Skip to content

Commit

Permalink
fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ElyaConrad committed Apr 13, 2024
1 parent 4e31702 commit c99923c
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 22 deletions.
14 changes: 7 additions & 7 deletions playground/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@vicons/ionicons5": "^0.12.0",
"naive-ui": "^2.38.1",
"vue": "^3.2.37",
"zoompinch": "^0.0.5"
"zoompinch": "^0.0.7"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.1.0",
Expand Down
26 changes: 19 additions & 7 deletions playground/src/components/Playground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
:mouse="mouseEvents"
:touch="touchEvents"
:wheel="wheelEvents"
:gesture="false"
:gesture="gestureEvents"
>
<template #canvas>
<img
Expand All @@ -141,9 +141,9 @@
/>
</template>
<template #matrix="{ compose }">
<svg xmlns="http://www.w3.org/2000/svg" @click="handleClickOnLayer">
<!-- <svg xmlns="http://www.w3.org/2000/svg" @click="handleClickOnLayer">
<circle :cx="compose(1536 / 2, 2048 / 2)[0]" :cy="compose(1536 / 2, 2048 / 2)[1]" r="5" style="fill: #f00" />
</svg>
</svg> -->
</template>
</zoompinch>
</div>
Expand All @@ -156,6 +156,8 @@ import 'zoompinch/style.css';
import { reactive, ref, watch, watchEffect } from 'vue';
import { NInputNumber, NSwitch, NButton } from 'naive-ui';
// Flicker bug reproducable: 100,0,0.1,180
const rotation = ref(true);
const bounds = ref(false);
watch(bounds, (newValue) => {
Expand All @@ -173,7 +175,8 @@ const zoompinchRef = ref<InstanceType<typeof Zoompinch>>();
const offset = reactive({ top: 10, right: 10, bottom: 10, left: 10 });
(window as any).offset = offset;
const transform = ref({ x: 0, y: 0, scale: 1, rotate: 0 });
//const transform = ref({ x: 0, y: 0, scale: 1, rotate: 0 });
const transform = ref({ x: 100, y: 0, scale: 0.1, rotate: 180 }); // Flicker bug reproducable: 100,0,0.1,180
(window as any).transform = transform;
const updateTransform = (newTransform: Partial<typeof transform.value>) => {
transform.value = { ...transform.value, ...newTransform };
Expand Down Expand Up @@ -238,9 +241,9 @@ function handleClickOnLayer(event: MouseEvent) {
gap: 10px;
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
// @media screen and (max-width: 700px) {
// grid-template-columns: repeat(auto-fill, minmax(1fr, ));
// }
@media screen and (max-width: 700px) {
grid-template-columns: repeat(4, 1fr);
}
&.small {
grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
Expand All @@ -250,6 +253,15 @@ function handleClickOnLayer(event: MouseEvent) {
font-size: 0.9em;
opacity: 0.7;
}
.n-input-number {
::v-deep(.n-input__suffix) {
.n-button {
@media screen and (max-width: 700px) {
display: none;
}
}
}
}
}
}
.zoompinch {
Expand Down
3 changes: 2 additions & 1 deletion zoompinch-lit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"build": "tsc && vite build"
},
"dependencies": {
"lit": "^2.3.1"
"lit": "^2.3.1",
"zoompinch": "^0.0.12"
},
"devDependencies": {
"rollup-plugin-scss-lit": "^1.1.6",
Expand Down
2 changes: 1 addition & 1 deletion zoompinch-lit/src/components/PanCake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export class PanCake extends LitElement {
const innerCanvasRel = this.touchStarts[0].canvasRel;

// Project the scale
const [scaleDeltaX, scaleDeltaY] = this.calcProjectionTranslate(futureScale, innerWrapperRelPos, innerCanvasRel);
const [scaleDeltaX, scaleDeltaY] = this.calcProjectionTranslate(futureScale, innerWrapperRelPos, innerCanvasRel, 0);

let rotationDeltaX = 0;
let rotationDeltaY = 0;
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.12",
"version": "0.0.13",
"type": "module",
"files": [
"package.json",
Expand Down
12 changes: 9 additions & 3 deletions zoompinch-vue/src/components/Zoompinch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,25 @@ const mouseupProxy = (event: MouseEvent) => {
handleMouseup(event);
}
};
function isTouchDevice() {
return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
}
const gestureEnabled = computed(() => {
return !isTouchDevice() && props.gesture;
});
const gesturestartProxy = (event: any) => {
if (props.gesture) {
if (gestureEnabled.value) {
handleGesturestart(event);
}
};
const gesturechangeProxy = (event: any) => {
if (props.gesture) {
if (gestureEnabled.value) {
handleGesturechange(event);
}
};
const gestureendProxy = (event: any) => {
if (props.gesture) {
if (gestureEnabled.value) {
handleGestureend(event);
}
};
Expand Down
2 changes: 1 addition & 1 deletion zoompinch-vue/src/controllers/touch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function useTouch({
}
};
const handleTouchend = (event: TouchEvent) => {
event.preventDefault();
//event.preventDefault();

if (event.touches.length === 0) {
touchStarts = null;
Expand Down

0 comments on commit c99923c

Please sign in to comment.