-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(toggle): uses PanGesture abstraction
fixes #9428
- Loading branch information
1 parent
0b642e7
commit 6ef6f0a
Showing
7 changed files
with
187 additions
and
97 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { GestureController, GesturePriority, GESTURE_TOGGLE } from '../../gestures/gesture-controller'; | ||
import { PanGesture } from '../../gestures/drag-gesture'; | ||
import { pointerCoord } from '../../util/dom'; | ||
import { NativeRafDebouncer } from '../../util/debouncer'; | ||
import { Toggle } from './toggle'; | ||
|
||
/** | ||
* @private | ||
*/ | ||
export class ToggleGesture extends PanGesture { | ||
|
||
constructor(public toogle: Toggle, gestureCtrl: GestureController) { | ||
super(toogle.getNativeElement(), { | ||
maxAngle: 20, | ||
threshold: 0, | ||
debouncer: new NativeRafDebouncer(), | ||
gesture: gestureCtrl.createGesture({ | ||
name: GESTURE_TOGGLE, | ||
priority: GesturePriority.Toggle, | ||
}) | ||
}); | ||
} | ||
|
||
canStart(ev: any): boolean { | ||
return true; | ||
} | ||
|
||
onDragStart(ev: any) { | ||
ev.preventDefault(); | ||
|
||
this.toogle._onDragStart(pointerCoord(ev).x); | ||
} | ||
|
||
onDragMove(ev: any) { | ||
ev.preventDefault(); | ||
|
||
this.toogle._onDragMove(pointerCoord(ev).x); | ||
} | ||
|
||
onDragEnd(ev: any) { | ||
ev.preventDefault(); | ||
|
||
this.toogle._onDragEnd(pointerCoord(ev).x); | ||
} | ||
} |
This file contains 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 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
Oops, something went wrong.