@onesy/ui-react 1.0.175 → 1.0.177
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Interaction/Interaction.d.ts +1 -0
- package/Interaction/Interaction.js +24 -15
- package/esm/Interaction/Interaction.js +24 -15
- package/esm/index.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
|
@@ -158,6 +158,7 @@ const Interaction = props_ => {
|
|
|
158
158
|
subscription,
|
|
159
159
|
clear,
|
|
160
160
|
disabled,
|
|
161
|
+
mobileDelay = 15,
|
|
161
162
|
className
|
|
162
163
|
} = props;
|
|
163
164
|
const {
|
|
@@ -232,22 +233,32 @@ const Interaction = props_ => {
|
|
|
232
233
|
remove('mouse-down');
|
|
233
234
|
removeWaves();
|
|
234
235
|
};
|
|
236
|
+
const onTouchStart = () => {
|
|
237
|
+
onMouseUp();
|
|
238
|
+
onMouseIn();
|
|
239
|
+
};
|
|
240
|
+
const onTouchUp = () => {
|
|
241
|
+
setTimeout(() => {
|
|
242
|
+
onMouseUp();
|
|
243
|
+
onMouseOut();
|
|
244
|
+
}, mobileDelay);
|
|
245
|
+
};
|
|
246
|
+
const onTouchCancel = () => {
|
|
247
|
+
setTimeout(() => {
|
|
248
|
+
onMouseUp();
|
|
249
|
+
onMouseOut();
|
|
250
|
+
}, mobileDelay);
|
|
251
|
+
};
|
|
235
252
|
const rootDocument = (0, _utils.isEnvironment)('browser') ? ((_refs$root$current = refs.root.current) === null || _refs$root$current === void 0 ? void 0 : _refs$root$current.ownerDocument) || window.document : undefined;
|
|
236
253
|
if (parent) {
|
|
237
254
|
if (touch) {
|
|
238
|
-
parent.addEventListener('touchstart',
|
|
239
|
-
passive: true
|
|
240
|
-
});
|
|
241
|
-
parent.addEventListener('touchend', onMouseUp, {
|
|
242
|
-
passive: true
|
|
243
|
-
});
|
|
244
|
-
rootDocument.addEventListener('touchend', onMouseUp, {
|
|
255
|
+
parent.addEventListener('touchstart', onTouchStart, {
|
|
245
256
|
passive: true
|
|
246
257
|
});
|
|
247
|
-
|
|
258
|
+
rootDocument.addEventListener('touchend', onTouchUp, {
|
|
248
259
|
passive: true
|
|
249
260
|
});
|
|
250
|
-
|
|
261
|
+
rootDocument.addEventListener('touchcancel', onTouchCancel, {
|
|
251
262
|
passive: true
|
|
252
263
|
});
|
|
253
264
|
} else {
|
|
@@ -261,11 +272,9 @@ const Interaction = props_ => {
|
|
|
261
272
|
refs.init.current = true;
|
|
262
273
|
return () => {
|
|
263
274
|
if (parent) {
|
|
264
|
-
parent.removeEventListener('touchstart',
|
|
265
|
-
|
|
266
|
-
rootDocument.removeEventListener('
|
|
267
|
-
parent.removeEventListener('touchstart', onMouseIn);
|
|
268
|
-
parent.removeEventListener('touchend', onMouseOut);
|
|
275
|
+
parent.removeEventListener('touchstart', onTouchStart);
|
|
276
|
+
rootDocument.removeEventListener('touchend', onTouchUp);
|
|
277
|
+
rootDocument.removeEventListener('touchcancel', onTouchCancel);
|
|
269
278
|
parent.removeEventListener('mousedown', onMouseDown);
|
|
270
279
|
parent.removeEventListener('mouseup', onMouseUp);
|
|
271
280
|
rootDocument.removeEventListener('mouseup', onMouseUp);
|
|
@@ -273,7 +282,7 @@ const Interaction = props_ => {
|
|
|
273
282
|
parent.removeEventListener('mouseleave', onMouseOut);
|
|
274
283
|
}
|
|
275
284
|
};
|
|
276
|
-
}, [touch]);
|
|
285
|
+
}, [mobileDelay, touch]);
|
|
277
286
|
_react.default.useEffect(() => {
|
|
278
287
|
if (refs.init.current) {
|
|
279
288
|
if (refs.interactions.current.length) setInteractions([]);
|
|
@@ -150,6 +150,7 @@ const Interaction = props_ => {
|
|
|
150
150
|
subscription,
|
|
151
151
|
clear,
|
|
152
152
|
disabled,
|
|
153
|
+
mobileDelay = 15,
|
|
153
154
|
className
|
|
154
155
|
} = props;
|
|
155
156
|
const {
|
|
@@ -223,22 +224,32 @@ const Interaction = props_ => {
|
|
|
223
224
|
remove('mouse-down');
|
|
224
225
|
removeWaves();
|
|
225
226
|
};
|
|
227
|
+
const onTouchStart = () => {
|
|
228
|
+
onMouseUp();
|
|
229
|
+
onMouseIn();
|
|
230
|
+
};
|
|
231
|
+
const onTouchUp = () => {
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
onMouseUp();
|
|
234
|
+
onMouseOut();
|
|
235
|
+
}, mobileDelay);
|
|
236
|
+
};
|
|
237
|
+
const onTouchCancel = () => {
|
|
238
|
+
setTimeout(() => {
|
|
239
|
+
onMouseUp();
|
|
240
|
+
onMouseOut();
|
|
241
|
+
}, mobileDelay);
|
|
242
|
+
};
|
|
226
243
|
const rootDocument = isEnvironment('browser') ? refs.root.current?.ownerDocument || window.document : undefined;
|
|
227
244
|
if (parent) {
|
|
228
245
|
if (touch) {
|
|
229
|
-
parent.addEventListener('touchstart',
|
|
230
|
-
passive: true
|
|
231
|
-
});
|
|
232
|
-
parent.addEventListener('touchend', onMouseUp, {
|
|
233
|
-
passive: true
|
|
234
|
-
});
|
|
235
|
-
rootDocument.addEventListener('touchend', onMouseUp, {
|
|
246
|
+
parent.addEventListener('touchstart', onTouchStart, {
|
|
236
247
|
passive: true
|
|
237
248
|
});
|
|
238
|
-
|
|
249
|
+
rootDocument.addEventListener('touchend', onTouchUp, {
|
|
239
250
|
passive: true
|
|
240
251
|
});
|
|
241
|
-
|
|
252
|
+
rootDocument.addEventListener('touchcancel', onTouchCancel, {
|
|
242
253
|
passive: true
|
|
243
254
|
});
|
|
244
255
|
} else {
|
|
@@ -252,11 +263,9 @@ const Interaction = props_ => {
|
|
|
252
263
|
refs.init.current = true;
|
|
253
264
|
return () => {
|
|
254
265
|
if (parent) {
|
|
255
|
-
parent.removeEventListener('touchstart',
|
|
256
|
-
|
|
257
|
-
rootDocument.removeEventListener('
|
|
258
|
-
parent.removeEventListener('touchstart', onMouseIn);
|
|
259
|
-
parent.removeEventListener('touchend', onMouseOut);
|
|
266
|
+
parent.removeEventListener('touchstart', onTouchStart);
|
|
267
|
+
rootDocument.removeEventListener('touchend', onTouchUp);
|
|
268
|
+
rootDocument.removeEventListener('touchcancel', onTouchCancel);
|
|
260
269
|
parent.removeEventListener('mousedown', onMouseDown);
|
|
261
270
|
parent.removeEventListener('mouseup', onMouseUp);
|
|
262
271
|
rootDocument.removeEventListener('mouseup', onMouseUp);
|
|
@@ -264,7 +273,7 @@ const Interaction = props_ => {
|
|
|
264
273
|
parent.removeEventListener('mouseleave', onMouseOut);
|
|
265
274
|
}
|
|
266
275
|
};
|
|
267
|
-
}, [touch]);
|
|
276
|
+
}, [mobileDelay, touch]);
|
|
268
277
|
React.useEffect(() => {
|
|
269
278
|
if (refs.init.current) {
|
|
270
279
|
if (refs.interactions.current.length) setInteractions([]);
|
package/esm/index.js
CHANGED
package/index.js
CHANGED