Follow mousemove
diff --git a/dev/js/src/menu/slider.js b/dev/js/src/menu/slider.js
index c1f0440..3313d70 100644
--- a/dev/js/src/menu/slider.js
+++ b/dev/js/src/menu/slider.js
@@ -7,10 +7,54 @@
return Object.create(this)._init();
},
+ _mousemove : function (e) {
+
+ var offset = parseInt(
+ (
+ (e.clientY - this._event.init)
+ / this._rulerHeight
+ ) * this._screens
+ );
+
+ this.offset(offset);
+
+ e.halt();
+ /*
+ isTouch?e.touches[0]:e
+ ,offset = horizontal?client.clientX - lastClient.clientX:client.clientY - lastClient.clientY
+ ,barPos = Math.min(Math.max(orgBarPos + offset,0),dir.viewportSize-dir.barSize)
+ ;
+ //
+ inst.viewport[getScroll(horizontal)] = (barPos/dir.viewportSize)*dir.viewportScrollSize;
+ */
+ },
+
+ _mouseup : function (e) {
+
+ window.removeEventListener('mousemove', this._event.mov);
+ window.removeEventListener('mouseup', this._event.up);
+ },
+
+ _mousedown : function (e) {
+ // Bind drag handler
+ var ev = this._event;
+ ev.init = e.clientY;
+ ev.mov = this._mousemove.bind(this);
+ ev.up = this._mouseup.bind(this);
+
+ this._rulerHeight = this._element.clientHeight; // offsetHeight?
+
+ window.addEventListener('mousemove', ev.mov);
+ window.addEventListener('mouseup', ev.up);
+
+ e.halt();
+ },
+
// Initialize prefix object
_init : function () {
this._offset = 0;
+ this._event = {};
this._element = document.createElement('div');
this._element.setAttribute('class', 'ruler');
@@ -19,26 +63,17 @@
document.createElement('span')
);
+ // TODO: Support touch!
+ this._slider.addEventListener('mousedown', this._mousedown.bind(this), false);
+
this._element.appendChild(document.createElement('div'));
-
-/*
- this._string = '';
-
- // Add prefix span
- this._element = document.createElement('span');
- this._element.classList.add('pref');
- // Connect action
-
- if (this["onclick"] !== undefined)
- this._element["onclick"] = this.onclick.bind(this);
-
-*/
return this;
},
_initSize : function () {
this._height = ((this._limit / this._length) * 100);
- this._step = (100 - this._height) / (this._length - this._limit);
+ this._screens = this._length - this._limit;
+ this._step = (100 - this._height) / this._screens;
},
show : function (i) {
@@ -59,6 +94,9 @@
if (off === undefined)
return this._offset;
+ if (off === this._offset || off > this._screens || off < 0)
+ return;
+
this._offset = off;
this._slider.style.top = (this._step * off) + '%';
},