Skip to content

Commit

Permalink
new wrapper bounds exposed
Browse files Browse the repository at this point in the history
  • Loading branch information
ElyaConrad committed Apr 14, 2024
1 parent 5bdaa28 commit b1dfb4d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions playground/src/components/Playground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ function fit(animate: boolean) {
onMounted(() => {
setTimeout(() => fit(true));
});
watch(
() => zoompinchRef.value?.wrapperBounds,
() => {
requestAnimationFrame(() => {
zoompinchRef.value?.applyTransform(1, [0.5, 0.5], [0.5, 0.5], false);
});
}
);
</script>

<style scoped lang="scss">
Expand Down
2 changes: 1 addition & 1 deletion zoompinch-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zoompinch",
"private": false,
"version": "0.0.24",
"version": "0.0.25",
"type": "module",
"files": [
"package.json",
Expand Down
12 changes: 12 additions & 0 deletions zoompinch-vue/src/components/Zoompinch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ const {
normalizeMatrixCoordinates,
transitionEnabled,
transitionDuration,
wrapperX,
wrapperY,
wrapperWidth,
wrapperHeight,
} = useZoom({
wrapperElementRef: zoompinchRef,
canvasNaturalWidth,
Expand Down Expand Up @@ -255,6 +259,14 @@ defineExpose({
applyTransform,
calcProjectionTranslate,
rotateCanvas,
wrapperBounds: computed(() => {
return {
x: wrapperX.value,
y: wrapperY.value,
width: wrapperWidth.value,
height: wrapperHeight.value,
};
}),
});
</script>

Expand Down
4 changes: 4 additions & 0 deletions zoompinch-vue/src/controllers/zoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,5 +375,9 @@ export function useZoom({
wrapperBounds,
transitionEnabled,
transitionDuration,
wrapperX,
wrapperY,
wrapperWidth,
wrapperHeight,
};
}

0 comments on commit b1dfb4d

Please sign in to comment.