Repository navigation
feat(slide-toggle): add drag functionality to thumb - #750
Conversation
d550d5a to
0aa322a
Compare
|
@jelbourn Not sure how HammerJS will run on the users Environment later. What were your thoughts? |
0aa322a to
fc9f815
Compare
|
|
||
| hammerManager.on('panstart', this._onDragStart.bind(this)); | ||
| hammerManager.on('panmove', this._onDrag.bind(this)); | ||
| hammerManager.on('panend', this._onDragEnd.bind(this)); |
There was a problem hiding this comment.
Also, I tried this on my phone (Galaxy S6) and it was a bit sluggish. I wonder if we should throttle these drag events (would we need a throttle function in the library, though...)
There was a problem hiding this comment.
Actually, it's fine for now- can you just add a TODO to throttle the events later?
There was a problem hiding this comment.
Why are you adding the events directly instead of using handlers defined via the template, e.g.,
Yeah great idea - as we discussed on Slack
Also, I tried this on my phone (Galaxy S6) and it was a bit sluggish. I wonder if we should throttle these drag events (would we need a throttle function in the library, though...)
Yeah I fixed that by calculating the absolute difference (as done in the slider)
Actually, it's fine for now- can you just add a TODO to throttle the events later?
Not sure, why throttling is necessary here? It seems like throttling would probably make it less smooth.
fc9f815 to
975495a
Compare
|
@jelbourn Addressed your comments One thing I've noticed:
cc. @iveysaur (Also noticed this in the Slider component) |
| // Once the thumb container is being dragged around, we remove the transition duration to | ||
| // make the drag feeling fast and not delayed. | ||
| &.md-dragging { | ||
| transition-duration: 0ms; |
There was a problem hiding this comment.
Could just be 0 without the ms (hopefully the stylelint doesn't want this?)
There was a problem hiding this comment.
Seems like it's not allowed to have just zero here, because it needs a time unit.
c173a43 to
f68d38f
Compare
f68d38f to
226dc3e
Compare
| private _isInitialized: boolean = false; | ||
| private _slideRenderer: MdSlideToggleRenderer = null; | ||
|
|
||
| // State of the current drag, which holds required variables for the drag. |
There was a problem hiding this comment.
Nit: use /** */ style comments for member / method descriptions
7f62032 to
cc6bcfc
Compare
|
LGTM! |
This adds the dragging functionality to the
slide-toggle.It works pretty neat. Also tested on older touch devices. Seems like HammerJS is doing a pretty good job.
FYI: I intentionally didn't use the
class/stylebindings, because we don't want to trigger a change detection for each Drag Event.