-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make hammerjs optional (#2280)
* feat: make hammerjs optional Makes HammerJS and logs a warning if it's missing, instead of crashing the app. * Rename the MdHammerEvent interface. * Replace the HammerJS annotations with stripped-down alternatives. * Remove "hammerjs" from the "types" config.
- Loading branch information
Showing
10 changed files
with
80 additions
and
24 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
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,48 @@ | ||
/** | ||
* Stripped-down HammerJS annotations to be used within Material, which are necessary, | ||
* because HammerJS is an optional dependency. For the full annotations see: | ||
* https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/hammerjs | ||
*/ | ||
|
||
/** @docs-private */ | ||
export interface HammerInput { | ||
preventDefault: () => {}; | ||
deltaX: number; | ||
deltaY: number; | ||
center: { x: number; y: number; }; | ||
} | ||
|
||
/** @docs-private */ | ||
export interface HammerStatic { | ||
new(element: HTMLElement | SVGElement, options?: any): HammerManager; | ||
|
||
Pan: Recognizer; | ||
Swipe: Recognizer; | ||
Press: Recognizer; | ||
} | ||
|
||
/** @docs-private */ | ||
export interface Recognizer { | ||
new(options?: any): Recognizer; | ||
recognizeWith(otherRecognizer: Recognizer | string): Recognizer; | ||
} | ||
|
||
/** @docs-private */ | ||
export interface RecognizerStatic { | ||
new(options?: any): Recognizer; | ||
} | ||
|
||
/** @docs-private */ | ||
export interface HammerInstance { | ||
on(eventName: string, callback: Function): void; | ||
off(eventName: string, callback: Function): void; | ||
} | ||
|
||
/** @docs-private */ | ||
export interface HammerManager { | ||
add(recogniser: Recognizer | Recognizer[]): Recognizer; | ||
set(options: any): HammerManager; | ||
emit(event: string, data: any): void; | ||
off(events: string, handler?: Function): void; | ||
on(events: string, handler: Function): void; | ||
} |
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
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 |
---|---|---|
|
@@ -17,8 +17,6 @@ | |
"stripInternal": false, | ||
"typeRoots": [ | ||
"../../node_modules/@types" | ||
], | ||
"types": [ | ||
] | ||
}, | ||
"exclude": [ | ||
|