sv en en en en en en en en en en en en en en en fa en en fr hbs_lat en en en es en en en de en en fr en en ca en en en en en en ca en en en pl pl sv en en en it uk ky en en ru ru az de de fa de mn uk az en en en it ar tg ru en es tr it en mr ru el ceb fa tr ko en en ar tr hbs_lat de en en fi fa ru de myv fi ru da fr eu ja en az en en kn my en en en ca ru en en hi en en en en en en en de en en en en en en en en ca en en en fr en en en en en it en en en en en es en en en en en en en en en fr cv es tr es en en en en ms en en en en en en fr en hbs_lat en en en en en en en fr cv es tr es en en en en de en en en ca en en en en en
Gets or sets an event callback like onComplete, onUpdate, onStart, onReverseComplete, or onRepeat along with any parameters that should be passed to that callback.
The type of event callback, like onComplete, onUpdate, onStart, or onRepeat. This is case-sensitive.
(default = null) — The function that should be called when the event occurs.
(default = null) — An array of parameters to pass the callback.
Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining.
Gets or sets an event callback like "onComplete", "onUpdate", "onStart", "onReverseComplete" or "onRepeat" along with any parameters that should be passed to that callback. This is the same as defining the values directly in the constructor’s vars parameter initially, so the following two lines are functionally equivalent:
//the following two lines produce IDENTICAL results:
var myAnimation = gsap.to(obj, {duration: 1, x: 100, onComplete: myFunction, onCompleteParams: ["param1","param2"]});
The benefit of using eventCallback() is that it allows you to set callbacks even after the animation instance has been created and it also allows you to inspect the callback references or even delete them on-the-fly (use null to delete the event callback).
IMPORTANT: Animation instances can only have one callback associated with each event type (one onComplete, one onUpdate, one onStart, etc.). So setting a new value will overwrite the old one. All of the values populate the vars object which was originally passed into the constructor (think of that like a storage place for configuration data).
This method serves as both a getter and setter. Omitting all but the first parameter returns the current value (getter), whereas defining more than the first parameter sets the value (setter) and returns the instance itself for easier chaining, like myAnimation.eventCallback("onComplete", completeHandler).eventCallback("onUpdate", updateHandler, ["param1","param2"]).play(1);
var currentOnComplete = myAnimation.eventCallback("onComplete"); //gets current onComplete
myAnimation.eventCallback("onComplete", myFunction); //sets the onComplete
Note: - Due to the way JavaScript doesn’t maintain scope (what this refers to, or the context) in function calls, it can be useful to define the scope specifically in the 4th parameter.
Copyright 2017, GreenSock. All rights reserved. This work is subject to theterms of useor for Club GreenSock members, the software agreement that was issued with the membership.
“I am more and more amazed every day, and very glad that I decided to get a business license.”
“GreenSock is the best thing that happened to SVG animations since SVG animations.”
“Honestly think without TweenMax, I'd of changed careers by now; it's that good.”
“...obviously GSAP is incredible”
“The best thing about GSAP is that it just works, and it works well. On every single browser I’ve tested.”
“Aside from GreenSock’s laser-focused attention to detail, GSAP is fast, reliable, flexible, exceptional value (read: free in most cases) and, very importantly, supported.”
“No other animation library is as intuitive, rigorous, conceptually simple and well curated as GreenSock’s”
“Go and browse through FWA or Awwwards, then view source of anything you see that has cool animation and you will be surprised how widely GSAP is used.”
“Really quite impressed with @GreenSock JS - even the small things.”
Sign Up For Our Newsletter
Get the latest updates on GreenSock products, exclusive offers, and more right in your inbox.
Your information will always be kept confidential.
Thanks for signing up!
Now you'll begin receiving the latest GreenSock updates, exclusive offers, and more right in your inbox. Welcome aboard.