Skip to content

Commit

Permalink
Fix zoom rotate on wheel 💞 (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
willnguyen1312 authored Feb 17, 2024
1 parent eda88f5 commit 4e590e8
Show file tree
Hide file tree
Showing 20 changed files with 1,354 additions and 1,523 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-otters-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zoom-image/core": patch
---

Fix zoom on wheel with rotation 💞
20 changes: 10 additions & 10 deletions examples/with-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
"dev": "ng serve"
},
"dependencies": {
"@angular/common": "^17.1.3",
"@angular/core": "^17.1.3",
"@angular/platform-browser": "^17.1.3",
"@angular/platform-browser-dynamic": "^17.1.3",
"@zoom-image/core": "latest",
"@angular/common": "^17.2.1",
"@angular/core": "^17.2.1",
"@angular/platform-browser": "^17.2.1",
"@angular/platform-browser-dynamic": "^17.2.1",
"@zoom-image/angular": "latest",
"@zoom-image/core": "latest",
"rxjs": "~7.8.1",
"tslib": "^2.6.2",
"zone.js": "~0.14.3"
"zone.js": "~0.14.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.1.3",
"@angular/cli": "~17.1.3",
"@angular/compiler": "^17.1.3",
"@angular/compiler-cli": "^17.1.3",
"@angular-devkit/build-angular": "^17.2.0",
"@angular/cli": "~17.2.0",
"@angular/compiler": "^17.2.1",
"@angular/compiler-cli": "^17.2.1",
"typescript": "~5.3.3"
}
}
4 changes: 2 additions & 2 deletions examples/with-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dev": "next dev"
},
"dependencies": {
"@types/node": "^20.11.17",
"@types/react": "^18.2.55",
"@types/node": "^20.11.19",
"@types/react": "^18.2.56",
"@types/react-dom": "^18.2.19",
"@unocss/postcss": "^0.58.5",
"@unocss/reset": "^0.58.5",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"@zoom-image/core": "latest",
"@zoom-image/preact": "latest",
"preact": "^10.19.4"
"preact": "^10.19.5"
},
"devDependencies": {
"@preact/preset-vite": "^2.8.1",
Expand Down
6 changes: 3 additions & 3 deletions examples/with-qwik/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"dev": "vite --mode ssr"
},
"devDependencies": {
"@builder.io/qwik": "1.4.4",
"@builder.io/qwik-city": "^1.4.4",
"@types/node": "^20.11.17",
"@builder.io/qwik": "1.4.5",
"@builder.io/qwik-city": "^1.4.5",
"@types/node": "^20.11.19",
"@unocss/reset": "^0.58.5",
"typescript": "5.3.3",
"undici": "^6.6.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.55",
"@types/react": "^18.2.56",
"@types/react-dom": "^18.2.19",
"@unocss/reset": "^0.58.5",
"@vitejs/plugin-react": "^4.2.1",
Expand Down
4 changes: 2 additions & 2 deletions examples/with-remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"@unocss/reset": "^0.58.5",
"@zoom-image/core": "latest",
"@zoom-image/react": "latest",
"isbot": "^4.4.0",
"isbot": "^5.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^2.6.0",
"@remix-run/eslint-config": "^2.6.0",
"@types/react": "^18.2.55",
"@types/react": "^18.2.56",
"@types/react-dom": "^18.2.19",
"eslint": "^8.56.0",
"tailwindcss": "^3.4.1",
Expand Down
4 changes: 2 additions & 2 deletions examples/with-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"typescript": "^5.3.3",
"unocss": "^0.58.5",
"vite": "^4.5.2",
"vite-plugin-solid": "^2.9.1"
"vite-plugin-solid": "^2.10.1"
},
"dependencies": {
"@zoom-image/core": "latest",
"@zoom-image/solid": "latest",
"solid-js": "^1.8.14"
"solid-js": "^1.8.15"
}
}
2 changes: 1 addition & 1 deletion examples/with-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@tsconfig/svelte": "^5.0.2",
"@unocss/reset": "^0.58.5",
"svelte": "^4.2.10",
"svelte": "^4.2.11",
"svelte-check": "^3.6.4",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
Expand Down
4 changes: 2 additions & 2 deletions examples/with-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"dependencies": {
"@zoom-image/core": "latest",
"@zoom-image/vue": "latest",
"vue": "^3.4.18"
"vue": "^3.4.19"
},
"devDependencies": {
"@types/node": "^20.11.17",
"@types/node": "^20.11.19",
"@unocss/reset": "^0.58.5",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/tsconfig": "^0.5.1",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
"esno": "^4.0.0",
"export-size": "^0.7.0",
"prettier": "^3.2.5",
"prettier-plugin-svelte": "^3.1.2",
"prettier-plugin-svelte": "^3.2.1",
"prettier-plugin-tailwindcss": "^0.5.11",
"turbo": "^1.12.3",
"turbo": "^1.12.4",
"unocss": "^0.58.5"
}
}
12 changes: 6 additions & 6 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"tslib": "^2.6.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.1.3",
"@angular/cli": "~17.1.3",
"@angular/compiler": "^17.1.3",
"@angular/compiler-cli": "^17.1.3",
"@angular/core": "^17.1.3",
"ng-packagr": "^17.1.2",
"@angular-devkit/build-angular": "^17.2.0",
"@angular/cli": "~17.2.0",
"@angular/compiler": "^17.2.1",
"@angular/compiler-cli": "^17.2.1",
"@angular/core": "^17.2.1",
"ng-packagr": "^17.2.0",
"typescript": "~5.3.3"
}
}
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
"@testing-library/dom": "^9.3.4",
"@testing-library/user-event": "^14.5.2",
"@testing-library/vue": "^8.0.2",
"@types/node": "^20.11.17",
"@types/node": "^20.11.19",
"@vitejs/plugin-vue": "^5.0.4",
"@vitest/coverage-v8": "^1.2.2",
"@vitest/coverage-v8": "^1.3.0",
"@vue/test-utils": "^2.4.4",
"eslint-config-custom": "workspace:*",
"fast-check": "^3.15.1",
Expand All @@ -65,8 +65,8 @@
"tsup": "8.0.2",
"typescript": "^5.3.3",
"vite": "^4.5.2",
"vitest": "^1.2.2",
"vitest": "^1.3.0",
"vitest-dom": "^0.1.1",
"vue": "^3.4.18"
"vue": "^3.4.19"
}
}
6 changes: 4 additions & 2 deletions packages/core/src/createZoomImageWheel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ export function createZoomImageWheel(container: HTMLElement, options: ZoomImageW
}

const calculatePositionX = (newPositionX: number, currentZoom: number) => {
const width = checkDimensionSwitched() ? container.clientHeight : container.clientWidth
if (newPositionX > 0) return 0

const width = container.clientWidth
if (newPositionX + width * currentZoom < width) return -width * (currentZoom - 1)
return newPositionX
}

const calculatePositionY = (newPositionY: number, currentZoom: number) => {
const height = checkDimensionSwitched() ? container.clientWidth : container.clientHeight
if (newPositionY > 0) return 0

const height = container.clientHeight
if (newPositionY + height * currentZoom < height) return -height * (currentZoom - 1)
return newPositionY
}
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"eslint-plugin-vue": "^9.21.1",
"vite": "^4.5.2",
"vitepress": "1.0.0-rc.42",
"vue": "^3.4.18"
"vue": "^3.4.19"
}
}
6 changes: 3 additions & 3 deletions packages/eslint-config-custom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"private": true,
"main": "index.js",
"dependencies": {
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint": "8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^1.12.3",
"eslint-config-turbo": "^1.12.4",
"tsconfig": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/qwik/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"qwik": "qwik"
},
"devDependencies": {
"@builder.io/qwik": "1.4.4",
"@builder.io/qwik": "1.4.5",
"eslint-config-custom": "workspace:*",
"npm-run-all": "^4.1.5",
"prettier": "3.2.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@types/react": "^18.2.55",
"@types/react": "^18.2.56",
"eslint-config-custom": "workspace:*",
"tsconfig": "workspace:*",
"tsup": "8.0.2",
Expand Down
Loading

0 comments on commit 4e590e8

Please sign in to comment.