Skip to content

Commit

Permalink
fix: Replace hammerjs with ember-gesture-modifiers, fixes #138 (#139)
Browse files Browse the repository at this point in the history
* WIP Attempt to fix #138 Replace hammerjs with ember-gesture-modifiers

* fix: move gestures devdep to dependencies

* fix: toggle direction for pan

* chore: test prerelease of pointer events

* fix: enabble pointer events

* chore: update pan in tests and remove jquery

* fix: bump gestures version

* chore: remove console log

Co-authored-by: Ilya Radchenko <knownasilya@gmail.com>
  • Loading branch information
lolmaus and knownasilya committed Nov 20, 2020
1 parent ac8ad6a commit 884c715
Show file tree
Hide file tree
Showing 7 changed files with 855 additions and 3,184 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@
# IDE project files
/.idea/
/*.iml
/.vscode/
/.history/
14 changes: 3 additions & 11 deletions addon/components/x-toggle-switch/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,14 @@ export default class XToggleSwitch extends Component {
}

@action
handlePanRight() {
handlePan(touchData) {
if (this.disabled) {
return;
}

this.sendToggle(true);
this._disableLabelUntilMouseUp();
}

@action
handlePanLeft() {
if (this.disabled) {
return;
}
const isToggled = touchData.current.distanceX > 0;

this.sendToggle(false);
this.sendToggle(isToggled);
this._disableLabelUntilMouseUp();
}

Expand Down
8 changes: 5 additions & 3 deletions addon/components/x-toggle-switch/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
{{if @value 'x-toggle-container-checked'}}
"
...attributes
{{recognize-gesture 'pan'}}
{{on 'panleft' this.handlePanLeft}}
{{on 'panright' this.handlePanRight}}
{{did-pan
onPanStart=this.handlePan
onPan=this.handlePan
pointerTypes=(array 'touch' 'mouse')
}}
>
<input
class='x-toggle'
Expand Down

0 comments on commit 884c715

Please sign in to comment.