(elapsed: number, duration: number, from: Element, to: Element)
| 14 | // This method calculates the animated new position of the |
| 15 | // stage (called for each frame by requestAnimationFrame) |
| 16 | export function transitionStage(elapsed: number, duration: number, from: Element, to: Element) { |
| 17 | let activeStagePosition = getState("__activeStagePosition"); |
| 18 | |
| 19 | const fromDefinition = activeStagePosition ? activeStagePosition : from.getBoundingClientRect(); |
| 20 | const toDefinition = to.getBoundingClientRect(); |
| 21 | |
| 22 | const x = easeInOutQuad(elapsed, fromDefinition.x, toDefinition.x - fromDefinition.x, duration); |
| 23 | const y = easeInOutQuad(elapsed, fromDefinition.y, toDefinition.y - fromDefinition.y, duration); |
| 24 | const width = easeInOutQuad(elapsed, fromDefinition.width, toDefinition.width - fromDefinition.width, duration); |
| 25 | const height = easeInOutQuad(elapsed, fromDefinition.height, toDefinition.height - fromDefinition.height, duration); |
| 26 | |
| 27 | activeStagePosition = { |
| 28 | x, |
| 29 | y, |
| 30 | width, |
| 31 | height, |
| 32 | }; |
| 33 | |
| 34 | renderOverlay(activeStagePosition); |
| 35 | setState("__activeStagePosition", activeStagePosition); |
| 36 | } |
| 37 | |
| 38 | export function trackActiveElement(element: Element) { |
| 39 | if (!element) { |
no test coverage detected
searching dependent graphs…