Fixed relative movement of slider in menus
diff --git a/dev/js/spec/menuSpec.js b/dev/js/spec/menuSpec.js
index ba6f1fd..09848fc 100644
--- a/dev/js/spec/menuSpec.js
+++ b/dev/js/spec/menuSpec.js
@@ -1608,10 +1608,12 @@
// This will normally be done on
menu.slider()._rulerHeight = 100;
menu.slider()._sliderHeight = 40;
+ menu.slider()._event.initOffset = 0;
expect(menu.slider().length()).toEqual(5);
menu.slider().movetoRel(10);
expect(menu.slider().offset()).toEqual(0);
+
expect(menu.shownItem(0).active()).toBe(true);
expect(menu.shownItem(0).lcField()).toEqual(' constituency');
menu.slider().movetoRel(24);
diff --git a/dev/js/src/hint/item.js b/dev/js/src/hint/item.js
index 317dae7..3747a72 100644
--- a/dev/js/src/hint/item.js
+++ b/dev/js/src/hint/item.js
@@ -22,6 +22,8 @@
this._name = params[0];
this._action = params[1];
this._lcField = ' ' + this._name.toLowerCase();
+
+ console.log('!!!!');
if (params.length > 2) {
this._desc = params[2];
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 8fcc162..e79837b 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -63,6 +63,7 @@
domReady(function (event) {
var obj = {};
+
var session = sessionClass.create('KalamarJS');
// What should be visible?
diff --git a/dev/js/src/menu/slider.js b/dev/js/src/menu/slider.js
index baef16a..5df1543 100644
--- a/dev/js/src/menu/slider.js
+++ b/dev/js/src/menu/slider.js
@@ -73,10 +73,16 @@
* @param {number} relative position
*/
movetoRel : function (relativePos) {
+
+ // This is important to find the correct percentage!
var diffHeight = (this._rulerHeight - this._sliderHeight);
var relativeOffset = (relativePos / diffHeight);
- var off = this.offset(parseInt(relativeOffset * this._screens));
+ // Offset is a value 0 to this._screens
+ var off = this.offset(
+ parseInt(relativeOffset * this._screens) + this._event.initOffset
+ );
+
if (off !== undefined) {
this._menu.screen(off);
};
@@ -206,7 +212,12 @@
_mousedown : function (e) {
// Bind drag handler
var ev = this._event;
- ev.init = e.clientY - (this._step * this._offset);
+
+ // _step * _offset is the distance of the ruler to the top
+ ev.init = e.clientY;
+ ev.initOffset = this._offset;
+ // By substracting that, it is like initializing to the first point
+
ev.mov = this._mousemove.bind(this);
ev.up = this._mouseup.bind(this);