Registers a function that should be called each time a particular type of event occurs. Inside the listener function this
refers to the target of the Draggable instance that fired the event.
Events
- press
- click
- dragstart
- drag
- dragend
- release
- throwcomplete
- throwupdate
Usage
var myDraggable = Draggable.create("#box1", {
bounds: "#container"
})[0];
myDraggable.addEventListener("press", onPress);
function onPress() {
console.log("myDraggable was pressed");
gsap.to(this, {duration: 0.2, backgroundColor: "red"}); // animate the backgroundColor of the target of the Draggable that was pressed
}