Minimal working UI wireup

Working:
  - location.hash
  - click on slider
  - stepper buttons
  - UI update (except authors)
Not working:
  - playback
  - bugs in transition code
This commit is contained in:
s1341 2013-12-16 13:59:07 +02:00
parent 3013bab251
commit eef08490b2
4 changed files with 139 additions and 329 deletions

View file

@ -93,10 +93,7 @@ $.Class("SliderUI",
handle.element.css('left', (handle.value * this._getStep()) );
}
},
// this internal version of _setValue should only be used to render
// when the handle changes position as a result of UI events handled
// by this slider.
_setValue: function (value) {
setValue: function (value) {
if (value < 0)
value = 0;
if (value > this.options.max)
@ -105,11 +102,6 @@ $.Class("SliderUI",
this.current_value = value;
this.render();
},
// this 'public' version of _setValue also triggers a change event
setValue: function(value) {
this._setValue(value);
this._trigger("change", value);
},
setMax: function (max) {
this.options.max = max;
this.render();
@ -136,14 +128,14 @@ $.Class("SliderUI",
var start_value = Math.floor((event.clientX-_this.element.offset().left) / _this._getStep());
console.log("sliderbar mousedown, value:", start_value);
if (_this.current_value != start_value)
_this._setValue(start_value);
_this.setValue(start_value);
$(document).on("mousemove.slider", function (event) {
var current_value = Math.floor((event.clientX-_this.element.offset().left) / _this._getStep());
console.log("sliderbar mousemove, value:", current_value);
// don't change the value if it hasn't actually changed!
if (_this.current_value != current_value) {
_this._setValue(current_value);
_this.setValue(current_value);
_this._trigger("slide", current_value);
}
});
@ -155,7 +147,7 @@ $.Class("SliderUI",
var end_value = Math.floor((event.clientX-_this.element.offset().left) / _this._getStep());
console.log("sliderbar mouseup, value:", end_value);
// always change the value at mouseup
_this._setValue(end_value);
_this.setValue(end_value);
_this._trigger("change", end_value);
});