mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-08 02:36:10 +00:00
fix(studio): pin the drop point on a first resize
The finalize step measures where the committed scale put the box and shifts the position hold by the difference. Whether the commit had actually rendered when it measured was luck: on a first resize the timeline had not re-seeked, so it measured the element at its natural size still sitting on the drop point, saw no residual, and skipped the correction. The scale then landed, GSAP rendered it about the element's centre, and the element jumped by the whole drag distance. Elements resized before got a correction only because their previous scale made the residual non-zero by accident. The committed scale is now applied to the live element before measuring, so the measurement means what its comment says either way, and a skipped correction is logged rather than silent. Confirmed against a real session: a first resize of a 630px chip now reports residual -109.93 and lands on the drop point, where it previously logged no scale-finalize at all.
This commit is contained in:
@@ -24,6 +24,20 @@ export function setElementGsapPosition(element: HTMLElement, x: number, y: numbe
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the element's GSAP scale. Returns false when no runtime is reachable.
|
||||
*
|
||||
* Used to make the element show a scale that has been committed but not yet
|
||||
* re-rendered by the timeline, so measuring it afterwards reports where the
|
||||
* commit actually puts it rather than where it happened to be mid-flight.
|
||||
*/
|
||||
export function setElementGsapScale(element: HTMLElement, x: number, y: number): boolean {
|
||||
const gsap = gsapOf(element);
|
||||
if (!gsap?.set) return false;
|
||||
gsap.set(element, { scaleX: x, scaleY: y });
|
||||
return true;
|
||||
}
|
||||
|
||||
/** The element's GSAP numeric property, or null when unreadable. */
|
||||
export function readElementGsapNumber(element: HTMLElement, prop: string): number | null {
|
||||
const value = Number(gsapOf(element)?.getProperty?.(element, prop));
|
||||
|
||||
Reference in New Issue
Block a user