parent
96a0847e2c
commit
a9b894d066
@ -1,2 +1,3 @@
|
|||||||
export * from "./PixelPerfectCanvas.jsx";
|
export * from "./PixelPerfectCanvas.jsx";
|
||||||
export * from "./PixelPerfectTouch.jsx";
|
export * from "./PixelPerfectTouch.jsx";
|
||||||
|
export * from "./usePannable.js";
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
import { createSignal } from "solid-js";
|
||||||
|
import { Pannable, PannableOptions, PannableState, Touch } from "../index.js";
|
||||||
|
|
||||||
|
export function usePannable(config: PannableOptions) {
|
||||||
|
const pannable = new Pannable(config);
|
||||||
|
const [state, setState] = createSignal<PannableState>(pannable.getState());
|
||||||
|
|
||||||
|
return {
|
||||||
|
update(touches: Map<number, Touch>) {
|
||||||
|
pannable.update(touches);
|
||||||
|
},
|
||||||
|
move(touches: Map<number, Touch>) {
|
||||||
|
pannable.move(touches);
|
||||||
|
const newState = pannable.getState();
|
||||||
|
setState(newState);
|
||||||
|
return newState;
|
||||||
|
},
|
||||||
|
zoom(amount: number, clientX?: number, clientY?: number) {
|
||||||
|
pannable.zoom(amount, clientX, clientY);
|
||||||
|
const newState = pannable.getState();
|
||||||
|
setState(newState);
|
||||||
|
return newState;
|
||||||
|
},
|
||||||
|
getState: state,
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in new issue