Jump to content
Search Community

Pining multiple elements

livechat test
Moderator Tag

Recommended Posts

Hi!

 

I'm trying to create an animation with few stages of pinning and multiple items being pinned. And I need help with that :-)

 

In my example animation can be divided into two stages. In the first stage, red dots are pinned, arranged and join the blue screen. Then, in the second stage, blue screen is pinned and fully shown. What I'm trying to achieve now is for the red dots to be still pinned (after their animation is finished), along the blue screen, up until the screen animation is finished. Later on I'll add alternating animations of dots, screen, and different elements, but I narrowed it down for the sake of making the example simple.

 

I'd much appreciate any help.

See the Pen XWXPKLN by dmgawel (@dmgawel) on CodePen

Link to comment
Share on other sites

Hey livechat and welcome to the GreenSock forums.

 

This is an... unconventional usage of ScrollTrigger. With that being said there are a couple ways that you could approach it. You could create a second ScrollTrigger to pin the dots a second time. The other method which I use in the demo below is to just change the end position of the original ScrollTrigger and accommodate for the added distance by using an empty tween:

See the Pen KKVxgEW?editors=0010 by GreenSock (@GreenSock) on CodePen

 

By the way, there's not very many cases where applying ScrollTriggers to tweens inside of a timeline makes sense. It usually makes more sense to apply the ScrollTrigger to individual tweens (not in timelines) or to a timeline itself.

  • Like 1
Link to comment
Share on other sites

Hey @ZachSaucier!

 

Thank you for your reply. That is a very neat trick!

 

To better understand it I tried an approach with the first method you suggested (second ScrollTrigger for dots). However, I find it problematic to set start and end triggers. It looks like second ScrollTrigger is taking into account padding added by the first ScrollTrigger to screen element. Is it expected behaviour? How can I overcome it to use the original element markings?

 

See the Pen vYLzyRL by dmgawel (@dmgawel) on CodePen

Link to comment
Share on other sites

@livechat it's an interesting edge case that exposed a bug related to pinning the same thing multiple times (some of which use a different trigger). It should be resolved in the next release, 3.4.1, which you can preview at https://assets.codepen.io/16327/ScrollTrigger.min.js (might need to clear your cache)

 

Does that fix things for you?  

  • Like 3
Link to comment
Share on other sites

@GreenSock thanks a lot! I'm happy to hear that a). my intuition was right b). you were able to release a fix so fast!

 

Version 3.4.1 indeed fixes things for me. I was able to pin an element twice and positioning worked as expected. There is only one small issue I experienced: markers for the first ScrollTrigger are missing (animation is triggered, it's only the markers that are not working).

 

Example: 

See the Pen gOPdKVW by dmgawel (@dmgawel) on CodePen

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...