Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(slider): make modelValue be set on pressdown
Browse files Browse the repository at this point in the history
Closes #1296.
  • Loading branch information
ajoslin committed Jan 27, 2015
1 parent 8a0411f commit 7028a75
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/slider/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,21 @@ function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdThemi
element[0].focus();
refreshSliderDimensions();

setSliderFromEvent(ev);
var exactVal = percentToValue( positionToPercent( ev.pointer.x ));
var closestVal = minMaxValidator( stepValidator(exactVal) );
scope.$apply(function() {
setModelValue( closestVal );
setSliderPercent( valueToPercent(closestVal));
});
}
function onPressUp(ev) {
element.removeClass('dragging active');

var exactVal = percentToValue( positionToPercent( ev.pointer.x ));
var closestVal = minMaxValidator( stepValidator(exactVal) );
scope.$apply(function() {
setModelValue(closestVal);
});
}
function onDragStart(ev) {
if (isDisabledGetter(scope)) return;
Expand All @@ -309,14 +320,6 @@ function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdThemi
if (!isDragging) return;
ev.stopPropagation();
isDragging = false;

var exactVal = percentToValue( positionToPercent( ev.pointer.x ));
var closestVal = minMaxValidator( stepValidator(exactVal) );

setSliderPercent( valueToPercent(closestVal));
$$rAF(function(){
setModelValue( closestVal );
});
}

function setSliderFromEvent(ev) {
Expand Down

0 comments on commit 7028a75

Please sign in to comment.