-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(slide-toggle): disabled theme not working and dragging works if disabled #1268
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
Merged
jelbourn
merged 4 commits into
angular:master
from
devversion:fix/slide-toggle-drag-theme
Oct 5, 2016
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,16 +215,24 @@ export class MdSlideToggle implements AfterContentInit, ControlValueAccessor { | |
|
||
/** TODO: internal */ | ||
_onDragStart() { | ||
this._slideRenderer.startThumbDrag(this.checked); | ||
if (!this.disabled) { | ||
this._slideRenderer.startThumbDrag(this.checked); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually planned to add some gesture tests in another PR (because of big changes), but I will try to add them to this PR soon. |
||
} | ||
|
||
/** TODO: internal */ | ||
_onDrag(event: HammerInput) { | ||
this._slideRenderer.updateThumbPosition(event.deltaX); | ||
if (this._slideRenderer.isDragging()) { | ||
this._slideRenderer.updateThumbPosition(event.deltaX); | ||
} | ||
} | ||
|
||
/** TODO: internal */ | ||
_onDragEnd() { | ||
if (!this._slideRenderer.isDragging()) { | ||
return; | ||
} | ||
|
||
// Notice that we have to stop outside of the current event handler, | ||
// because otherwise the click event will be fired and will reset the new checked variable. | ||
setTimeout(() => { | ||
|
@@ -258,7 +266,7 @@ class SlideToggleRenderer { | |
|
||
/** Initializes the drag of the slide-toggle. */ | ||
startThumbDrag(checked: boolean) { | ||
if (!this._thumbBarWidth) { | ||
if (!this.isDragging()) { | ||
this._thumbBarWidth = this._thumbBarEl.clientWidth - this._thumbEl.clientWidth; | ||
this._checked = checked; | ||
this._thumbEl.classList.add('md-dragging'); | ||
|
@@ -267,7 +275,7 @@ class SlideToggleRenderer { | |
|
||
/** Stops the current drag and returns the new checked value. */ | ||
stopThumbDrag(): boolean { | ||
if (this._thumbBarWidth) { | ||
if (this.isDragging()) { | ||
this._thumbBarWidth = null; | ||
this._thumbEl.classList.remove('md-dragging'); | ||
|
||
|
@@ -279,10 +287,8 @@ class SlideToggleRenderer { | |
|
||
/** Updates the thumb containers position from the specified distance. */ | ||
updateThumbPosition(distance: number) { | ||
if (this._thumbBarWidth) { | ||
this._percentage = this._getThumbPercentage(distance); | ||
applyCssTransform(this._thumbEl, `translate3d(${this._percentage}%, 0, 0)`); | ||
} | ||
this._percentage = this._getThumbPercentage(distance); | ||
applyCssTransform(this._thumbEl, `translate3d(${this._percentage}%, 0, 0)`); | ||
} | ||
|
||
/** Retrieves the percentage of thumb from the moved distance. */ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Wouldn't autoprefixer do 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 there is no autoprefixer anymore, and
user-select
is also kind of a special property for the prefixer (e.g Material 1)