Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.2.6 to 3.3.1 Loss in transitions #388

Closed
zslabs opened this issue Jun 9, 2020 · 7 comments
Closed

3.2.6 to 3.3.1 Loss in transitions #388

zslabs opened this issue Jun 9, 2020 · 7 comments

Comments

@zslabs
Copy link

zslabs commented Jun 9, 2020

👋 Hi all, as part of https://github.com/gremlin/chaoskit (demo site) components like OffCanvas and Modal are using a x and y properties as part of their timeline, respectively. When upgrading to 3.3.1 I noticed this transition is lost. I also tried using xPercent and yPercent without any luck, but I may be misunderstanding the point of those properties.

Reproduction

  1. Pull down https://github.com/gremlin/chaoskit
  2. Inside of package.json upgrade GSAP to 3.3.1
  3. Run yarn develop (this will install all deps and fire up a Storybook instance)
  4. Visit "Components > OffCanvas" and you'll notice there is no slide transition. You can compare this to the current live version of the demo mentioned above.

Please let me know if I can provide anymore context. Thanks!

@ZachSaucier
Copy link
Member

Hey zslabs. It'd really help us in figuring out the issue if we didn't have to pull the entire project and filter through all of the irrelevant parts. Can you try to create a more minimal demo of the issue, perhaps in a CodePen or CodeSandbox?

@zslabs
Copy link
Author

zslabs commented Jun 9, 2020

@ZachSaucier Here's a smaller reproduction https://codepen.io/zslabs/pen/qBbOzVR

If you take off the offCanvas label attached to each to so they move independently, you'll notice there's no issue. If you downgrade the deps in that CodePen to 3.2.6 - things work as they should.

@ZachSaucier
Copy link
Member

Thanks! That's very helpful. That's definitely a bug and we'll get it fixed ASAP.

@ZachSaucier
Copy link
Member

ZachSaucier commented Jun 9, 2020

Curiously if I change the position parameter of the second tween to 0.02 it works. But even 0.019 doesn't work.

@jackdoyle
Copy link
Member

jackdoyle commented Jun 9, 2020

This is one of the reasons we strongly recommend ALWAYS setting your transform-related values via GSAP instead of only in CSS. It's fine to also set the initial ones in CSS to avoid FOUC, but when you set them in GSAP too it ensures that the proper values are cached and there's no ambiguity in rotational values. The browser always reports computed transforms as matrix() or matrix3d() which are px-based, thus it's impossible to discern percentage-based values and also rotations become ambiguous (i.e. rotation of 0, 360, 720, etc. are all identical matrices).

Here's a fork that shows how it resolves things by simply setting the transforms via GSAP:
https://codepen.io/GreenSock/pen/36449da7dfe34f3dfe7db5a4c8b00295?editors=0010

Let me explain what's going on...

You've got an element nested inside another one that's display: none which causes the browser to mis-report the transforms. Try this in your demo:

let el = document.querySelector(".offcanvas-panel");
console.log(window.getComputedStyle(el).transform); // none!

There was a "bug" report (not really a bug) at #375 that we accommodated by changing the kind of check we were doing (instead of checking for a null offsetParent, we checked to see if the element was in the <body>) but in your example that still fails. Elements with position: flex always report a null offsetParent.

I'll roll back that change in order to resolve the edge case here.

You can test out a preview of the next release (with this fix) here:
https://assets.codepen.io/16327/gsap-latest-beta.min.js

Better?

Curiously if I change the position parameter of the second tween to 0.02 it works. But even 0.019 doesn't work.

That's just because when you pad the beginning like that, by the time that second tween renders for the first time, the parent element has had its display set to "block", thus transforms get reported correctly by the browser.

@jackdoyle
Copy link
Member

And by the way, thanks so much for the reduced test case in CodePen @zslabs ! I know that takes you some extra time but it really helps us address it promptly and it ensures we're crystal clear on what the issue is.

@zslabs
Copy link
Author

zslabs commented Jun 9, 2020

@jackdoyle That preview release does indeed resolve that issue! I really appreciate the explanation and the suggestion to move these initial styles to GSAP. I'll definitely do that moving forward. Thanks both for helping with this!

jackdoyle added a commit that referenced this issue Jun 14, 2020
- NEW: ScrollTrigger accommodates pinning the same element multiple times! Just make sure you create the ScrollTriggers in the order they'll be pinned. See https://greensock.com/forums/topic/24429-scrolltrigger-pinning-element-both-top-and-bottom and https://greensock.com/forums/topic/24421-issues-with-multiple-pins-in-a-row/

- IMPROVED: if a pinned ScrollTrigger's animation affects the pin element's transform, it now gets factored in to the final positioning of that pin.

- IMPROVED: if you set up a toggleClass on a ScrollTrigger that has once: true, it will no longer toggle that class back onLeave (it will only happen onEnter because that's more intuitive).

- FIXED: if you kill() a ScrollTrigger when it's in the middle of scrubbing or snapping, it wouldn't kill the in-progress scrubbing or snapping.

- FIXED: if a tween with a stagger is overwritten, the staggered (nested) tweens that haven't started yet may render for one tick when they're scheduled to start

- FIXED: a zero-duration tween (a set()) at the very beginning of a timeline may not render correctly in certain circumstances. See https://greensock.com/forums/topic/24358-scrolltrigger-set/

- FIXED: regression in 3.3.0 could cause initial transform-related values not to be parsed correctly if an ancestor element had dispaly: none. See #388 (this reverts the change made for #375)

- FIXED: the pre-"from" values in a fromTo() may not render when the parent timeline's playhead rewinds past the beginning of that tween.

- FIXED: gsap.utils.wrapYoyo() would return NaN if the start and end values matched. See https://greensock.com/forums/topic/24403-wrapyoyo00x-nan/

- FIXED: if you defined a toggleClass on a ScrollTrigger and that class affected positioning, a refresh() could miscalculate positions because the class wasn't removed for the measurements. See https://greensock.com/forums/topic/24412-scrolltriggerrefresh-help/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants