diff --git a/DOC.md b/DOC.md
index 039035b0..0534e95f 100644
--- a/DOC.md
+++ b/DOC.md
@@ -11065,6 +11065,28 @@ const stooges = [
pluck(stooges, 'name'); // -> ['moe', 'larry', 'curly']
```
+## pointerEvent
+
+Get the pointer event name, use touch and mouse events as a fallback if not supported.
+
+
+Type Definition
+
+```typescript
+function pointerEvent(type: 'down' | 'move' | 'up'): string;
+```
+
+
+
+|Name |Desc |
+|------|----------------------------|
+|type |Event type, down, move or up|
+|return|Pointer event name |
+
+```javascript
+pointerEvent('down'); // -> 'pointerdown' if supported
+```
+
## precision
Find decimal precision of a given number.
diff --git a/DOC_CN.md b/DOC_CN.md
index 0dc47d64..fd3361db 100644
--- a/DOC_CN.md
+++ b/DOC_CN.md
@@ -11056,6 +11056,28 @@ const stooges = [
pluck(stooges, 'name'); // -> ['moe', 'larry', 'curly']
```
+## pointerEvent
+
+获取 pointer 事件名,如果不支持使用 touch 或 mouse 事件替代。
+
+
+类型定义
+
+```typescript
+function pointerEvent(type: 'down' | 'move' | 'up'): string;
+```
+
+
+
+|参数名|说明|
+|-----|---|
+|type|事件类型,down,move 或 up|
+|返回值|pointer 事件名|
+
+```javascript
+pointerEvent('down'); // -> 'pointerdown' if supported
+```
+
## precision
获取数字的精度。
diff --git a/cspell.json b/cspell.json
index 805f8304..c81bd7b8 100644
--- a/cspell.json
+++ b/cspell.json
@@ -321,6 +321,7 @@
"pick",
"pipe",
"pluck",
+ "pointerEvent",
"precision",
"prefetch",
"prefix",
diff --git a/i18n/pointerEvent.md b/i18n/pointerEvent.md
new file mode 100644
index 00000000..d8e0644b
--- /dev/null
+++ b/i18n/pointerEvent.md
@@ -0,0 +1,8 @@
+## CN
+
+获取 pointer 事件名,如果不支持使用 touch 或 mouse 事件替代。
+
+|参数名|说明|
+|-----|---|
+|type|事件类型,down,move 或 up|
+|返回值|pointer 事件名|
diff --git a/index.json b/index.json
index 1a112ecf..42eb640e 100644
--- a/index.json
+++ b/index.json
@@ -5196,6 +5196,18 @@
"browser"
]
},
+ "pointerEvent": {
+ "dependencies": [
+ "root"
+ ],
+ "description": "Get the pointer event name, use touch and mouse events as a fallback if not supported.",
+ "env": [
+ "browser"
+ ],
+ "test": [
+ "browser"
+ ]
+ },
"precision": {
"dependencies": [],
"description": "Find decimal precision of a given number.",
diff --git a/src/Channel.js b/src/Channel.js
index 79ffdaef..58f285d6 100644
--- a/src/Channel.js
+++ b/src/Channel.js
@@ -101,7 +101,7 @@ exports = Emitter.extend({
},
isConnected(connection) {
if (connection === this) {
- throw new Error('Connection cannot be connected to itself.');
+ throw new Error('Channel cannot be connected to itself.');
}
return some(this._connections, item => item === connection);
diff --git a/src/pointerEvent.js b/src/pointerEvent.js
new file mode 100644
index 00000000..8c40a8b2
--- /dev/null
+++ b/src/pointerEvent.js
@@ -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];
+};
diff --git a/test/pointerEvent.js b/test/pointerEvent.js
new file mode 100644
index 00000000..9b81ea2b
--- /dev/null
+++ b/test/pointerEvent.js
@@ -0,0 +1,5 @@
+tests([
+ ['up', 'pointerup'],
+ ['down', 'pointerdown'],
+ ['move', 'pointermove']
+]);