Jump to content
GreenSock

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

Draggable.create()

Draggable.create( target:Object, vars:Object ) : Array

[static] Provides a more flexible way to create Draggable instances than the constructor (new Draggable(...)) because the Draggable.create() method can accommodate multiple elements (either as an array of elements or a jQuery object with many results) or even selector text like ".yourClass" which gets fed to whatever TweenLite.selector is (defaults to jQuery if it's loaded).

Parameters

target: Object

the element that should be draggable; this can be a regular DOM element or a jQuery object or an array of elements. For example, document.getElementById("yourID") or $("#yourID") or "#yourID" or [element1, element2, element3]

vars: Object

an object containing optional configuration data like {type:"x,y", throwProps:true, edgeResistance:0.8, onDrag:yourFunction}

Show More

Returns : Array

an array of Draggable instances (one for each element).

Details

Provides a more flexible way to create Draggable instances than the constructor (new Draggable(...)) because the Draggable.create() method can accommodate multiple elements (either as an array of elements or a jQuery object with many results) or even selector text like ".yourClass"which gets fed to whatever TweenLite.selector is (defaults to jQuery if it's loaded). Draggable.create() always returns an array of Draggableinstances, one for each element. Remember an individual Draggable instance can only be associated with a single element - that's whyDraggable.create() creates one for each element and spits back an array.

Any of the following are valid:

//a regular DOM element Draggable.create(document.getElementById("yourID"), {type:"x,y"}); //or a jQuery object Draggable.create( $(".yourClass"), {type:"x,y"}); //or selector text Draggable.create("#yourID", {type:"x,y"}); //or an array of elements Draggable.create([element1, element2, element3], {type:"x,y"});

The second parameter is the vars object that contains any optional configuration data. Any of the following properties can be defined:

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.
×