Skip to content

Commit

Permalink
pointer leave event in blocking layer (#12)
Browse files Browse the repository at this point in the history
* pointer leave event in blocking layer

* only change active status on pointer leave
  • Loading branch information
YehonatanSaharof authored Jan 23, 2025
1 parent 7dcc75d commit 99e5e0d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,18 @@ export function getController (config) {
for (let scene of config.scenes) {
if (!scene.disabled) {
// get scene's progress
const x = +clamp(0, 1, scene.transform?.x(progress.x) || progress.x / config.rect.width).toPrecision(4);
const y = +clamp(0, 1, scene.transform?.y(progress.y) || progress.y / config.rect.height).toPrecision(4);
const normalizedX = scene.transform?.x(progress.x) || progress.x / config.rect.width;
const normalizedY = scene.transform?.y(progress.y) || progress.y / config.rect.height;

const x = +clamp(0, 1, normalizedX).toPrecision(4);
const y = +clamp(0, 1, normalizedY).toPrecision(4);

const velocity = {x: progress.vx, y: progress.vy};

if (config.allowActiveEvent && (normalizedX > 1 || normalizedY > 1 || normalizedX < 0 || normalizedY < 0)) {
progress.active = false;
}

// run effect
scene.effect(scene, {x, y}, velocity, progress.active);
}
Expand Down

0 comments on commit 99e5e0d

Please sign in to comment.