Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

Draggable

.addEventListener()

.addEventListener( event:String, listener:Function ) : void

Registers a function that should be called each time a particular type of event occurs, like "drag" or "dragEnd".

Parameters

event: String

The type of event.

listener: Function

The listener function that processes the event.

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


var myDraggable = Draggable.create("#box1", {
bounds:"#container"
})[0];

myDraggable.addEventListener("press", onPress);

function onPress() {
console.log("myDraggable was pressed");
TweenLite.to(this, 0.2, {backgroundColor:"red"}); // animate the backgroundColor of the target of the Draggable that was pressed
}
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.
×