Jump to content
GreenSock

DraggablePlugin

.addEventListener()

.addEventListener( ) ;

Details

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

  1. var myDraggable = Draggable.create("#box1", {
  2. bounds: "#container"
  3. })[0];
  4. myDraggable.addEventListener("press", onPress);
  5. function onPress() {
  6. console.log("myDraggable was pressed");
  7. gsap.to(this, {duration: 0.2, backgroundColor: "red"}); // animate the backgroundColor of the target of the Draggable that was pressed
  8. }
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.
×