@onesy/ui-react 1.0.174 → 1.0.176
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.js +37 -6
- package/esm/Interaction/Interaction.js +37 -6
- package/esm/index.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
|
@@ -232,17 +232,48 @@ const Interaction = props_ => {
|
|
|
232
232
|
remove('mouse-down');
|
|
233
233
|
removeWaves();
|
|
234
234
|
};
|
|
235
|
+
const onTouchStart = () => {
|
|
236
|
+
onMouseUp();
|
|
237
|
+
onMouseIn();
|
|
238
|
+
};
|
|
239
|
+
const onTouchUp = () => {
|
|
240
|
+
setTimeout(() => {
|
|
241
|
+
onMouseUp();
|
|
242
|
+
onMouseOut();
|
|
243
|
+
}, 15);
|
|
244
|
+
};
|
|
245
|
+
const onTouchCancel = () => {
|
|
246
|
+
setTimeout(() => {
|
|
247
|
+
onMouseUp();
|
|
248
|
+
onMouseOut();
|
|
249
|
+
}, 15);
|
|
250
|
+
};
|
|
235
251
|
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
252
|
if (parent) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
253
|
+
if (touch) {
|
|
254
|
+
parent.addEventListener('touchstart', onTouchStart, {
|
|
255
|
+
passive: true
|
|
256
|
+
});
|
|
257
|
+
rootDocument.addEventListener('touchend', onTouchUp, {
|
|
258
|
+
passive: true
|
|
259
|
+
});
|
|
260
|
+
rootDocument.addEventListener('touchcancel', onTouchCancel, {
|
|
261
|
+
passive: true
|
|
262
|
+
});
|
|
263
|
+
} else {
|
|
264
|
+
parent.addEventListener('mousedown', onMouseDown);
|
|
265
|
+
parent.addEventListener('mouseup', onMouseUp);
|
|
266
|
+
rootDocument.addEventListener('mouseup', onMouseUp);
|
|
267
|
+
parent.addEventListener('mouseenter', onMouseIn);
|
|
268
|
+
parent.addEventListener('mouseleave', onMouseOut);
|
|
269
|
+
}
|
|
242
270
|
}
|
|
243
271
|
refs.init.current = true;
|
|
244
272
|
return () => {
|
|
245
273
|
if (parent) {
|
|
274
|
+
parent.removeEventListener('touchstart', onTouchStart);
|
|
275
|
+
rootDocument.removeEventListener('touchend', onTouchUp);
|
|
276
|
+
rootDocument.removeEventListener('touchcancel', onTouchCancel);
|
|
246
277
|
parent.removeEventListener('mousedown', onMouseDown);
|
|
247
278
|
parent.removeEventListener('mouseup', onMouseUp);
|
|
248
279
|
rootDocument.removeEventListener('mouseup', onMouseUp);
|
|
@@ -250,7 +281,7 @@ const Interaction = props_ => {
|
|
|
250
281
|
parent.removeEventListener('mouseleave', onMouseOut);
|
|
251
282
|
}
|
|
252
283
|
};
|
|
253
|
-
}, []);
|
|
284
|
+
}, [touch]);
|
|
254
285
|
_react.default.useEffect(() => {
|
|
255
286
|
if (refs.init.current) {
|
|
256
287
|
if (refs.interactions.current.length) setInteractions([]);
|
|
@@ -223,17 +223,48 @@ const Interaction = props_ => {
|
|
|
223
223
|
remove('mouse-down');
|
|
224
224
|
removeWaves();
|
|
225
225
|
};
|
|
226
|
+
const onTouchStart = () => {
|
|
227
|
+
onMouseUp();
|
|
228
|
+
onMouseIn();
|
|
229
|
+
};
|
|
230
|
+
const onTouchUp = () => {
|
|
231
|
+
setTimeout(() => {
|
|
232
|
+
onMouseUp();
|
|
233
|
+
onMouseOut();
|
|
234
|
+
}, 15);
|
|
235
|
+
};
|
|
236
|
+
const onTouchCancel = () => {
|
|
237
|
+
setTimeout(() => {
|
|
238
|
+
onMouseUp();
|
|
239
|
+
onMouseOut();
|
|
240
|
+
}, 15);
|
|
241
|
+
};
|
|
226
242
|
const rootDocument = isEnvironment('browser') ? refs.root.current?.ownerDocument || window.document : undefined;
|
|
227
243
|
if (parent) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
244
|
+
if (touch) {
|
|
245
|
+
parent.addEventListener('touchstart', onTouchStart, {
|
|
246
|
+
passive: true
|
|
247
|
+
});
|
|
248
|
+
rootDocument.addEventListener('touchend', onTouchUp, {
|
|
249
|
+
passive: true
|
|
250
|
+
});
|
|
251
|
+
rootDocument.addEventListener('touchcancel', onTouchCancel, {
|
|
252
|
+
passive: true
|
|
253
|
+
});
|
|
254
|
+
} else {
|
|
255
|
+
parent.addEventListener('mousedown', onMouseDown);
|
|
256
|
+
parent.addEventListener('mouseup', onMouseUp);
|
|
257
|
+
rootDocument.addEventListener('mouseup', onMouseUp);
|
|
258
|
+
parent.addEventListener('mouseenter', onMouseIn);
|
|
259
|
+
parent.addEventListener('mouseleave', onMouseOut);
|
|
260
|
+
}
|
|
233
261
|
}
|
|
234
262
|
refs.init.current = true;
|
|
235
263
|
return () => {
|
|
236
264
|
if (parent) {
|
|
265
|
+
parent.removeEventListener('touchstart', onTouchStart);
|
|
266
|
+
rootDocument.removeEventListener('touchend', onTouchUp);
|
|
267
|
+
rootDocument.removeEventListener('touchcancel', onTouchCancel);
|
|
237
268
|
parent.removeEventListener('mousedown', onMouseDown);
|
|
238
269
|
parent.removeEventListener('mouseup', onMouseUp);
|
|
239
270
|
rootDocument.removeEventListener('mouseup', onMouseUp);
|
|
@@ -241,7 +272,7 @@ const Interaction = props_ => {
|
|
|
241
272
|
parent.removeEventListener('mouseleave', onMouseOut);
|
|
242
273
|
}
|
|
243
274
|
};
|
|
244
|
-
}, []);
|
|
275
|
+
}, [touch]);
|
|
245
276
|
React.useEffect(() => {
|
|
246
277
|
if (refs.init.current) {
|
|
247
278
|
if (refs.interactions.current.length) setInteractions([]);
|
package/esm/index.js
CHANGED
package/index.js
CHANGED