draggabilly.pkgd.js 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538
  1. /*!
  2. * Draggabilly PACKAGED v2.1.1
  3. * Make that shiz draggable
  4. * http://draggabilly.desandro.com
  5. * MIT license
  6. */
  7. /**
  8. * Bridget makes jQuery widgets
  9. * v2.0.0
  10. * MIT license
  11. */
  12. /* jshint browser: true, strict: true, undef: true, unused: true */
  13. ( function( window, factory ) {
  14. /* globals define: false, module: false, require: false */
  15. if ( typeof define == 'function' && define.amd ) {
  16. // AMD
  17. define( 'jquery-bridget/jquery-bridget',[ 'jquery' ], function( jQuery ) {
  18. factory( window, jQuery );
  19. });
  20. } else if ( typeof module == 'object' && module.exports ) {
  21. // CommonJS
  22. module.exports = factory(
  23. window,
  24. require('jquery')
  25. );
  26. } else {
  27. // browser global
  28. window.jQueryBridget = factory(
  29. window,
  30. window.jQuery
  31. );
  32. }
  33. }( window, function factory( window, jQuery ) {
  34. // ----- utils ----- //
  35. var arraySlice = Array.prototype.slice;
  36. // helper function for logging errors
  37. // $.error breaks jQuery chaining
  38. var console = window.console;
  39. var logError = typeof console == 'undefined' ? function() {} :
  40. function( message ) {
  41. console.error( message );
  42. };
  43. // ----- jQueryBridget ----- //
  44. function jQueryBridget( namespace, PluginClass, $ ) {
  45. $ = $ || jQuery || window.jQuery;
  46. if ( !$ ) {
  47. return;
  48. }
  49. // add option method -> $().plugin('option', {...})
  50. if ( !PluginClass.prototype.option ) {
  51. // option setter
  52. PluginClass.prototype.option = function( opts ) {
  53. // bail out if not an object
  54. if ( !$.isPlainObject( opts ) ){
  55. return;
  56. }
  57. this.options = $.extend( true, this.options, opts );
  58. };
  59. }
  60. // make jQuery plugin
  61. $.fn[ namespace ] = function( arg0 /*, arg1 */ ) {
  62. if ( typeof arg0 == 'string' ) {
  63. // method call $().plugin( 'methodName', { options } )
  64. // shift arguments by 1
  65. var args = arraySlice.call( arguments, 1 );
  66. return methodCall( this, arg0, args );
  67. }
  68. // just $().plugin({ options })
  69. plainCall( this, arg0 );
  70. return this;
  71. };
  72. // $().plugin('methodName')
  73. function methodCall( $elems, methodName, args ) {
  74. var returnValue;
  75. var pluginMethodStr = '$().' + namespace + '("' + methodName + '")';
  76. $elems.each( function( i, elem ) {
  77. // get instance
  78. var instance = $.data( elem, namespace );
  79. if ( !instance ) {
  80. logError( namespace + ' not initialized. Cannot call methods, i.e. ' +
  81. pluginMethodStr );
  82. return;
  83. }
  84. var method = instance[ methodName ];
  85. if ( !method || methodName.charAt(0) == '_' ) {
  86. logError( pluginMethodStr + ' is not a valid method' );
  87. return;
  88. }
  89. // apply method, get return value
  90. var value = method.apply( instance, args );
  91. // set return value if value is returned, use only first value
  92. returnValue = returnValue === undefined ? value : returnValue;
  93. });
  94. return returnValue !== undefined ? returnValue : $elems;
  95. }
  96. function plainCall( $elems, options ) {
  97. $elems.each( function( i, elem ) {
  98. var instance = $.data( elem, namespace );
  99. if ( instance ) {
  100. // set options & init
  101. instance.option( options );
  102. instance._init();
  103. } else {
  104. // initialize new instance
  105. instance = new PluginClass( elem, options );
  106. $.data( elem, namespace, instance );
  107. }
  108. });
  109. }
  110. updateJQuery( $ );
  111. }
  112. // ----- updateJQuery ----- //
  113. // set $.bridget for v1 backwards compatibility
  114. function updateJQuery( $ ) {
  115. if ( !$ || ( $ && $.bridget ) ) {
  116. return;
  117. }
  118. $.bridget = jQueryBridget;
  119. }
  120. updateJQuery( jQuery || window.jQuery );
  121. // ----- ----- //
  122. return jQueryBridget;
  123. }));
  124. /*!
  125. * getSize v2.0.2
  126. * measure size of elements
  127. * MIT license
  128. */
  129. /*jshint browser: true, strict: true, undef: true, unused: true */
  130. /*global define: false, module: false, console: false */
  131. ( function( window, factory ) {
  132. if ( typeof define == 'function' && define.amd ) {
  133. // AMD
  134. define( 'get-size/get-size',[],function() {
  135. return factory();
  136. });
  137. } else if ( typeof module == 'object' && module.exports ) {
  138. // CommonJS
  139. module.exports = factory();
  140. } else {
  141. // browser global
  142. window.getSize = factory();
  143. }
  144. })( window, function factory() {
  145. // -------------------------- helpers -------------------------- //
  146. // get a number from a string, not a percentage
  147. function getStyleSize( value ) {
  148. var num = parseFloat( value );
  149. // not a percent like '100%', and a number
  150. var isValid = value.indexOf('%') == -1 && !isNaN( num );
  151. return isValid && num;
  152. }
  153. function noop() {}
  154. var logError = typeof console == 'undefined' ? noop :
  155. function( message ) {
  156. console.error( message );
  157. };
  158. // -------------------------- measurements -------------------------- //
  159. var measurements = [
  160. 'paddingLeft',
  161. 'paddingRight',
  162. 'paddingTop',
  163. 'paddingBottom',
  164. 'marginLeft',
  165. 'marginRight',
  166. 'marginTop',
  167. 'marginBottom',
  168. 'borderLeftWidth',
  169. 'borderRightWidth',
  170. 'borderTopWidth',
  171. 'borderBottomWidth'
  172. ];
  173. var measurementsLength = measurements.length;
  174. function getZeroSize() {
  175. var size = {
  176. width: 0,
  177. height: 0,
  178. innerWidth: 0,
  179. innerHeight: 0,
  180. outerWidth: 0,
  181. outerHeight: 0
  182. };
  183. for ( var i=0; i < measurementsLength; i++ ) {
  184. var measurement = measurements[i];
  185. size[ measurement ] = 0;
  186. }
  187. return size;
  188. }
  189. // -------------------------- getStyle -------------------------- //
  190. /**
  191. * getStyle, get style of element, check for Firefox bug
  192. * https://bugzilla.mozilla.org/show_bug.cgi?id=548397
  193. */
  194. function getStyle( elem ) {
  195. var style = getComputedStyle( elem );
  196. if ( !style ) {
  197. logError( 'Style returned ' + style +
  198. '. Are you running this code in a hidden iframe on Firefox? ' +
  199. 'See http://bit.ly/getsizebug1' );
  200. }
  201. return style;
  202. }
  203. // -------------------------- setup -------------------------- //
  204. var isSetup = false;
  205. var isBoxSizeOuter;
  206. /**
  207. * setup
  208. * check isBoxSizerOuter
  209. * do on first getSize() rather than on page load for Firefox bug
  210. */
  211. function setup() {
  212. // setup once
  213. if ( isSetup ) {
  214. return;
  215. }
  216. isSetup = true;
  217. // -------------------------- box sizing -------------------------- //
  218. /**
  219. * WebKit measures the outer-width on style.width on border-box elems
  220. * IE & Firefox<29 measures the inner-width
  221. */
  222. var div = document.createElement('div');
  223. div.style.width = '200px';
  224. div.style.padding = '1px 2px 3px 4px';
  225. div.style.borderStyle = 'solid';
  226. div.style.borderWidth = '1px 2px 3px 4px';
  227. div.style.boxSizing = 'border-box';
  228. var body = document.body || document.documentElement;
  229. body.appendChild( div );
  230. var style = getStyle( div );
  231. getSize.isBoxSizeOuter = isBoxSizeOuter = getStyleSize( style.width ) == 200;
  232. body.removeChild( div );
  233. }
  234. // -------------------------- getSize -------------------------- //
  235. function getSize( elem ) {
  236. setup();
  237. // use querySeletor if elem is string
  238. if ( typeof elem == 'string' ) {
  239. elem = document.querySelector( elem );
  240. }
  241. // do not proceed on non-objects
  242. if ( !elem || typeof elem != 'object' || !elem.nodeType ) {
  243. return;
  244. }
  245. var style = getStyle( elem );
  246. // if hidden, everything is 0
  247. if ( style.display == 'none' ) {
  248. return getZeroSize();
  249. }
  250. var size = {};
  251. size.width = elem.offsetWidth;
  252. size.height = elem.offsetHeight;
  253. var isBorderBox = size.isBorderBox = style.boxSizing == 'border-box';
  254. // get all measurements
  255. for ( var i=0; i < measurementsLength; i++ ) {
  256. var measurement = measurements[i];
  257. var value = style[ measurement ];
  258. var num = parseFloat( value );
  259. // any 'auto', 'medium' value will be 0
  260. size[ measurement ] = !isNaN( num ) ? num : 0;
  261. }
  262. var paddingWidth = size.paddingLeft + size.paddingRight;
  263. var paddingHeight = size.paddingTop + size.paddingBottom;
  264. var marginWidth = size.marginLeft + size.marginRight;
  265. var marginHeight = size.marginTop + size.marginBottom;
  266. var borderWidth = size.borderLeftWidth + size.borderRightWidth;
  267. var borderHeight = size.borderTopWidth + size.borderBottomWidth;
  268. var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
  269. // overwrite width and height if we can get it from style
  270. var styleWidth = getStyleSize( style.width );
  271. if ( styleWidth !== false ) {
  272. size.width = styleWidth +
  273. // add padding and border unless it's already including it
  274. ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
  275. }
  276. var styleHeight = getStyleSize( style.height );
  277. if ( styleHeight !== false ) {
  278. size.height = styleHeight +
  279. // add padding and border unless it's already including it
  280. ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
  281. }
  282. size.innerWidth = size.width - ( paddingWidth + borderWidth );
  283. size.innerHeight = size.height - ( paddingHeight + borderHeight );
  284. size.outerWidth = size.width + marginWidth;
  285. size.outerHeight = size.height + marginHeight;
  286. return size;
  287. }
  288. return getSize;
  289. });
  290. /**
  291. * EvEmitter v1.0.3
  292. * Lil' event emitter
  293. * MIT License
  294. */
  295. /* jshint unused: true, undef: true, strict: true */
  296. ( function( global, factory ) {
  297. // universal module definition
  298. /* jshint strict: false */ /* globals define, module, window */
  299. if ( typeof define == 'function' && define.amd ) {
  300. // AMD - RequireJS
  301. define( 'ev-emitter/ev-emitter',factory );
  302. } else if ( typeof module == 'object' && module.exports ) {
  303. // CommonJS - Browserify, Webpack
  304. module.exports = factory();
  305. } else {
  306. // Browser globals
  307. global.EvEmitter = factory();
  308. }
  309. }( typeof window != 'undefined' ? window : this, function() {
  310. function EvEmitter() {}
  311. var proto = EvEmitter.prototype;
  312. proto.on = function( eventName, listener ) {
  313. if ( !eventName || !listener ) {
  314. return;
  315. }
  316. // set events hash
  317. var events = this._events = this._events || {};
  318. // set listeners array
  319. var listeners = events[ eventName ] = events[ eventName ] || [];
  320. // only add once
  321. if ( listeners.indexOf( listener ) == -1 ) {
  322. listeners.push( listener );
  323. }
  324. return this;
  325. };
  326. proto.once = function( eventName, listener ) {
  327. if ( !eventName || !listener ) {
  328. return;
  329. }
  330. // add event
  331. this.on( eventName, listener );
  332. // set once flag
  333. // set onceEvents hash
  334. var onceEvents = this._onceEvents = this._onceEvents || {};
  335. // set onceListeners object
  336. var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
  337. // set flag
  338. onceListeners[ listener ] = true;
  339. return this;
  340. };
  341. proto.off = function( eventName, listener ) {
  342. var listeners = this._events && this._events[ eventName ];
  343. if ( !listeners || !listeners.length ) {
  344. return;
  345. }
  346. var index = listeners.indexOf( listener );
  347. if ( index != -1 ) {
  348. listeners.splice( index, 1 );
  349. }
  350. return this;
  351. };
  352. proto.emitEvent = function( eventName, args ) {
  353. var listeners = this._events && this._events[ eventName ];
  354. if ( !listeners || !listeners.length ) {
  355. return;
  356. }
  357. var i = 0;
  358. var listener = listeners[i];
  359. args = args || [];
  360. // once stuff
  361. var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
  362. while ( listener ) {
  363. var isOnce = onceListeners && onceListeners[ listener ];
  364. if ( isOnce ) {
  365. // remove listener
  366. // remove before trigger to prevent recursion
  367. this.off( eventName, listener );
  368. // unset once flag
  369. delete onceListeners[ listener ];
  370. }
  371. // trigger listener
  372. listener.apply( this, args );
  373. // get next listener
  374. i += isOnce ? 0 : 1;
  375. listener = listeners[i];
  376. }
  377. return this;
  378. };
  379. return EvEmitter;
  380. }));
  381. /*!
  382. * Unipointer v2.1.0
  383. * base class for doing one thing with pointer event
  384. * MIT license
  385. */
  386. /*jshint browser: true, undef: true, unused: true, strict: true */
  387. ( function( window, factory ) {
  388. // universal module definition
  389. /* jshint strict: false */ /*global define, module, require */
  390. if ( typeof define == 'function' && define.amd ) {
  391. // AMD
  392. define( 'unipointer/unipointer',[
  393. 'ev-emitter/ev-emitter'
  394. ], function( EvEmitter ) {
  395. return factory( window, EvEmitter );
  396. });
  397. } else if ( typeof module == 'object' && module.exports ) {
  398. // CommonJS
  399. module.exports = factory(
  400. window,
  401. require('ev-emitter')
  402. );
  403. } else {
  404. // browser global
  405. window.Unipointer = factory(
  406. window,
  407. window.EvEmitter
  408. );
  409. }
  410. }( window, function factory( window, EvEmitter ) {
  411. function noop() {}
  412. function Unipointer() {}
  413. // inherit EvEmitter
  414. var proto = Unipointer.prototype = Object.create( EvEmitter.prototype );
  415. proto.bindStartEvent = function( elem ) {
  416. this._bindStartEvent( elem, true );
  417. };
  418. proto.unbindStartEvent = function( elem ) {
  419. this._bindStartEvent( elem, false );
  420. };
  421. /**
  422. * works as unbinder, as you can ._bindStart( false ) to unbind
  423. * @param {Boolean} isBind - will unbind if falsey
  424. */
  425. proto._bindStartEvent = function( elem, isBind ) {
  426. // munge isBind, default to true
  427. isBind = isBind === undefined ? true : !!isBind;
  428. var bindMethod = isBind ? 'addEventListener' : 'removeEventListener';
  429. if ( window.navigator.pointerEnabled ) {
  430. // W3C Pointer Events, IE11. See https://coderwall.com/p/mfreca
  431. elem[ bindMethod ]( 'pointerdown', this );
  432. } else if ( window.navigator.msPointerEnabled ) {
  433. // IE10 Pointer Events
  434. elem[ bindMethod ]( 'MSPointerDown', this );
  435. } else {
  436. // listen for both, for devices like Chrome Pixel
  437. elem[ bindMethod ]( 'mousedown', this );
  438. elem[ bindMethod ]( 'touchstart', this );
  439. }
  440. };
  441. // trigger handler methods for events
  442. proto.handleEvent = function( event ) {
  443. var method = 'on' + event.type;
  444. if ( this[ method ] ) {
  445. this[ method ]( event );
  446. }
  447. };
  448. // returns the touch that we're keeping track of
  449. proto.getTouch = function( touches ) {
  450. for ( var i=0; i < touches.length; i++ ) {
  451. var touch = touches[i];
  452. if ( touch.identifier == this.pointerIdentifier ) {
  453. return touch;
  454. }
  455. }
  456. };
  457. // ----- start event ----- //
  458. proto.onmousedown = function( event ) {
  459. // dismiss clicks from right or middle buttons
  460. var button = event.button;
  461. if ( button && ( button !== 0 && button !== 1 ) ) {
  462. return;
  463. }
  464. this._pointerDown( event, event );
  465. };
  466. proto.ontouchstart = function( event ) {
  467. this._pointerDown( event, event.changedTouches[0] );
  468. };
  469. proto.onMSPointerDown =
  470. proto.onpointerdown = function( event ) {
  471. this._pointerDown( event, event );
  472. };
  473. /**
  474. * pointer start
  475. * @param {Event} event
  476. * @param {Event or Touch} pointer
  477. */
  478. proto._pointerDown = function( event, pointer ) {
  479. // dismiss other pointers
  480. if ( this.isPointerDown ) {
  481. return;
  482. }
  483. this.isPointerDown = true;
  484. // save pointer identifier to match up touch events
  485. this.pointerIdentifier = pointer.pointerId !== undefined ?
  486. // pointerId for pointer events, touch.indentifier for touch events
  487. pointer.pointerId : pointer.identifier;
  488. this.pointerDown( event, pointer );
  489. };
  490. proto.pointerDown = function( event, pointer ) {
  491. this._bindPostStartEvents( event );
  492. this.emitEvent( 'pointerDown', [ event, pointer ] );
  493. };
  494. // hash of events to be bound after start event
  495. var postStartEvents = {
  496. mousedown: [ 'mousemove', 'mouseup' ],
  497. touchstart: [ 'touchmove', 'touchend', 'touchcancel' ],
  498. pointerdown: [ 'pointermove', 'pointerup', 'pointercancel' ],
  499. MSPointerDown: [ 'MSPointerMove', 'MSPointerUp', 'MSPointerCancel' ]
  500. };
  501. proto._bindPostStartEvents = function( event ) {
  502. if ( !event ) {
  503. return;
  504. }
  505. // get proper events to match start event
  506. var events = postStartEvents[ event.type ];
  507. // bind events to node
  508. events.forEach( function( eventName ) {
  509. window.addEventListener( eventName, this );
  510. }, this );
  511. // save these arguments
  512. this._boundPointerEvents = events;
  513. };
  514. proto._unbindPostStartEvents = function() {
  515. // check for _boundEvents, in case dragEnd triggered twice (old IE8 bug)
  516. if ( !this._boundPointerEvents ) {
  517. return;
  518. }
  519. this._boundPointerEvents.forEach( function( eventName ) {
  520. window.removeEventListener( eventName, this );
  521. }, this );
  522. delete this._boundPointerEvents;
  523. };
  524. // ----- move event ----- //
  525. proto.onmousemove = function( event ) {
  526. this._pointerMove( event, event );
  527. };
  528. proto.onMSPointerMove =
  529. proto.onpointermove = function( event ) {
  530. if ( event.pointerId == this.pointerIdentifier ) {
  531. this._pointerMove( event, event );
  532. }
  533. };
  534. proto.ontouchmove = function( event ) {
  535. var touch = this.getTouch( event.changedTouches );
  536. if ( touch ) {
  537. this._pointerMove( event, touch );
  538. }
  539. };
  540. /**
  541. * pointer move
  542. * @param {Event} event
  543. * @param {Event or Touch} pointer
  544. * @private
  545. */
  546. proto._pointerMove = function( event, pointer ) {
  547. this.pointerMove( event, pointer );
  548. };
  549. // public
  550. proto.pointerMove = function( event, pointer ) {
  551. this.emitEvent( 'pointerMove', [ event, pointer ] );
  552. };
  553. // ----- end event ----- //
  554. proto.onmouseup = function( event ) {
  555. this._pointerUp( event, event );
  556. };
  557. proto.onMSPointerUp =
  558. proto.onpointerup = function( event ) {
  559. if ( event.pointerId == this.pointerIdentifier ) {
  560. this._pointerUp( event, event );
  561. }
  562. };
  563. proto.ontouchend = function( event ) {
  564. var touch = this.getTouch( event.changedTouches );
  565. if ( touch ) {
  566. this._pointerUp( event, touch );
  567. }
  568. };
  569. /**
  570. * pointer up
  571. * @param {Event} event
  572. * @param {Event or Touch} pointer
  573. * @private
  574. */
  575. proto._pointerUp = function( event, pointer ) {
  576. this._pointerDone();
  577. this.pointerUp( event, pointer );
  578. };
  579. // public
  580. proto.pointerUp = function( event, pointer ) {
  581. this.emitEvent( 'pointerUp', [ event, pointer ] );
  582. };
  583. // ----- pointer done ----- //
  584. // triggered on pointer up & pointer cancel
  585. proto._pointerDone = function() {
  586. // reset properties
  587. this.isPointerDown = false;
  588. delete this.pointerIdentifier;
  589. // remove events
  590. this._unbindPostStartEvents();
  591. this.pointerDone();
  592. };
  593. proto.pointerDone = noop;
  594. // ----- pointer cancel ----- //
  595. proto.onMSPointerCancel =
  596. proto.onpointercancel = function( event ) {
  597. if ( event.pointerId == this.pointerIdentifier ) {
  598. this._pointerCancel( event, event );
  599. }
  600. };
  601. proto.ontouchcancel = function( event ) {
  602. var touch = this.getTouch( event.changedTouches );
  603. if ( touch ) {
  604. this._pointerCancel( event, touch );
  605. }
  606. };
  607. /**
  608. * pointer cancel
  609. * @param {Event} event
  610. * @param {Event or Touch} pointer
  611. * @private
  612. */
  613. proto._pointerCancel = function( event, pointer ) {
  614. this._pointerDone();
  615. this.pointerCancel( event, pointer );
  616. };
  617. // public
  618. proto.pointerCancel = function( event, pointer ) {
  619. this.emitEvent( 'pointerCancel', [ event, pointer ] );
  620. };
  621. // ----- ----- //
  622. // utility function for getting x/y coords from event
  623. Unipointer.getPointerPoint = function( pointer ) {
  624. return {
  625. x: pointer.pageX,
  626. y: pointer.pageY
  627. };
  628. };
  629. // ----- ----- //
  630. return Unipointer;
  631. }));
  632. /*!
  633. * Unidragger v2.1.0
  634. * Draggable base class
  635. * MIT license
  636. */
  637. /*jshint browser: true, unused: true, undef: true, strict: true */
  638. ( function( window, factory ) {
  639. // universal module definition
  640. /*jshint strict: false */ /*globals define, module, require */
  641. if ( typeof define == 'function' && define.amd ) {
  642. // AMD
  643. define( 'unidragger/unidragger',[
  644. 'unipointer/unipointer'
  645. ], function( Unipointer ) {
  646. return factory( window, Unipointer );
  647. });
  648. } else if ( typeof module == 'object' && module.exports ) {
  649. // CommonJS
  650. module.exports = factory(
  651. window,
  652. require('unipointer')
  653. );
  654. } else {
  655. // browser global
  656. window.Unidragger = factory(
  657. window,
  658. window.Unipointer
  659. );
  660. }
  661. }( window, function factory( window, Unipointer ) {
  662. // ----- ----- //
  663. function noop() {}
  664. // -------------------------- Unidragger -------------------------- //
  665. function Unidragger() {}
  666. // inherit Unipointer & EvEmitter
  667. var proto = Unidragger.prototype = Object.create( Unipointer.prototype );
  668. // ----- bind start ----- //
  669. proto.bindHandles = function() {
  670. this._bindHandles( true );
  671. };
  672. proto.unbindHandles = function() {
  673. this._bindHandles( false );
  674. };
  675. var navigator = window.navigator;
  676. /**
  677. * works as unbinder, as you can .bindHandles( false ) to unbind
  678. * @param {Boolean} isBind - will unbind if falsey
  679. */
  680. proto._bindHandles = function( isBind ) {
  681. // munge isBind, default to true
  682. isBind = isBind === undefined ? true : !!isBind;
  683. // extra bind logic
  684. var binderExtra;
  685. if ( navigator.pointerEnabled ) {
  686. binderExtra = function( handle ) {
  687. // disable scrolling on the element
  688. handle.style.touchAction = isBind ? 'none' : '';
  689. };
  690. } else if ( navigator.msPointerEnabled ) {
  691. binderExtra = function( handle ) {
  692. // disable scrolling on the element
  693. handle.style.msTouchAction = isBind ? 'none' : '';
  694. };
  695. } else {
  696. binderExtra = noop;
  697. }
  698. // bind each handle
  699. var bindMethod = isBind ? 'addEventListener' : 'removeEventListener';
  700. for ( var i=0; i < this.handles.length; i++ ) {
  701. var handle = this.handles[i];
  702. this._bindStartEvent( handle, isBind );
  703. binderExtra( handle );
  704. handle[ bindMethod ]( 'click', this );
  705. }
  706. };
  707. // ----- start event ----- //
  708. /**
  709. * pointer start
  710. * @param {Event} event
  711. * @param {Event or Touch} pointer
  712. */
  713. proto.pointerDown = function( event, pointer ) {
  714. // dismiss range sliders
  715. if ( event.target.nodeName == 'INPUT' && event.target.type == 'range' ) {
  716. // reset pointerDown logic
  717. this.isPointerDown = false;
  718. delete this.pointerIdentifier;
  719. return;
  720. }
  721. this._dragPointerDown( event, pointer );
  722. // kludge to blur focused inputs in dragger
  723. var focused = document.activeElement;
  724. if ( focused && focused.blur ) {
  725. focused.blur();
  726. }
  727. // bind move and end events
  728. this._bindPostStartEvents( event );
  729. this.emitEvent( 'pointerDown', [ event, pointer ] );
  730. };
  731. // base pointer down logic
  732. proto._dragPointerDown = function( event, pointer ) {
  733. // track to see when dragging starts
  734. this.pointerDownPoint = Unipointer.getPointerPoint( pointer );
  735. var canPreventDefault = this.canPreventDefaultOnPointerDown( event, pointer );
  736. if ( canPreventDefault ) {
  737. event.preventDefault();
  738. }
  739. };
  740. // overwriteable method so Flickity can prevent for scrolling
  741. proto.canPreventDefaultOnPointerDown = function( event ) {
  742. // prevent default, unless touchstart or <select>
  743. return event.target.nodeName != 'SELECT';
  744. };
  745. // ----- move event ----- //
  746. /**
  747. * drag move
  748. * @param {Event} event
  749. * @param {Event or Touch} pointer
  750. */
  751. proto.pointerMove = function( event, pointer ) {
  752. var moveVector = this._dragPointerMove( event, pointer );
  753. this.emitEvent( 'pointerMove', [ event, pointer, moveVector ] );
  754. this._dragMove( event, pointer, moveVector );
  755. };
  756. // base pointer move logic
  757. proto._dragPointerMove = function( event, pointer ) {
  758. var movePoint = Unipointer.getPointerPoint( pointer );
  759. var moveVector = {
  760. x: movePoint.x - this.pointerDownPoint.x,
  761. y: movePoint.y - this.pointerDownPoint.y
  762. };
  763. // start drag if pointer has moved far enough to start drag
  764. if ( !this.isDragging && this.hasDragStarted( moveVector ) ) {
  765. this._dragStart( event, pointer );
  766. }
  767. return moveVector;
  768. };
  769. // condition if pointer has moved far enough to start drag
  770. proto.hasDragStarted = function( moveVector ) {
  771. return Math.abs( moveVector.x ) > 3 || Math.abs( moveVector.y ) > 3;
  772. };
  773. // ----- end event ----- //
  774. /**
  775. * pointer up
  776. * @param {Event} event
  777. * @param {Event or Touch} pointer
  778. */
  779. proto.pointerUp = function( event, pointer ) {
  780. this.emitEvent( 'pointerUp', [ event, pointer ] );
  781. this._dragPointerUp( event, pointer );
  782. };
  783. proto._dragPointerUp = function( event, pointer ) {
  784. if ( this.isDragging ) {
  785. this._dragEnd( event, pointer );
  786. } else {
  787. // pointer didn't move enough for drag to start
  788. this._staticClick( event, pointer );
  789. }
  790. };
  791. // -------------------------- drag -------------------------- //
  792. // dragStart
  793. proto._dragStart = function( event, pointer ) {
  794. this.isDragging = true;
  795. this.dragStartPoint = Unipointer.getPointerPoint( pointer );
  796. // prevent clicks
  797. this.isPreventingClicks = true;
  798. this.dragStart( event, pointer );
  799. };
  800. proto.dragStart = function( event, pointer ) {
  801. this.emitEvent( 'dragStart', [ event, pointer ] );
  802. };
  803. // dragMove
  804. proto._dragMove = function( event, pointer, moveVector ) {
  805. // do not drag if not dragging yet
  806. if ( !this.isDragging ) {
  807. return;
  808. }
  809. this.dragMove( event, pointer, moveVector );
  810. };
  811. proto.dragMove = function( event, pointer, moveVector ) {
  812. event.preventDefault();
  813. this.emitEvent( 'dragMove', [ event, pointer, moveVector ] );
  814. };
  815. // dragEnd
  816. proto._dragEnd = function( event, pointer ) {
  817. // set flags
  818. this.isDragging = false;
  819. // re-enable clicking async
  820. setTimeout( function() {
  821. delete this.isPreventingClicks;
  822. }.bind( this ) );
  823. this.dragEnd( event, pointer );
  824. };
  825. proto.dragEnd = function( event, pointer ) {
  826. this.emitEvent( 'dragEnd', [ event, pointer ] );
  827. };
  828. // ----- onclick ----- //
  829. // handle all clicks and prevent clicks when dragging
  830. proto.onclick = function( event ) {
  831. if ( this.isPreventingClicks ) {
  832. event.preventDefault();
  833. }
  834. };
  835. // ----- staticClick ----- //
  836. // triggered after pointer down & up with no/tiny movement
  837. proto._staticClick = function( event, pointer ) {
  838. // ignore emulated mouse up clicks
  839. if ( this.isIgnoringMouseUp && event.type == 'mouseup' ) {
  840. return;
  841. }
  842. // allow click in <input>s and <textarea>s
  843. var nodeName = event.target.nodeName;
  844. if ( nodeName == 'INPUT' || nodeName == 'TEXTAREA' ) {
  845. event.target.focus();
  846. }
  847. this.staticClick( event, pointer );
  848. // set flag for emulated clicks 300ms after touchend
  849. if ( event.type != 'mouseup' ) {
  850. this.isIgnoringMouseUp = true;
  851. // reset flag after 300ms
  852. setTimeout( function() {
  853. delete this.isIgnoringMouseUp;
  854. }.bind( this ), 400 );
  855. }
  856. };
  857. proto.staticClick = function( event, pointer ) {
  858. this.emitEvent( 'staticClick', [ event, pointer ] );
  859. };
  860. // ----- utils ----- //
  861. Unidragger.getPointerPoint = Unipointer.getPointerPoint;
  862. // ----- ----- //
  863. return Unidragger;
  864. }));
  865. /*!
  866. * Draggabilly v2.1.1
  867. * Make that shiz draggable
  868. * http://draggabilly.desandro.com
  869. * MIT license
  870. */
  871. /*jshint browser: true, strict: true, undef: true, unused: true */
  872. ( function( window, factory ) {
  873. // universal module definition
  874. /* jshint strict: false */ /*globals define, module, require */
  875. if ( typeof define == 'function' && define.amd ) {
  876. // AMD
  877. define( [
  878. 'get-size/get-size',
  879. 'unidragger/unidragger'
  880. ],
  881. function( getSize, Unidragger ) {
  882. return factory( window, getSize, Unidragger );
  883. });
  884. } else if ( typeof module == 'object' && module.exports ) {
  885. // CommonJS
  886. module.exports = factory(
  887. window,
  888. require('get-size'),
  889. require('unidragger')
  890. );
  891. } else {
  892. // browser global
  893. window.Draggabilly = factory(
  894. window,
  895. window.getSize,
  896. window.Unidragger
  897. );
  898. }
  899. }( window, function factory( window, getSize, Unidragger ) {
  900. // vars
  901. var document = window.document;
  902. function noop() {}
  903. // -------------------------- helpers -------------------------- //
  904. // extend objects
  905. function extend( a, b ) {
  906. for ( var prop in b ) {
  907. a[ prop ] = b[ prop ];
  908. }
  909. return a;
  910. }
  911. function isElement( obj ) {
  912. return obj instanceof HTMLElement;
  913. }
  914. // -------------------------- requestAnimationFrame -------------------------- //
  915. // get rAF, prefixed, if present
  916. var requestAnimationFrame = window.requestAnimationFrame ||
  917. window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
  918. // fallback to setTimeout
  919. var lastTime = 0;
  920. if ( !requestAnimationFrame ) {
  921. requestAnimationFrame = function( callback ) {
  922. var currTime = new Date().getTime();
  923. var timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) );
  924. var id = setTimeout( callback, timeToCall );
  925. lastTime = currTime + timeToCall;
  926. return id;
  927. };
  928. }
  929. // -------------------------- support -------------------------- //
  930. var docElem = document.documentElement;
  931. var transformProperty = typeof docElem.style.transform == 'string' ?
  932. 'transform' : 'WebkitTransform';
  933. var jQuery = window.jQuery;
  934. // -------------------------- -------------------------- //
  935. function Draggabilly( element, options ) {
  936. // querySelector if string
  937. this.element = typeof element == 'string' ?
  938. document.querySelector( element ) : element;
  939. if ( jQuery ) {
  940. this.$element = jQuery( this.element );
  941. }
  942. // options
  943. this.options = extend( {}, this.constructor.defaults );
  944. this.option( options );
  945. this._create();
  946. }
  947. // inherit Unidragger methods
  948. var proto = Draggabilly.prototype = Object.create( Unidragger.prototype );
  949. Draggabilly.defaults = {
  950. };
  951. /**
  952. * set options
  953. * @param {Object} opts
  954. */
  955. proto.option = function( opts ) {
  956. extend( this.options, opts );
  957. };
  958. // css position values that don't need to be set
  959. var positionValues = {
  960. relative: true,
  961. absolute: true,
  962. fixed: true
  963. };
  964. proto._create = function() {
  965. // properties
  966. this.position = {};
  967. this._getPosition();
  968. this.startPoint = { x: 0, y: 0 };
  969. this.dragPoint = { x: 0, y: 0 };
  970. this.startPosition = extend( {}, this.position );
  971. // set relative positioning
  972. var style = getComputedStyle( this.element );
  973. if ( !positionValues[ style.position ] ) {
  974. this.element.style.position = 'fixed';
  975. }
  976. this.enable();
  977. this.setHandles();
  978. };
  979. /**
  980. * set this.handles and bind start events to 'em
  981. */
  982. proto.setHandles = function() {
  983. this.handles = this.options.handle ?
  984. this.element.querySelectorAll( this.options.handle ) : [ this.element ];
  985. this.bindHandles();
  986. };
  987. /**
  988. * emits events via EvEmitter and jQuery events
  989. * @param {String} type - name of event
  990. * @param {Event} event - original event
  991. * @param {Array} args - extra arguments
  992. */
  993. proto.dispatchEvent = function( type, event, args ) {
  994. var emitArgs = [ event ].concat( args );
  995. this.emitEvent( type, emitArgs );
  996. var jQuery = window.jQuery;
  997. // trigger jQuery event
  998. if ( jQuery && this.$element ) {
  999. if ( event ) {
  1000. // create jQuery event
  1001. var $event = jQuery.Event( event );
  1002. $event.type = type;
  1003. this.$element.trigger( $event, args );
  1004. } else {
  1005. // just trigger with type if no event available
  1006. this.$element.trigger( type, args );
  1007. }
  1008. }
  1009. };
  1010. // -------------------------- position -------------------------- //
  1011. // get x/y position from style
  1012. proto._getPosition = function() {
  1013. var style = getComputedStyle( this.element );
  1014. var x = this._getPositionCoord( style.left, 'width' );
  1015. var y = this._getPositionCoord( style.top, 'height' );
  1016. // clean up 'auto' or other non-integer values
  1017. this.position.x = isNaN( x ) ? 0 : x;
  1018. this.position.y = isNaN( y ) ? 0 : y;
  1019. this._addTransformPosition( style );
  1020. };
  1021. proto._getPositionCoord = function( styleSide, measure ) {
  1022. if ( styleSide.indexOf('%') != -1 ) {
  1023. // convert percent into pixel for Safari, #75
  1024. var parentSize = getSize( this.element.parentNode );
  1025. // prevent not-in-DOM element throwing bug, #131
  1026. return !parentSize ? 0 :
  1027. ( parseFloat( styleSide ) / 100 ) * parentSize[ measure ];
  1028. }
  1029. return parseInt( styleSide, 10 );
  1030. };
  1031. // add transform: translate( x, y ) to position
  1032. proto._addTransformPosition = function( style ) {
  1033. var transform = style[ transformProperty ];
  1034. // bail out if value is 'none'
  1035. if ( transform.indexOf('matrix') !== 0 ) {
  1036. return;
  1037. }
  1038. // split matrix(1, 0, 0, 1, x, y)
  1039. var matrixValues = transform.split(',');
  1040. // translate X value is in 12th or 4th position
  1041. var xIndex = transform.indexOf('matrix3d') === 0 ? 12 : 4;
  1042. var translateX = parseInt( matrixValues[ xIndex ], 10 );
  1043. // translate Y value is in 13th or 5th position
  1044. var translateY = parseInt( matrixValues[ xIndex + 1 ], 10 );
  1045. this.position.x += translateX;
  1046. this.position.y += translateY;
  1047. };
  1048. // -------------------------- events -------------------------- //
  1049. /**
  1050. * pointer start
  1051. * @param {Event} event
  1052. * @param {Event or Touch} pointer
  1053. */
  1054. proto.pointerDown = function( event, pointer ) {
  1055. this._dragPointerDown( event, pointer );
  1056. // kludge to blur focused inputs in dragger
  1057. var focused = document.activeElement;
  1058. // do not blur body for IE10, metafizzy/flickity#117
  1059. if ( focused && focused.blur && focused != document.body ) {
  1060. focused.blur();
  1061. }
  1062. // bind move and end events
  1063. this._bindPostStartEvents( event );
  1064. this.element.classList.add('is-pointer-down');
  1065. this.dispatchEvent( 'pointerDown', event, [ pointer ] );
  1066. };
  1067. /**
  1068. * drag move
  1069. * @param {Event} event
  1070. * @param {Event or Touch} pointer
  1071. */
  1072. proto.pointerMove = function( event, pointer ) {
  1073. var moveVector = this._dragPointerMove( event, pointer );
  1074. this.dispatchEvent( 'pointerMove', event, [ pointer, moveVector ] );
  1075. this._dragMove( event, pointer, moveVector );
  1076. };
  1077. /**
  1078. * drag start
  1079. * @param {Event} event
  1080. * @param {Event or Touch} pointer
  1081. */
  1082. proto.dragStart = function( event, pointer ) {
  1083. if ( !this.isEnabled ) {
  1084. return;
  1085. }
  1086. this._getPosition();
  1087. this.measureContainment();
  1088. // position _when_ drag began
  1089. this.startPosition.x = this.position.x;
  1090. this.startPosition.y = this.position.y;
  1091. // reset left/top style
  1092. this.setLeftTop();
  1093. this.dragPoint.x = 0;
  1094. this.dragPoint.y = 0;
  1095. this.element.classList.add('is-dragging');
  1096. this.dispatchEvent( 'dragStart', event, [ pointer ] );
  1097. // start animation
  1098. this.animate();
  1099. };
  1100. proto.measureContainment = function() {
  1101. var containment = this.options.containment;
  1102. if ( !containment ) {
  1103. return;
  1104. }
  1105. // use element if element
  1106. var container = isElement( containment ) ? containment :
  1107. // fallback to querySelector if string
  1108. typeof containment == 'string' ? document.querySelector( containment ) :
  1109. // otherwise just `true`, use the parent
  1110. this.element.parentNode;
  1111. var elemSize = getSize( this.element );
  1112. var containerSize = getSize( container );
  1113. var elemRect = this.element.getBoundingClientRect();
  1114. var containerRect = container.getBoundingClientRect();
  1115. var borderSizeX = containerSize.borderLeftWidth + containerSize.borderRightWidth;
  1116. var borderSizeY = containerSize.borderTopWidth + containerSize.borderBottomWidth;
  1117. var position = this.relativeStartPosition = {
  1118. x: elemRect.left - ( containerRect.left + containerSize.borderLeftWidth ),
  1119. y: elemRect.top - ( containerRect.top + containerSize.borderTopWidth )
  1120. };
  1121. this.containSize = {
  1122. width: ( containerSize.width - borderSizeX ) - position.x - elemSize.width,
  1123. height: ( containerSize.height - borderSizeY ) - position.y - elemSize.height
  1124. };
  1125. };
  1126. // ----- move event ----- //
  1127. /**
  1128. * drag move
  1129. * @param {Event} event
  1130. * @param {Event or Touch} pointer
  1131. */
  1132. proto.dragMove = function( event, pointer, moveVector ) {
  1133. if ( !this.isEnabled ) {
  1134. return;
  1135. }
  1136. var dragX = moveVector.x;
  1137. var dragY = moveVector.y;
  1138. var grid = this.options.grid;
  1139. var gridX = grid && grid[0];
  1140. var gridY = grid && grid[1];
  1141. dragX = applyGrid( dragX, gridX );
  1142. dragY = applyGrid( dragY, gridY );
  1143. dragX = this.containDrag( 'x', dragX, gridX );
  1144. dragY = this.containDrag( 'y', dragY, gridY );
  1145. // constrain to axis
  1146. dragX = this.options.axis == 'y' ? 0 : dragX;
  1147. dragY = this.options.axis == 'x' ? 0 : dragY;
  1148. this.position.x = this.startPosition.x + dragX;
  1149. this.position.y = this.startPosition.y + dragY;
  1150. // set dragPoint properties
  1151. this.dragPoint.x = dragX;
  1152. this.dragPoint.y = dragY;
  1153. this.dispatchEvent( 'dragMove', event, [ pointer, moveVector ] );
  1154. };
  1155. function applyGrid( value, grid, method ) {
  1156. method = method || 'round';
  1157. return grid ? Math[ method ]( value / grid ) * grid : value;
  1158. }
  1159. proto.containDrag = function( axis, drag, grid ) {
  1160. if ( !this.options.containment ) {
  1161. return drag;
  1162. }
  1163. var measure = axis == 'x' ? 'width' : 'height';
  1164. var rel = this.relativeStartPosition[ axis ];
  1165. var min = applyGrid( -rel, grid, 'ceil' );
  1166. var max = this.containSize[ measure ];
  1167. max = applyGrid( max, grid, 'floor' );
  1168. return Math.min( max, Math.max( min, drag ) );
  1169. };
  1170. // ----- end event ----- //
  1171. /**
  1172. * pointer up
  1173. * @param {Event} event
  1174. * @param {Event or Touch} pointer
  1175. */
  1176. proto.pointerUp = function( event, pointer ) {
  1177. this.element.classList.remove('is-pointer-down');
  1178. this.dispatchEvent( 'pointerUp', event, [ pointer ] );
  1179. this._dragPointerUp( event, pointer );
  1180. };
  1181. /**
  1182. * drag end
  1183. * @param {Event} event
  1184. * @param {Event or Touch} pointer
  1185. */
  1186. proto.dragEnd = function( event, pointer ) {
  1187. if ( !this.isEnabled ) {
  1188. return;
  1189. }
  1190. // use top left position when complete
  1191. if ( transformProperty ) {
  1192. this.element.style[ transformProperty ] = '';
  1193. this.setLeftTop();
  1194. }
  1195. this.element.classList.remove('is-dragging');
  1196. this.dispatchEvent( 'dragEnd', event, [ pointer ] );
  1197. };
  1198. // -------------------------- animation -------------------------- //
  1199. proto.animate = function() {
  1200. // only render and animate if dragging
  1201. if ( !this.isDragging ) {
  1202. return;
  1203. }
  1204. this.positionDrag();
  1205. var _this = this;
  1206. requestAnimationFrame( function animateFrame() {
  1207. _this.animate();
  1208. });
  1209. };
  1210. // left/top positioning
  1211. proto.setLeftTop = function() {
  1212. this.element.style.left = this.position.x + 'px';
  1213. this.element.style.top = this.position.y + 'px';
  1214. };
  1215. proto.positionDrag = function() {
  1216. this.element.style[ transformProperty ] = 'translate3d( ' + this.dragPoint.x +
  1217. 'px, ' + this.dragPoint.y + 'px, 0)';
  1218. };
  1219. // ----- staticClick ----- //
  1220. proto.staticClick = function( event, pointer ) {
  1221. this.dispatchEvent( 'staticClick', event, [ pointer ] );
  1222. };
  1223. // ----- methods ----- //
  1224. proto.enable = function() {
  1225. this.isEnabled = true;
  1226. };
  1227. proto.disable = function() {
  1228. this.isEnabled = false;
  1229. if ( this.isDragging ) {
  1230. this.dragEnd();
  1231. }
  1232. };
  1233. proto.destroy = function() {
  1234. this.disable();
  1235. // reset styles
  1236. this.element.style[ transformProperty ] = '';
  1237. this.element.style.left = '';
  1238. this.element.style.top = '';
  1239. this.element.style.position = '';
  1240. // unbind handles
  1241. this.unbindHandles();
  1242. // remove jQuery data
  1243. if ( this.$element ) {
  1244. this.$element.removeData('draggabilly');
  1245. }
  1246. };
  1247. // ----- jQuery bridget ----- //
  1248. // required for jQuery bridget
  1249. proto._init = noop;
  1250. if ( jQuery && jQuery.bridget ) {
  1251. jQuery.bridget( 'draggabilly', Draggabilly );
  1252. }
  1253. // ----- ----- //
  1254. return Draggabilly;
  1255. }));