persona-community-5/.pnpm-store/v3/files/9f/0a1b4406ad8cb56bb521f1383a4e551483c23f54e971335fa6d59ca1367b04576f9de0f0dee6780a6aeed8be593bb2cc6efe1ef5b77d0176c520a83271b9e8
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

34 lines
1.5 KiB
Plaintext

var ds = function (ab) { return (ab[0] <= 0 && ab[1] >= 0) || (ab[0] >= 0 && ab[1] <= 0); };
var sign = function (x) { return (x < 0 ? -1 : 1); };
export var pinchOrZoom = function (event, cache) {
if (!event.changedTouches) {
return false;
}
if (event.touches.length === 2) {
var oldPoints = [cache[event.touches[0].identifier], cache[event.touches[1].identifier]];
var newPoints = [event.touches[0], event.touches[1]];
if (oldPoints[0] && oldPoints[1]) {
// Calculate the difference between the start and move coordinates
var diffx = [oldPoints[0].clientX - newPoints[0].clientX, oldPoints[1].clientX - newPoints[1].clientX];
var diffy = [oldPoints[0].clientY - newPoints[0].clientY, oldPoints[1].clientY - newPoints[1].clientY];
console.log(diffx, diffy);
if (ds(diffx) || ds(diffy)) {
return {
action: 'zoom',
};
}
var mx = Math.max(Math.abs(diffx[0]), Math.abs(diffx[1]));
var my = Math.max(Math.abs(diffy[0]), Math.abs(diffy[1]));
return {
action: 'pinch',
coords: [mx * sign(diffx[0]), my * sign(diffx[1])],
};
}
}
Array.from(event.changedTouches).forEach(function (touch) { return (cache[touch.identifier] = touch); });
return {
action: 'move',
coords: [event.changedTouches[0].clientX, event.changedTouches[0].clientY],
};
};