UNPKG

@zoom-image/vue

Version:
42 lines (40 loc) 1.06 kB
import { createZoomImageWheel } from '@zoom-image/core'; import { reactive, onUnmounted } from 'vue'; // src/useZoomImageWheel.ts function useZoomImageWheel() { let result; const zoomImageState = reactive({ currentZoom: 1, enable: false, currentPositionX: -1, currentPositionY: -1, currentRotation: 0 }); const createZoomImage = (...arg) => { result?.cleanup(); result = createZoomImageWheel(...arg); const currentState = result.getState(); for (const key in currentState) { zoomImageState[key] = currentState[key]; } result.subscribe(({ updatedProperties }) => { for (const key in updatedProperties) { zoomImageState[key] = updatedProperties[key]; } }); }; onUnmounted(() => { result?.cleanup(); }); const setZoomImageState = (state) => { result?.setState(state); }; return { createZoomImage, zoomImageState, setZoomImageState }; } export { useZoomImageWheel }; //# sourceMappingURL=out.js.map //# sourceMappingURL=chunk-N6ZDP6C6.mjs.map