Repository navigation
fix(studio): a drag in a composition without GSAP keeps the element's CSS translate - #4750
Closed
miguel-heygen wants to merge 4 commits into
Closed
miguel-heygen wants to merge 4 commits into
miguel-heygen wants to merge 4 commits into
Conversation
miguel-heygen
force-pushed
the
fix/studio-no-gsap-stylesheet-translate-drag
branch
from
September 30, 2026 04:37
c67c0d2 to
a5228f6
Compare
miguel-heygen
marked this pull request as ready for review
September 30, 2026 05:17
miguel-heygen
marked this pull request as draft
September 30, 2026 05:21
somanshreddy
approved these changes
Sep 30, 2026
4 of 5 tasks
Collaborator
Author
|
Fixed on main by #4799: a move in a composition without GSAP now saves the element's own CSS translate and adds no GSAP, so a stylesheet translate is kept. The edit-accuracy gate's move cases on this fixture (a stylesheet translate, no GSAP) all pass on main. Closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
In a composition that does not load GSAP, dragging an element that a stylesheet places with
translate(or atransformtranslation) no longer jumps when you let go. A 30px drag now moves it 30px, while dragging, after the drop and after a reload.Why
Before this change, the element followed the pointer during the drag and then jumped by its stylesheet offset on release. For example, with
#title { translate: 0 -200px }, a 30px drag down landed it about 200 composition pixels lower. The wrong position was saved to the file, so a reload showed it too.The first move of an element in such a composition is saved as
gsap.set("#title", { x, y }), and the server adds GSAP to the file for that write. That part is intended: a static element's position lives in one GSAP set. When GSAP loads, it folds the element's CSStranslateand its transform's translation into x/y, so the saved x/y has to include them. The drag took its starting x/y fromgsap.getProperty. With no GSAP on the page yet, it used 0, so the saved value dropped the stylesheet offset.To reproduce on main: take a composition with no GSAP script and
#title { translate: 0 -200px }, then drag#title30px down. It jumps on drop, and the file getsy: 87where it should gety: -113.Related work
Refs #4734. That PR changes the drag teardown in the same file; this change is only in the drag setup, and the two do not overlap.
How
createManualOffsetDragMemberreads its starting x/y fromgsap.getPropertywhen GSAP is on the page. When it is not, it now computes the value GSAP's CSS parser will report for the element once the commit loads it:translate(px, or % of the element's box), plusrotate,scaleand the computedtransformcombined in that order, as GSAP builds them, minusxPercent/yPercentrather than x/y.When the browser cannot parse that combination (for example
rotate: x 30deg), GSAP keeps only the plain transform, and so does this.Nothing changes when GSAP is loaded.
Test plan
translate, a stylesheettransform, and a-50%centering. The first two fail on main (expected { x: 40, y: 30 } to deeply equal { x: 40, y: -170 }). The third fails if the centering rule is removed.rotateorscaleturns or scales the transform's translation, a combination the browser cannot parse falls back to the plain transform without throwing, and with GSAP on the page the base still comes from GSAP. Checked against real GSAP 3.12.5 in Chrome on 27 element styles: all match.translateelement, a no-GSAPtransform: translate(-50%, -50%)element, and a GSAP composition with a stylesheettranslateto check for regressions.Walk results. Screen px in a 1600x900 Studio, from where the element started; the pointer moved +40,+30 and then -60,+20.
translate: 0 -200pxy: 87translate: 0 -200pxy: -113transform: translate(-50%, -50%)x: 116transform: translate(-50%, -50%)x: 42translate: 0 -200pxy: -113The saved values in the GSAP composition are the same on main and on this PR. The live -39 there, and the -19 after the second no-GSAP move on this PR, is the stylesheet translate showing again under GSAP's transform after a drop. That is #4734's bug. #4734 is now on main, and on main plus this PR every cell in both compositions is exact: 40, 30 / -20, 50.
Before
No GSAP,
translate: 0 -200px. Held at the end of the drag, the title is where the pointer put it:After the drop it jumps down, and that is what gets saved:
No GSAP,
transform: translate(-50%, -50%). After the drop it jumps right:After
No GSAP,
translate: 0 -200px. After the drop the title stays where the pointer left it:No GSAP,
transform: translate(-50%, -50%). It stays put too: