Skip to content

Commit

Permalink
use boundaries to normalize drag position and only update up knob pos…
Browse files Browse the repository at this point in the history
…ition really changes
  • Loading branch information
peuter committed Oct 29, 2017
1 parent 6534214 commit 0584cad
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions source/class/cv/ui/website/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ qx.Class.define('cv.ui.website.Slider', {
*/
members: {
__pointerMoveEvent: null,
__positionKnob: null,

init: function() {
this.base(arguments);
Expand Down Expand Up @@ -109,14 +110,19 @@ qx.Class.define('cv.ui.website.Slider', {
e.preventDefault();

if (this.__dragMode) {
var dragPosition = e.getDocumentLeft();
// position normalization
var dragBoundaries = this._getDragBoundaries();
var dragPosition = Math.max(e.getDocumentLeft(), dragBoundaries.min);
dragPosition = Math.min(dragPosition, dragBoundaries.max);

var paddingLeft = Math.ceil(parseFloat(this.getStyle("paddingLeft")) || 0);
var positionKnob = dragPosition - this.getOffset().left - this._getHalfKnobWidth() - paddingLeft;

this.setValue(this._getNearestValue(dragPosition));
if (positionKnob > 0) {
if (this.__positionKnob !== positionKnob) {
this.setValue(this._getNearestValue(dragPosition));
this._setKnobPosition(positionKnob);
this.emit("changePosition", positionKnob);
this.__positionKnob = positionKnob;
}
e.stopPropagation();
}
Expand Down

0 comments on commit 0584cad

Please sign in to comment.