diff --git a/src/controller.js b/src/controller.js index 6f943f0..21193ef 100644 --- a/src/controller.js +++ b/src/controller.js @@ -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); }