-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
121 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -321,6 +321,7 @@ | |
"pick", | ||
"pipe", | ||
"pluck", | ||
"pointerEvent", | ||
"precision", | ||
"prefetch", | ||
"prefix", | ||
|
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,8 @@ | ||
## CN | ||
|
||
获取 pointer 事件名,如果不支持使用 touch 或 mouse 事件替代。 | ||
|
||
|参数名|说明| | ||
|-----|---| | ||
|type|事件类型,down,move 或 up| | ||
|返回值|pointer 事件名| |
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,50 @@ | ||
/* Get the pointer event name, use touch and mouse events as a fallback if not supported. | ||
* | ||
* |Name |Desc | | ||
* |------|----------------------------| | ||
* |type |Event type, down, move or up| | ||
* |return|Pointer event name | | ||
*/ | ||
|
||
/* example | ||
* pointerEvent('down'); // -> 'pointerdown' if supported | ||
*/ | ||
|
||
/* module | ||
* env: browser | ||
*/ | ||
|
||
/* typescript | ||
* export declare function pointerEvent(type: 'down' | 'move' | 'up'): string; | ||
*/ | ||
|
||
_('root'); | ||
|
||
const touchEvents = { | ||
down: 'touchstart', | ||
move: 'touchmove', | ||
up: 'touchend' | ||
}; | ||
|
||
const mouseEvents = { | ||
down: 'mousedown', | ||
move: 'mousemove', | ||
up: 'mouseup' | ||
}; | ||
|
||
const pointerEvents = { | ||
down: 'pointerdown', | ||
move: 'pointermove', | ||
up: 'pointerup' | ||
}; | ||
|
||
const hasPointerSupport = 'PointerEvent' in root; | ||
const hasTouchSupport = 'ontouchstart' in root; | ||
|
||
exports = function(type) { | ||
if (hasPointerSupport) { | ||
return pointerEvents[type]; | ||
} | ||
|
||
return hasTouchSupport ? touchEvents[type] : mouseEvents[type]; | ||
}; |
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,5 @@ | ||
tests([ | ||
['up', 'pointerup'], | ||
['down', 'pointerdown'], | ||
['move', 'pointermove'] | ||
]); |