Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

md-discrete sliders often does not snap to nearest step #1431

Closed
LuminescentMoon opened this issue Feb 9, 2015 · 5 comments
Closed

md-discrete sliders often does not snap to nearest step #1431

LuminescentMoon opened this issue Feb 9, 2015 · 5 comments
Assignees
Milestone

Comments

@LuminescentMoon
Copy link

This issue has appeared in the last 2-3 days. An example of this issue can be found here.

@ThomasBurleson ThomasBurleson added this to the 0.9.0 milestone Feb 9, 2015
@ThomasBurleson
Copy link
Contributor

@robertmesserle - something is messed up... is mdGestures interfering?

@mckenzielong
Copy link
Contributor

In slider.js, the slider position is never being updated after the drag / event. The slider position is set in onPressDown at the beginning of the event, but as I mentioned, not after the event. Add setSliderPercentage call after the model is updated?

    function onPressUp(ev) {
      if (isDisabledGetter()) return;

      element.removeClass('dragging active');

      var exactVal = percentToValue( positionToPercent( ev.pointer.x ));
      var closestVal = minMaxValidator( stepValidator(exactVal) );
      scope.$apply(function() {
        setModelValue(closestVal);
        setSliderPercent( valueToPercent(closestVal));
      });
    }

Kind of unrelated, but should there be a blur call in here?

@ThomasBurleson
Copy link
Contributor

@robertmesserle - is this an issue with $mdGesture ?

@robertmesserle
Copy link
Contributor

@ThomasBurleson I haven't had a chance to look into it yet, but that's what I suspect.

Update: After looking into it, $mdGesture looks to be firing properly. I added a fix. Seems like a minor difference in the way the events were fired may have been the cause, but I'm not entirely sure.

@mckenzielong
Copy link
Contributor

This was introduced by this change: 7028a75

Adding this back into onDragEnd also resolves the issue -- either way there was a missing call to setSliderPercent.

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

Edit: disregard the bit about re-adding to onDragEnd. Adding that code in onDragEnd reintroduces unintended 'click' behavior...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants