-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it's fine for now- can you just add a TODO
to throttle the events later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could just be 0
without the ms
(hopefully the stylelint doesn't want this?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -58,6 +59,13 @@ export class MdSlideToggle implements AfterContentInit, ControlValueAccessor { | |||
private _hasFocus: boolean = false; | |||
private _isMousedown: boolean = false; | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use /** */
style comments for member / method descriptions
7f62032
to
cc6bcfc
Compare
LGTM! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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
/style
bindings, because we don't want to trigger a change detection for each Drag Event.