Jump to content
Search Community

Multiple event handling (maybe Feature request?)

mapps-video test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

19 hours ago, Shaun Gorneau said:

Why wouldn't you package everything into one onUpdate call?

 

I have multiple objects that needs to react on the "update" call.
Eg: a slider, a text, timeline control buttons and so on... they are different entities/objects that receive a TimeLineMax object as a property. 

To wrap it up in one call is not possible; when the timeline is created one cannot tell how many of these objects will be.
I wrote yesterday a wrapper to cover my situation, I will create a codepen with it and post it here.

In regards to the performance concern, there "might be" performance impact, though I personally doubt that in most of the cases that will be an issue. A benchmark would answer this.

Link to comment
Share on other sites

Hi @mapps-video

 

I would probably use an event emitter for something like that. Just listen for what you want. There's only 1 animation here, but 45 different controls are being updated. Yes, I was bored. :lol:

 

See the Pen Lzxwee by osublake (@osublake) on CodePen

 

I'm using EventEmitter3 in that demo, which is one of the fastest around. Should you ever need more speed, I would recommend mini-runner. It's not as flexible, but it's really fast.

 

  • Like 7
Link to comment
Share on other sites

15 hours ago, OSUblake said:

Hi @mapps-video

 

I would probably use an event emitter for something like that. Just listen for what you want. There's only 1 animation here, but 45 different controls are being updated. Yes, I was bored. :lol:

I'm using EventEmitter3 in that demo, which is one of the fastest around. Should you ever need more speed, I would recommend mini-runner. It's not as flexible, but it's really fast.

 


Great example! Thanks for your input. 

Here is what my small wrapper looks like, I've adapted it to your example. 
I am "misusing" backbone view as base class here( inheritance, events - all in one). 

EventEmitter3 looks great! I'll have a look!

See the Pen eGvyBN by klodoma (@klodoma) on CodePen

 

 

  • Like 1
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.
×
×
  • Create New...