fix: passive events (sorry Dan)
This commit is contained in:
parent
aed0ab97cd
commit
10a9b28099
|
@ -21,25 +21,7 @@ const Stage = forwardRef(({
|
|||
ticker,
|
||||
}, fref) => {
|
||||
const hostRef = useRef();
|
||||
useImperativeHandle(fref, () => ({
|
||||
events: () => K.merge(
|
||||
[
|
||||
'click',
|
||||
'mousemove',
|
||||
'mouseout',
|
||||
'mousedown',
|
||||
'mouseup',
|
||||
'touchend',
|
||||
'touchmove',
|
||||
'touchstart',
|
||||
'wheel',
|
||||
]
|
||||
.map((event) => (
|
||||
K.fromEvents(
|
||||
renderer.element,
|
||||
event,
|
||||
// Normalize touch events.
|
||||
(event) => {
|
||||
const normalizeDeltaAndPosition = (event) => {
|
||||
let {
|
||||
clientX,
|
||||
clientY,
|
||||
|
@ -66,9 +48,25 @@ const Stage = forwardRef(({
|
|||
{get: () => [(clientX - left) / scale, (clientY - top) / scale]},
|
||||
);
|
||||
return event;
|
||||
},
|
||||
)
|
||||
};
|
||||
useImperativeHandle(fref, () => ({
|
||||
events: () => K.merge(
|
||||
[].concat(
|
||||
['touchmove', 'touchstart', 'wheel']
|
||||
.map((event) => (
|
||||
K.stream((emitter) => {
|
||||
const handler = (event) => {
|
||||
emitter.emit(normalizeDeltaAndPosition(event));
|
||||
};
|
||||
renderer.element.addEventListener(event, handler, {passive: true});
|
||||
return () => {
|
||||
renderer.element.removeEventListener(event, handler);
|
||||
}
|
||||
})
|
||||
)),
|
||||
['click', 'mousemove', 'mouseout', 'mousedown', 'mouseup', 'touchend']
|
||||
.map((event) => K.fromEvents(renderer.element, event, normalizeDeltaAndPosition)),
|
||||
),
|
||||
),
|
||||
}));
|
||||
useEffect(() => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user