Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Lauritz Offe

Variables in ScrollTrigger

Recommended Posts

Hi,

for my Projekt in TYPO3 I need to use variables in my Animation / ScrollTrigger .

 

Somethin like that...
 

var myid1 = somefunction1

var myid2 = somefunction2

 

ScrollTrigger.create({  

trigger: '#step-2',  

start: 'top center',  

onEnter: myid1,  

onLeaveBack: myid2,  

markers: false,  

id: 'second-box' });

 

Is this even possible?
I don´t need to change the variables  on the fly.

 

Thanks in advance

Lauritz Offe

Link to comment
Share on other sites

Hi @Lauritz Offe

Yep, that's possible - You can even do function based values as an option - Here you go.

See the Pen VwzNgNg?editors=1111 by GreenSock (@GreenSock) on CodePen



In future if you could pop together a minimal demo first to test out your code that would be great!

Thanks, and good luck with your project!

Link to comment
Share on other sites

The Solution was that is is possible to use js in an option field:
onEnter: () => {

//here you can use js

return someValue;

},

Link to comment
Share on other sites

I'm not sure if you meant that as a question, @Lauritz Offe. If so, no, it wouldn't make sense to use function-based values to function-based values :) In other words, how would ScrollTrigger know that the function you're passing it is the actual onEnter that should be called or just a function that's to be called in order to get the real onEnter function? 

Link to comment
Share on other sites

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.
×