Jump to content
Search Community

Selectively suppressEvents when calling seek()

benjaminben test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I have a timeline wherein analytics events and accessibility-related events are both sequenced through various add() calls. When a user seeks around the timeline, I want to skip the analytics events but keep the accessibility ones. Is it possible for events/callbacks to opt into being suppressed on a case-by-case basis?

See the Pen RwVEVPo by benjaminben (@benjaminben) on CodePen

Link to comment
Share on other sites

  • Solution

No, that's something you should handle externally - here's one technique:

See the Pen 4b96715cfadd17aa3c815c1c7f0407c4 by GreenSock (@GreenSock) on CodePen

 

Create a function for adding any of your analytics function calls: 

function addAnalytics(tl, func, position) {
  return tl.add(() => tl.suppressAnalytics || func(), position);
}

Notice it just checks if the timeline has a truthy suppressAnalytics property. If so, it skips the function call. 

 

Then, instead of calling the normal tl.seek(), you'd use a function like this which toggles that property for you and jumps to a particular time: 

function seekWithoutAnalytics(tl, time) {
  tl.suppressAnalytics = true;
  tl.time(time);
  tl.suppressAnalytics = false;
  return tl;
}

Does that help? 

  • Like 4
  • Thanks 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...