Skip to content

Commit

Permalink
new playground
Browse files Browse the repository at this point in the history
  • Loading branch information
ElyaConrad committed Apr 19, 2024
1 parent 4ed56b3 commit b3b8875
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
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.27",
"version": "0.0.28",
"type": "module",
"files": [
"package.json",
Expand Down
3 changes: 3 additions & 0 deletions zoompinch-vue/src/components/Zoompinch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import { useZoom } from '../controllers/zoom';
import { ref, defineProps, toRef, computed, onMounted, watch, toRefs, onUnmounted, reactive } from 'vue';
import { radiansToDegrees } from '../controllers/helpers';
import { detectTrackpad } from '../controllers/wheel';
export type Transform = {
x: number;
Expand Down Expand Up @@ -180,6 +181,8 @@ onMounted(() => {
const wheelProxy = (event: WheelEvent) => {
if (props.wheel) {
const isTrackpad = detectTrackpad(event);
console.log('isTrackpad', isTrackpad);
handleWheel(event);
}
};
Expand Down
12 changes: 12 additions & 0 deletions zoompinch-vue/src/controllers/wheel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import { Ref } from 'vue';
import { clamp } from './helpers';

export function detectTrackpad(event: WheelEvent) {
var isTrackpad = false;
if ((event as any).wheelDeltaY) {
if ((event as any).wheelDeltaY === event.deltaY * -3) {
isTrackpad = true;
}
} else if (event.deltaMode === 0) {
isTrackpad = true;
}
return isTrackpad;
}

export function useWheel({
scale,
translate,
Expand Down

0 comments on commit b3b8875

Please sign in to comment.