|
|
|
@ -1,12 +1,16 @@
|
|
|
|
|
import { children, Component, createEffect, JSX, onCleanup } from "solid-js";
|
|
|
|
|
import { attachTouch, AttachTouchOptions, Touch } from "../index.js";
|
|
|
|
|
|
|
|
|
|
export type TouchHandler<T = Touch> = (touches: Map<number, Touch>, touch: T) => void;
|
|
|
|
|
import { Component, createEffect, createSignal, type JSX, onCleanup } from "solid-js";
|
|
|
|
|
import { attachTouch, type AttachTouchOptions, type Touch } from "../index.js";
|
|
|
|
|
|
|
|
|
|
export type PixelPefectTouchProps = {
|
|
|
|
|
children: JSX.Element;
|
|
|
|
|
|
|
|
|
|
onMount?: (element: HTMLDivElement) => void;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called whenever the touchMap is updated.
|
|
|
|
|
* You can safely pass the setter of a solid.js signal to have reactive updates to the touchMap.
|
|
|
|
|
**/
|
|
|
|
|
onUpdate?: (touchMap: Map<number, Touch>) => void
|
|
|
|
|
} & AttachTouchOptions;
|
|
|
|
|
|
|
|
|
|
export const PixelPerfectTouch: Component<PixelPefectTouchProps> = (
|
|
|
|
@ -19,7 +23,21 @@ export const PixelPerfectTouch: Component<PixelPefectTouchProps> = (
|
|
|
|
|
|
|
|
|
|
if (!element) return;
|
|
|
|
|
|
|
|
|
|
const cleanup = attachTouch(element, options);
|
|
|
|
|
const cleanup = attachTouch(element, {
|
|
|
|
|
...options,
|
|
|
|
|
onDown(touch, touchMap) {
|
|
|
|
|
options.onUpdate?.(new Map(touchMap));
|
|
|
|
|
options.onDown?.(touch, touchMap);
|
|
|
|
|
},
|
|
|
|
|
onUp(touch, touchMap) {
|
|
|
|
|
options.onUpdate?.(new Map(touchMap));
|
|
|
|
|
options.onUp?.(touch, touchMap);
|
|
|
|
|
},
|
|
|
|
|
onMove(touches, touchMap) {
|
|
|
|
|
options.onUpdate?.(new Map(touchMap));
|
|
|
|
|
options.onMove?.(touches, touchMap);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onCleanup(cleanup);
|
|
|
|
|
});
|
|
|
|
|