draggabilly
Advanced tools
Comparing version 2.0.1 to 2.1.0
{ | ||
"name": "draggabilly", | ||
"main": "draggabilly.js", | ||
"version": "2.0.1", | ||
"description": "make that shiz draggable", | ||
"dependencies": { | ||
"get-size": "~2.0.2", | ||
"unidragger": "~2.0.0" | ||
"unidragger": "~2.1.0" | ||
}, | ||
@@ -10,0 +9,0 @@ "devDependencies": { |
/*! | ||
* Draggabilly PACKAGED v2.0.1 | ||
* Draggabilly PACKAGED v2.1.0 | ||
* Make that shiz draggable | ||
@@ -363,477 +363,114 @@ * http://draggabilly.desandro.com | ||
/*! | ||
* EventEmitter v4.2.11 - git.io/ee | ||
* Unlicense - http://unlicense.org/ | ||
* Oliver Caldwell - http://oli.me.uk/ | ||
* @preserve | ||
/** | ||
* EvEmitter v1.0.1 | ||
* Lil' event emitter | ||
* MIT License | ||
*/ | ||
;(function () { | ||
/* jshint unused: true, undef: true, strict: true */ | ||
/** | ||
* Class for managing events. | ||
* Can be extended to provide event functionality in other classes. | ||
* | ||
* @class EventEmitter Manages event registering and emitting. | ||
*/ | ||
function EventEmitter() {} | ||
( function( global, factory ) { | ||
// universal module definition | ||
/* jshint strict: false */ /* globals define, module */ | ||
if ( typeof define == 'function' && define.amd ) { | ||
// AMD - RequireJS | ||
define( 'ev-emitter/ev-emitter',factory ); | ||
} else if ( typeof module == 'object' && module.exports ) { | ||
// CommonJS - Browserify, Webpack | ||
module.exports = factory(); | ||
} else { | ||
// Browser globals | ||
global.EvEmitter = factory(); | ||
} | ||
// Shortcuts to improve speed and size | ||
var proto = EventEmitter.prototype; | ||
var exports = this; | ||
var originalGlobalValue = exports.EventEmitter; | ||
}( this, function() { | ||
/** | ||
* Finds the index of the listener for the event in its storage array. | ||
* | ||
* @param {Function[]} listeners Array of listeners to search through. | ||
* @param {Function} listener Method to look for. | ||
* @return {Number} Index of the specified listener, -1 if not found | ||
* @api private | ||
*/ | ||
function indexOfListener(listeners, listener) { | ||
var i = listeners.length; | ||
while (i--) { | ||
if (listeners[i].listener === listener) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
} | ||
/** | ||
* Alias a method while keeping the context correct, to allow for overwriting of target method. | ||
* | ||
* @param {String} name The name of the target method. | ||
* @return {Function} The aliased method | ||
* @api private | ||
*/ | ||
function alias(name) { | ||
return function aliasClosure() { | ||
return this[name].apply(this, arguments); | ||
}; | ||
} | ||
function EvEmitter() {} | ||
/** | ||
* Returns the listener array for the specified event. | ||
* Will initialise the event object and listener arrays if required. | ||
* Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them. | ||
* Each property in the object response is an array of listener functions. | ||
* | ||
* @param {String|RegExp} evt Name of the event to return the listeners from. | ||
* @return {Function[]|Object} All listener functions for the event. | ||
*/ | ||
proto.getListeners = function getListeners(evt) { | ||
var events = this._getEvents(); | ||
var response; | ||
var key; | ||
var proto = EvEmitter.prototype; | ||
// Return a concatenated array of all matching events if | ||
// the selector is a regular expression. | ||
if (evt instanceof RegExp) { | ||
response = {}; | ||
for (key in events) { | ||
if (events.hasOwnProperty(key) && evt.test(key)) { | ||
response[key] = events[key]; | ||
} | ||
} | ||
} | ||
else { | ||
response = events[evt] || (events[evt] = []); | ||
} | ||
proto.on = function( eventName, listener ) { | ||
if ( !eventName || !listener ) { | ||
return; | ||
} | ||
// set events hash | ||
var events = this._events = this._events || {}; | ||
// set listeners array | ||
var listeners = events[ eventName ] = events[ eventName ] || []; | ||
// only add once | ||
if ( listeners.indexOf( listener ) == -1 ) { | ||
listeners.push( listener ); | ||
} | ||
return response; | ||
}; | ||
return this; | ||
}; | ||
/** | ||
* Takes a list of listener objects and flattens it into a list of listener functions. | ||
* | ||
* @param {Object[]} listeners Raw listener objects. | ||
* @return {Function[]} Just the listener functions. | ||
*/ | ||
proto.flattenListeners = function flattenListeners(listeners) { | ||
var flatListeners = []; | ||
var i; | ||
proto.once = function( eventName, listener ) { | ||
if ( !eventName || !listener ) { | ||
return; | ||
} | ||
// add event | ||
this.on( eventName, listener ); | ||
// set once flag | ||
// set onceEvents hash | ||
var onceEvents = this._onceEvents = this._onceEvents || {}; | ||
// set onceListeners array | ||
var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || []; | ||
// set flag | ||
onceListeners[ listener ] = true; | ||
for (i = 0; i < listeners.length; i += 1) { | ||
flatListeners.push(listeners[i].listener); | ||
} | ||
return this; | ||
}; | ||
return flatListeners; | ||
}; | ||
proto.off = function( eventName, listener ) { | ||
var listeners = this._events && this._events[ eventName ]; | ||
if ( !listeners || !listeners.length ) { | ||
return; | ||
} | ||
var index = listeners.indexOf( listener ); | ||
if ( index != -1 ) { | ||
listeners.splice( index, 1 ); | ||
} | ||
/** | ||
* Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful. | ||
* | ||
* @param {String|RegExp} evt Name of the event to return the listeners from. | ||
* @return {Object} All listener functions for an event in an object. | ||
*/ | ||
proto.getListenersAsObject = function getListenersAsObject(evt) { | ||
var listeners = this.getListeners(evt); | ||
var response; | ||
return this; | ||
}; | ||
if (listeners instanceof Array) { | ||
response = {}; | ||
response[evt] = listeners; | ||
} | ||
proto.emitEvent = function( eventName, args ) { | ||
var listeners = this._events && this._events[ eventName ]; | ||
if ( !listeners || !listeners.length ) { | ||
return; | ||
} | ||
var i = 0; | ||
var listener = listeners[i]; | ||
args = args || []; | ||
// once stuff | ||
var onceListeners = this._onceEvents && this._onceEvents[ eventName ]; | ||
return response || listeners; | ||
}; | ||
while ( listener ) { | ||
var isOnce = onceListeners && onceListeners[ listener ]; | ||
if ( isOnce ) { | ||
// remove listener | ||
// remove before trigger to prevent recursion | ||
this.off( eventName, listener ); | ||
// unset once flag | ||
delete onceListeners[ listener ]; | ||
} | ||
// trigger listener | ||
listener.apply( this, args ); | ||
// get next listener | ||
i += isOnce ? 0 : 1; | ||
listener = listeners[i]; | ||
} | ||
/** | ||
* Adds a listener function to the specified event. | ||
* The listener will not be added if it is a duplicate. | ||
* If the listener returns true then it will be removed after it is called. | ||
* If you pass a regular expression as the event name then the listener will be added to all events that match it. | ||
* | ||
* @param {String|RegExp} evt Name of the event to attach the listener to. | ||
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.addListener = function addListener(evt, listener) { | ||
var listeners = this.getListenersAsObject(evt); | ||
var listenerIsWrapped = typeof listener === 'object'; | ||
var key; | ||
return this; | ||
}; | ||
for (key in listeners) { | ||
if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) { | ||
listeners[key].push(listenerIsWrapped ? listener : { | ||
listener: listener, | ||
once: false | ||
}); | ||
} | ||
} | ||
return EvEmitter; | ||
return this; | ||
}; | ||
})); | ||
/** | ||
* Alias of addListener | ||
*/ | ||
proto.on = alias('addListener'); | ||
/** | ||
* Semi-alias of addListener. It will add a listener that will be | ||
* automatically removed after its first execution. | ||
* | ||
* @param {String|RegExp} evt Name of the event to attach the listener to. | ||
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.addOnceListener = function addOnceListener(evt, listener) { | ||
return this.addListener(evt, { | ||
listener: listener, | ||
once: true | ||
}); | ||
}; | ||
/** | ||
* Alias of addOnceListener. | ||
*/ | ||
proto.once = alias('addOnceListener'); | ||
/** | ||
* Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad. | ||
* You need to tell it what event names should be matched by a regex. | ||
* | ||
* @param {String} evt Name of the event to create. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.defineEvent = function defineEvent(evt) { | ||
this.getListeners(evt); | ||
return this; | ||
}; | ||
/** | ||
* Uses defineEvent to define multiple events. | ||
* | ||
* @param {String[]} evts An array of event names to define. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.defineEvents = function defineEvents(evts) { | ||
for (var i = 0; i < evts.length; i += 1) { | ||
this.defineEvent(evts[i]); | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Removes a listener function from the specified event. | ||
* When passed a regular expression as the event name, it will remove the listener from all events that match it. | ||
* | ||
* @param {String|RegExp} evt Name of the event to remove the listener from. | ||
* @param {Function} listener Method to remove from the event. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.removeListener = function removeListener(evt, listener) { | ||
var listeners = this.getListenersAsObject(evt); | ||
var index; | ||
var key; | ||
for (key in listeners) { | ||
if (listeners.hasOwnProperty(key)) { | ||
index = indexOfListener(listeners[key], listener); | ||
if (index !== -1) { | ||
listeners[key].splice(index, 1); | ||
} | ||
} | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Alias of removeListener | ||
*/ | ||
proto.off = alias('removeListener'); | ||
/** | ||
* Adds listeners in bulk using the manipulateListeners method. | ||
* If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added. | ||
* You can also pass it a regular expression to add the array of listeners to all events that match it. | ||
* Yeah, this function does quite a bit. That's probably a bad thing. | ||
* | ||
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once. | ||
* @param {Function[]} [listeners] An optional array of listener functions to add. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.addListeners = function addListeners(evt, listeners) { | ||
// Pass through to manipulateListeners | ||
return this.manipulateListeners(false, evt, listeners); | ||
}; | ||
/** | ||
* Removes listeners in bulk using the manipulateListeners method. | ||
* If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. | ||
* You can also pass it an event name and an array of listeners to be removed. | ||
* You can also pass it a regular expression to remove the listeners from all events that match it. | ||
* | ||
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once. | ||
* @param {Function[]} [listeners] An optional array of listener functions to remove. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.removeListeners = function removeListeners(evt, listeners) { | ||
// Pass through to manipulateListeners | ||
return this.manipulateListeners(true, evt, listeners); | ||
}; | ||
/** | ||
* Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level. | ||
* The first argument will determine if the listeners are removed (true) or added (false). | ||
* If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. | ||
* You can also pass it an event name and an array of listeners to be added/removed. | ||
* You can also pass it a regular expression to manipulate the listeners of all events that match it. | ||
* | ||
* @param {Boolean} remove True if you want to remove listeners, false if you want to add. | ||
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once. | ||
* @param {Function[]} [listeners] An optional array of listener functions to add/remove. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) { | ||
var i; | ||
var value; | ||
var single = remove ? this.removeListener : this.addListener; | ||
var multiple = remove ? this.removeListeners : this.addListeners; | ||
// If evt is an object then pass each of its properties to this method | ||
if (typeof evt === 'object' && !(evt instanceof RegExp)) { | ||
for (i in evt) { | ||
if (evt.hasOwnProperty(i) && (value = evt[i])) { | ||
// Pass the single listener straight through to the singular method | ||
if (typeof value === 'function') { | ||
single.call(this, i, value); | ||
} | ||
else { | ||
// Otherwise pass back to the multiple function | ||
multiple.call(this, i, value); | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
// So evt must be a string | ||
// And listeners must be an array of listeners | ||
// Loop over it and pass each one to the multiple method | ||
i = listeners.length; | ||
while (i--) { | ||
single.call(this, evt, listeners[i]); | ||
} | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Removes all listeners from a specified event. | ||
* If you do not specify an event then all listeners will be removed. | ||
* That means every event will be emptied. | ||
* You can also pass a regex to remove all events that match it. | ||
* | ||
* @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.removeEvent = function removeEvent(evt) { | ||
var type = typeof evt; | ||
var events = this._getEvents(); | ||
var key; | ||
// Remove different things depending on the state of evt | ||
if (type === 'string') { | ||
// Remove all listeners for the specified event | ||
delete events[evt]; | ||
} | ||
else if (evt instanceof RegExp) { | ||
// Remove all events matching the regex. | ||
for (key in events) { | ||
if (events.hasOwnProperty(key) && evt.test(key)) { | ||
delete events[key]; | ||
} | ||
} | ||
} | ||
else { | ||
// Remove all listeners in all events | ||
delete this._events; | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Alias of removeEvent. | ||
* | ||
* Added to mirror the node API. | ||
*/ | ||
proto.removeAllListeners = alias('removeEvent'); | ||
/** | ||
* Emits an event of your choice. | ||
* When emitted, every listener attached to that event will be executed. | ||
* If you pass the optional argument array then those arguments will be passed to every listener upon execution. | ||
* Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately. | ||
* So they will not arrive within the array on the other side, they will be separate. | ||
* You can also pass a regular expression to emit to all events that match it. | ||
* | ||
* @param {String|RegExp} evt Name of the event to emit and execute listeners for. | ||
* @param {Array} [args] Optional array of arguments to be passed to each listener. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.emitEvent = function emitEvent(evt, args) { | ||
var listeners = this.getListenersAsObject(evt); | ||
var listener; | ||
var i; | ||
var key; | ||
var response; | ||
for (key in listeners) { | ||
if (listeners.hasOwnProperty(key)) { | ||
i = listeners[key].length; | ||
while (i--) { | ||
// If the listener returns true then it shall be removed from the event | ||
// The function is executed either with a basic call or an apply if there is an args array | ||
listener = listeners[key][i]; | ||
if (listener.once === true) { | ||
this.removeListener(evt, listener.listener); | ||
} | ||
response = listener.listener.apply(this, args || []); | ||
if (response === this._getOnceReturnValue()) { | ||
this.removeListener(evt, listener.listener); | ||
} | ||
} | ||
} | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Alias of emitEvent | ||
*/ | ||
proto.trigger = alias('emitEvent'); | ||
/** | ||
* Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on. | ||
* As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it. | ||
* | ||
* @param {String|RegExp} evt Name of the event to emit and execute listeners for. | ||
* @param {...*} Optional additional arguments to be passed to each listener. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.emit = function emit(evt) { | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
return this.emitEvent(evt, args); | ||
}; | ||
/** | ||
* Sets the current value to check against when executing listeners. If a | ||
* listeners return value matches the one set here then it will be removed | ||
* after execution. This value defaults to true. | ||
* | ||
* @param {*} value The new value to check for when executing listeners. | ||
* @return {Object} Current instance of EventEmitter for chaining. | ||
*/ | ||
proto.setOnceReturnValue = function setOnceReturnValue(value) { | ||
this._onceReturnValue = value; | ||
return this; | ||
}; | ||
/** | ||
* Fetches the current value to check against when executing listeners. If | ||
* the listeners return value matches this one then it should be removed | ||
* automatically. It will return true by default. | ||
* | ||
* @return {*|Boolean} The current value to check for or the default, true. | ||
* @api private | ||
*/ | ||
proto._getOnceReturnValue = function _getOnceReturnValue() { | ||
if (this.hasOwnProperty('_onceReturnValue')) { | ||
return this._onceReturnValue; | ||
} | ||
else { | ||
return true; | ||
} | ||
}; | ||
/** | ||
* Fetches the events object and creates one if required. | ||
* | ||
* @return {Object} The events storage object. | ||
* @api private | ||
*/ | ||
proto._getEvents = function _getEvents() { | ||
return this._events || (this._events = {}); | ||
}; | ||
/** | ||
* Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version. | ||
* | ||
* @return {Function} Non conflicting EventEmitter class. | ||
*/ | ||
EventEmitter.noConflict = function noConflict() { | ||
exports.EventEmitter = originalGlobalValue; | ||
return EventEmitter; | ||
}; | ||
// Expose the class either via AMD, CommonJS or the global object | ||
if (typeof define === 'function' && define.amd) { | ||
define('eventEmitter/EventEmitter',[],function () { | ||
return EventEmitter; | ||
}); | ||
} | ||
else if (typeof module === 'object' && module.exports){ | ||
module.exports = EventEmitter; | ||
} | ||
else { | ||
exports.EventEmitter = EventEmitter; | ||
} | ||
}.call(this)); | ||
/*! | ||
* Unipointer v2.0.0 | ||
* Unipointer v2.1.0 | ||
* base class for doing one thing with pointer event | ||
@@ -844,14 +481,12 @@ * MIT license | ||
/*jshint browser: true, undef: true, unused: true, strict: true */ | ||
/*global define: false, module: false, require: false */ | ||
( function( window, factory ) { | ||
// universal module definition | ||
/* jshint strict: false */ /*global define, module, require */ | ||
if ( typeof define == 'function' && define.amd ) { | ||
// AMD | ||
define( 'unipointer/unipointer',[ | ||
'eventEmitter/EventEmitter' | ||
], function( EventEmitter ) { | ||
return factory( window, EventEmitter ); | ||
'ev-emitter/ev-emitter' | ||
], function( EvEmitter ) { | ||
return factory( window, EvEmitter ); | ||
}); | ||
@@ -862,3 +497,3 @@ } else if ( typeof module == 'object' && module.exports ) { | ||
window, | ||
require('wolfy87-eventemitter') | ||
require('ev-emitter') | ||
); | ||
@@ -869,7 +504,7 @@ } else { | ||
window, | ||
window.EventEmitter | ||
window.EvEmitter | ||
); | ||
} | ||
}( window, function factory( window, EventEmitter ) { | ||
}( window, function factory( window, EvEmitter ) { | ||
@@ -882,4 +517,4 @@ | ||
// inherit EventEmitter | ||
var proto = Unipointer.prototype = Object.create( EventEmitter.prototype ); | ||
// inherit EvEmitter | ||
var proto = Unipointer.prototype = Object.create( EvEmitter.prototype ); | ||
@@ -1148,3 +783,3 @@ proto.bindStartEvent = function( elem ) { | ||
/*! | ||
* Unidragger v2.0.0 | ||
* Unidragger v2.1.0 | ||
* Draggable base class | ||
@@ -1157,5 +792,4 @@ * MIT license | ||
( function( window, factory ) { | ||
/*global define: false, module: false, require: false */ | ||
// universal module definition | ||
/*jshint strict: false */ /*globals define, module, require */ | ||
@@ -1195,3 +829,3 @@ if ( typeof define == 'function' && define.amd ) { | ||
// inherit Unipointer & EventEmitter | ||
// inherit Unipointer & EvEmitter | ||
var proto = Unidragger.prototype = Object.create( Unipointer.prototype ); | ||
@@ -1437,3 +1071,3 @@ | ||
/*! | ||
* Draggabilly v2.0.1 | ||
* Draggabilly v2.1.0 | ||
* Make that shiz draggable | ||
@@ -1444,5 +1078,7 @@ * http://draggabilly.desandro.com | ||
/*jshint browser: true, strict: true, undef: true, unused: true */ | ||
( function( window, factory ) { | ||
// universal module definition | ||
/* jshint strict: false */ /*globals define, module, require */ | ||
if ( typeof define == 'function' && define.amd ) { | ||
@@ -1457,3 +1093,3 @@ // AMD | ||
}); | ||
} else if ( typeof exports == 'object' ) { | ||
} else if ( typeof module == 'object' && module.exports ) { | ||
// CommonJS | ||
@@ -1499,10 +1135,8 @@ module.exports = factory( | ||
// https://gist.github.com/1866474 | ||
// get rAF and cAF, prefixed, if present | ||
// get rAF, prefixed, if present | ||
var requestAnimationFrame = window.requestAnimationFrame || | ||
window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame; | ||
// fallback to setTimeout | ||
var lastTime = 0; | ||
// fallback to setTimeout and clearTimeout if either request/cancel is not supported | ||
if ( !requestAnimationFrame ) { | ||
@@ -1512,5 +1146,3 @@ requestAnimationFrame = function( callback ) { | ||
var timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) ); | ||
var id = setTimeout( function() { | ||
callback( currTime + timeToCall ); | ||
}, timeToCall ); | ||
var id = setTimeout( callback, timeToCall ); | ||
lastTime = currTime + timeToCall; | ||
@@ -1523,9 +1155,5 @@ return id; | ||
var transformProperty = ( function () { | ||
var style = document.documentElement.style; | ||
if ( typeof style.transform == 'string' ) { | ||
return 'transform'; | ||
} | ||
return 'WebkitTransform'; | ||
})(); | ||
var docElem = document.documentElement; | ||
var transformProperty = typeof docElem.style.transform == 'string' ? | ||
'transform' : 'WebkitTransform'; | ||
@@ -1599,3 +1227,3 @@ var jQuery = window.jQuery; | ||
/** | ||
* emits events via eventEmitter and jQuery events | ||
* emits events via EvEmitter and jQuery events | ||
* @param {String} type - name of event | ||
@@ -1625,10 +1253,7 @@ * @param {Event} event - original event | ||
// get left/top position from style | ||
proto._getPosition = function() { | ||
// properties | ||
// get x/y position from style | ||
Draggabilly.prototype._getPosition = function() { | ||
var style = getComputedStyle( this.element ); | ||
var x = parseInt( style.left, 10 ); | ||
var y = parseInt( style.top, 10 ); | ||
var x = this._getPositionCoord( style.left, 'width' ); | ||
var y = this._getPositionCoord( style.top, 'height' ); | ||
// clean up 'auto' or other non-integer values | ||
@@ -1641,2 +1266,12 @@ this.position.x = isNaN( x ) ? 0 : x; | ||
Draggabilly.prototype._getPositionCoord = function( styleSide, measure ) { | ||
if ( styleSide.indexOf('%') != -1 ) { | ||
// convert percent into pixel for Safari, #75 | ||
var parentSize = getSize( this.element.parentNode ); | ||
return ( parseFloat( styleSide ) / 100 ) * parentSize[ measure ]; | ||
} | ||
return parseInt( styleSide, 10 ); | ||
}; | ||
// add transform: translate( x, y ) to position | ||
@@ -1643,0 +1278,0 @@ proto._addTransformPosition = function( style ) { |
/*! | ||
* Draggabilly PACKAGED v2.0.1 | ||
* Draggabilly PACKAGED v2.1.0 | ||
* Make that shiz draggable | ||
@@ -8,2 +8,2 @@ * http://draggabilly.desandro.com | ||
!function(t,e){"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(n){e(t,n)}):"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,function(t,e){function n(n,r,a){function h(t,e,i){var o,r="$()."+n+'("'+e+'")';return t.each(function(t,h){var d=a.data(h,n);if(!d)return void s(n+" not initialized. Cannot call methods, i.e. "+r);var u=d[e];if(!u||"_"==e.charAt(0))return void s(r+" is not a valid method");var c=u.apply(d,i);o=void 0===o?c:o}),void 0!==o?o:t}function d(t,e){t.each(function(t,i){var o=a.data(i,n);o?(o.option(e),o._init()):(o=new r(i,e),a.data(i,n,o))})}a=a||e||t.jQuery,a&&(r.prototype.option||(r.prototype.option=function(t){a.isPlainObject(t)&&(this.options=a.extend(!0,this.options,t))}),a.fn[n]=function(t){if("string"==typeof t){var e=o.call(arguments,1);return h(this,t,e)}return d(this,t),this},i(a))}function i(t){!t||t&&t.bridget||(t.bridget=n)}var o=Array.prototype.slice,r=t.console,s="undefined"==typeof r?function(){}:function(t){r.error(t)};return i(e||t.jQuery),n}),function(t,e){"function"==typeof define&&define.amd?define("get-size/get-size",[],function(){return e()}):"object"==typeof module&&module.exports?module.exports=e():t.getSize=e()}(window,function(){function t(t){var e=parseFloat(t),n=-1==t.indexOf("%")&&!isNaN(e);return n&&e}function e(){}function n(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},e=0;d>e;e++){var n=h[e];t[n]=0}return t}function i(t){var e=getComputedStyle(t);return e||a("Style returned "+e+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),e}function o(){if(!u){u=!0;var e=document.createElement("div");e.style.width="200px",e.style.padding="1px 2px 3px 4px",e.style.borderStyle="solid",e.style.borderWidth="1px 2px 3px 4px",e.style.boxSizing="border-box";var n=document.body||document.documentElement;n.appendChild(e);var o=i(e);r.isBoxSizeOuter=s=200==t(o.width),n.removeChild(e)}}function r(e){if(o(),"string"==typeof e&&(e=document.querySelector(e)),e&&"object"==typeof e&&e.nodeType){var r=i(e);if("none"==r.display)return n();var a={};a.width=e.offsetWidth,a.height=e.offsetHeight;for(var u=a.isBorderBox="border-box"==r.boxSizing,c=0;d>c;c++){var f=h[c],p=r[f],l=parseFloat(p);a[f]=isNaN(l)?0:l}var g=a.paddingLeft+a.paddingRight,v=a.paddingTop+a.paddingBottom,m=a.marginLeft+a.marginRight,y=a.marginTop+a.marginBottom,E=a.borderLeftWidth+a.borderRightWidth,b=a.borderTopWidth+a.borderBottomWidth,P=u&&s,_=t(r.width);_!==!1&&(a.width=_+(P?0:g+E));var x=t(r.height);return x!==!1&&(a.height=x+(P?0:v+b)),a.innerWidth=a.width-(g+E),a.innerHeight=a.height-(v+b),a.outerWidth=a.width+m,a.outerHeight=a.height+y,a}}var s,a="undefined"==typeof console?e:function(t){console.error(t)},h=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],d=h.length,u=!1;return r}),function(){function t(){}function e(t,e){for(var n=t.length;n--;)if(t[n].listener===e)return n;return-1}function n(t){return function(){return this[t].apply(this,arguments)}}var i=t.prototype,o=this,r=o.EventEmitter;i.getListeners=function(t){var e,n,i=this._getEvents();if(t instanceof RegExp){e={};for(n in i)i.hasOwnProperty(n)&&t.test(n)&&(e[n]=i[n])}else e=i[t]||(i[t]=[]);return e},i.flattenListeners=function(t){var e,n=[];for(e=0;e<t.length;e+=1)n.push(t[e].listener);return n},i.getListenersAsObject=function(t){var e,n=this.getListeners(t);return n instanceof Array&&(e={},e[t]=n),e||n},i.addListener=function(t,n){var i,o=this.getListenersAsObject(t),r="object"==typeof n;for(i in o)o.hasOwnProperty(i)&&-1===e(o[i],n)&&o[i].push(r?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(t,e){return this.addListener(t,{listener:e,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(t){return this.getListeners(t),this},i.defineEvents=function(t){for(var e=0;e<t.length;e+=1)this.defineEvent(t[e]);return this},i.removeListener=function(t,n){var i,o,r=this.getListenersAsObject(t);for(o in r)r.hasOwnProperty(o)&&(i=e(r[o],n),-1!==i&&r[o].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(t,e){return this.manipulateListeners(!1,t,e)},i.removeListeners=function(t,e){return this.manipulateListeners(!0,t,e)},i.manipulateListeners=function(t,e,n){var i,o,r=t?this.removeListener:this.addListener,s=t?this.removeListeners:this.addListeners;if("object"!=typeof e||e instanceof RegExp)for(i=n.length;i--;)r.call(this,e,n[i]);else for(i in e)e.hasOwnProperty(i)&&(o=e[i])&&("function"==typeof o?r.call(this,i,o):s.call(this,i,o));return this},i.removeEvent=function(t){var e,n=typeof t,i=this._getEvents();if("string"===n)delete i[t];else if(t instanceof RegExp)for(e in i)i.hasOwnProperty(e)&&t.test(e)&&delete i[e];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(t,e){var n,i,o,r,s=this.getListenersAsObject(t);for(o in s)if(s.hasOwnProperty(o))for(i=s[o].length;i--;)n=s[o][i],n.once===!0&&this.removeListener(t,n.listener),r=n.listener.apply(this,e||[]),r===this._getOnceReturnValue()&&this.removeListener(t,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(t){var e=Array.prototype.slice.call(arguments,1);return this.emitEvent(t,e)},i.setOnceReturnValue=function(t){return this._onceReturnValue=t,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return o.EventEmitter=r,t},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return t}):"object"==typeof module&&module.exports?module.exports=t:o.EventEmitter=t}.call(this),function(t,e){"function"==typeof define&&define.amd?define("unipointer/unipointer",["eventEmitter/EventEmitter"],function(n){return e(t,n)}):"object"==typeof module&&module.exports?module.exports=e(t,require("wolfy87-eventemitter")):t.Unipointer=e(t,t.EventEmitter)}(window,function(t,e){function n(){}function i(){}var o=i.prototype=Object.create(e.prototype);o.bindStartEvent=function(t){this._bindStartEvent(t,!0)},o.unbindStartEvent=function(t){this._bindStartEvent(t,!1)},o._bindStartEvent=function(e,n){n=void 0===n?!0:!!n;var i=n?"addEventListener":"removeEventListener";t.navigator.pointerEnabled?e[i]("pointerdown",this):t.navigator.msPointerEnabled?e[i]("MSPointerDown",this):(e[i]("mousedown",this),e[i]("touchstart",this))},o.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},o.getTouch=function(t){for(var e=0;e<t.length;e++){var n=t[e];if(n.identifier==this.pointerIdentifier)return n}},o.onmousedown=function(t){var e=t.button;e&&0!==e&&1!==e||this._pointerDown(t,t)},o.ontouchstart=function(t){this._pointerDown(t,t.changedTouches[0])},o.onMSPointerDown=o.onpointerdown=function(t){this._pointerDown(t,t)},o._pointerDown=function(t,e){this.isPointerDown||(this.isPointerDown=!0,this.pointerIdentifier=void 0!==e.pointerId?e.pointerId:e.identifier,this.pointerDown(t,e))},o.pointerDown=function(t,e){this._bindPostStartEvents(t),this.emitEvent("pointerDown",[t,e])};var r={mousedown:["mousemove","mouseup"],touchstart:["touchmove","touchend","touchcancel"],pointerdown:["pointermove","pointerup","pointercancel"],MSPointerDown:["MSPointerMove","MSPointerUp","MSPointerCancel"]};return o._bindPostStartEvents=function(e){if(e){var n=r[e.type];n.forEach(function(e){t.addEventListener(e,this)},this),this._boundPointerEvents=n}},o._unbindPostStartEvents=function(){this._boundPointerEvents&&(this._boundPointerEvents.forEach(function(e){t.removeEventListener(e,this)},this),delete this._boundPointerEvents)},o.onmousemove=function(t){this._pointerMove(t,t)},o.onMSPointerMove=o.onpointermove=function(t){t.pointerId==this.pointerIdentifier&&this._pointerMove(t,t)},o.ontouchmove=function(t){var e=this.getTouch(t.changedTouches);e&&this._pointerMove(t,e)},o._pointerMove=function(t,e){this.pointerMove(t,e)},o.pointerMove=function(t,e){this.emitEvent("pointerMove",[t,e])},o.onmouseup=function(t){this._pointerUp(t,t)},o.onMSPointerUp=o.onpointerup=function(t){t.pointerId==this.pointerIdentifier&&this._pointerUp(t,t)},o.ontouchend=function(t){var e=this.getTouch(t.changedTouches);e&&this._pointerUp(t,e)},o._pointerUp=function(t,e){this._pointerDone(),this.pointerUp(t,e)},o.pointerUp=function(t,e){this.emitEvent("pointerUp",[t,e])},o._pointerDone=function(){this.isPointerDown=!1,delete this.pointerIdentifier,this._unbindPostStartEvents(),this.pointerDone()},o.pointerDone=n,o.onMSPointerCancel=o.onpointercancel=function(t){t.pointerId==this.pointerIdentifier&&this._pointerCancel(t,t)},o.ontouchcancel=function(t){var e=this.getTouch(t.changedTouches);e&&this._pointerCancel(t,e)},o._pointerCancel=function(t,e){this._pointerDone(),this.pointerCancel(t,e)},o.pointerCancel=function(t,e){this.emitEvent("pointerCancel",[t,e])},i.getPointerPoint=function(t){return{x:t.pageX,y:t.pageY}},i}),function(t,e){"function"==typeof define&&define.amd?define("unidragger/unidragger",["unipointer/unipointer"],function(n){return e(t,n)}):"object"==typeof module&&module.exports?module.exports=e(t,require("unipointer")):t.Unidragger=e(t,t.Unipointer)}(window,function(t,e){function n(){}function i(){}var o=i.prototype=Object.create(e.prototype);o.bindHandles=function(){this._bindHandles(!0)},o.unbindHandles=function(){this._bindHandles(!1)};var r=t.navigator;return o._bindHandles=function(t){t=void 0===t?!0:!!t;var e;e=r.pointerEnabled?function(e){e.style.touchAction=t?"none":""}:r.msPointerEnabled?function(e){e.style.msTouchAction=t?"none":""}:n;for(var i=t?"addEventListener":"removeEventListener",o=0;o<this.handles.length;o++){var s=this.handles[o];this._bindStartEvent(s,t),e(s),s[i]("click",this)}},o.pointerDown=function(t,e){if("INPUT"==t.target.nodeName&&"range"==t.target.type)return this.isPointerDown=!1,void delete this.pointerIdentifier;this._dragPointerDown(t,e);var n=document.activeElement;n&&n.blur&&n.blur(),this._bindPostStartEvents(t),this.emitEvent("pointerDown",[t,e])},o._dragPointerDown=function(t,n){this.pointerDownPoint=e.getPointerPoint(n);var i=this.canPreventDefaultOnPointerDown(t,n);i&&t.preventDefault()},o.canPreventDefaultOnPointerDown=function(t){return"SELECT"!=t.target.nodeName},o.pointerMove=function(t,e){var n=this._dragPointerMove(t,e);this.emitEvent("pointerMove",[t,e,n]),this._dragMove(t,e,n)},o._dragPointerMove=function(t,n){var i=e.getPointerPoint(n),o={x:i.x-this.pointerDownPoint.x,y:i.y-this.pointerDownPoint.y};return!this.isDragging&&this.hasDragStarted(o)&&this._dragStart(t,n),o},o.hasDragStarted=function(t){return Math.abs(t.x)>3||Math.abs(t.y)>3},o.pointerUp=function(t,e){this.emitEvent("pointerUp",[t,e]),this._dragPointerUp(t,e)},o._dragPointerUp=function(t,e){this.isDragging?this._dragEnd(t,e):this._staticClick(t,e)},o._dragStart=function(t,n){this.isDragging=!0,this.dragStartPoint=e.getPointerPoint(n),this.isPreventingClicks=!0,this.dragStart(t,n)},o.dragStart=function(t,e){this.emitEvent("dragStart",[t,e])},o._dragMove=function(t,e,n){this.isDragging&&this.dragMove(t,e,n)},o.dragMove=function(t,e,n){t.preventDefault(),this.emitEvent("dragMove",[t,e,n])},o._dragEnd=function(t,e){this.isDragging=!1,setTimeout(function(){delete this.isPreventingClicks}.bind(this)),this.dragEnd(t,e)},o.dragEnd=function(t,e){this.emitEvent("dragEnd",[t,e])},o.onclick=function(t){this.isPreventingClicks&&t.preventDefault()},o._staticClick=function(t,e){if(!this.isIgnoringMouseUp||"mouseup"!=t.type){var n=t.target.nodeName;("INPUT"==n||"TEXTAREA"==n)&&t.target.focus(),this.staticClick(t,e),"mouseup"!=t.type&&(this.isIgnoringMouseUp=!0,setTimeout(function(){delete this.isIgnoringMouseUp}.bind(this),400))}},o.staticClick=function(t,e){this.emitEvent("staticClick",[t,e])},i.getPointerPoint=e.getPointerPoint,i}),function(t,e){"function"==typeof define&&define.amd?define(["get-size/get-size","unidragger/unidragger"],function(n,i){return e(t,n,i)}):"object"==typeof exports?module.exports=e(t,require("get-size"),require("unidragger")):t.Draggabilly=e(t,t.getSize,t.Unidragger)}(window,function(t,e,n){function i(){}function o(t,e){for(var n in e)t[n]=e[n];return t}function r(t){return t instanceof HTMLElement}function s(t,e){this.element="string"==typeof t?h.querySelector(t):t,f&&(this.$element=f(this.element)),this.options=o({},this.constructor.defaults),this.option(e),this._create()}function a(t,e,n){return n=n||"round",e?Math[n](t/e)*e:t}var h=t.document,d=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame,u=0;d||(d=function(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-u)),i=setTimeout(function(){t(e+n)},n);return u=e+n,i});var c=function(){var t=h.documentElement.style;return"string"==typeof t.transform?"transform":"WebkitTransform"}(),f=t.jQuery,p=s.prototype=Object.create(n.prototype);return s.defaults={},p.option=function(t){o(this.options,t)},p._create=function(){this.position={},this._getPosition(),this.startPoint={x:0,y:0},this.dragPoint={x:0,y:0},this.startPosition=o({},this.position);var t=getComputedStyle(this.element);"relative"!=t.position&&"absolute"!=t.position&&(this.element.style.position="relative"),this.enable(),this.setHandles()},p.setHandles=function(){this.handles=this.options.handle?this.element.querySelectorAll(this.options.handle):[this.element],this.bindHandles()},p.dispatchEvent=function(e,n,i){var o=[n].concat(i);this.emitEvent(e,o);var r=t.jQuery;if(r&&this.$element)if(n){var s=r.Event(n);s.type=e,this.$element.trigger(s,i)}else this.$element.trigger(e,i)},p._getPosition=function(){var t=getComputedStyle(this.element),e=parseInt(t.left,10),n=parseInt(t.top,10);this.position.x=isNaN(e)?0:e,this.position.y=isNaN(n)?0:n,this._addTransformPosition(t)},p._addTransformPosition=function(t){var e=t[c];if(0===e.indexOf("matrix")){var n=e.split(","),i=0===e.indexOf("matrix3d")?12:4,o=parseInt(n[i],10),r=parseInt(n[i+1],10);this.position.x+=o,this.position.y+=r}},p.pointerDown=function(t,e){this._dragPointerDown(t,e);var n=h.activeElement;n&&n.blur&&n!=h.body&&n.blur(),this._bindPostStartEvents(t),this.element.classList.add("is-pointer-down"),this.dispatchEvent("pointerDown",t,[e])},p.pointerMove=function(t,e){var n=this._dragPointerMove(t,e);this.dispatchEvent("pointerMove",t,[e,n]),this._dragMove(t,e,n)},p.dragStart=function(t,e){this.isEnabled&&(this._getPosition(),this.measureContainment(),this.startPosition.x=this.position.x,this.startPosition.y=this.position.y,this.setLeftTop(),this.dragPoint.x=0,this.dragPoint.y=0,this.element.classList.add("is-dragging"),this.dispatchEvent("dragStart",t,[e]),this.animate())},p.measureContainment=function(){var t=this.options.containment;if(t){var n=r(t)?t:"string"==typeof t?h.querySelector(t):this.element.parentNode,i=e(this.element),o=e(n),s=this.element.getBoundingClientRect(),a=n.getBoundingClientRect(),d=o.borderLeftWidth+o.borderRightWidth,u=o.borderTopWidth+o.borderBottomWidth,c=this.relativeStartPosition={x:s.left-(a.left+o.borderLeftWidth),y:s.top-(a.top+o.borderTopWidth)};this.containSize={width:o.width-d-c.x-i.width,height:o.height-u-c.y-i.height}}},p.dragMove=function(t,e,n){if(this.isEnabled){var i=n.x,o=n.y,r=this.options.grid,s=r&&r[0],h=r&&r[1];i=a(i,s),o=a(o,h),i=this.containDrag("x",i,s),o=this.containDrag("y",o,h),i="y"==this.options.axis?0:i,o="x"==this.options.axis?0:o,this.position.x=this.startPosition.x+i,this.position.y=this.startPosition.y+o,this.dragPoint.x=i,this.dragPoint.y=o,this.dispatchEvent("dragMove",t,[e,n])}},p.containDrag=function(t,e,n){if(!this.options.containment)return e;var i="x"==t?"width":"height",o=this.relativeStartPosition[t],r=a(-o,n,"ceil"),s=this.containSize[i];return s=a(s,n,"floor"),Math.min(s,Math.max(r,e))},p.pointerUp=function(t,e){this.element.classList.remove("is-pointer-down"),this.dispatchEvent("pointerUp",t,[e]),this._dragPointerUp(t,e)},p.dragEnd=function(t,e){this.isEnabled&&(c&&(this.element.style[c]="",this.setLeftTop()),this.element.classList.remove("is-dragging"),this.dispatchEvent("dragEnd",t,[e]))},p.animate=function(){if(this.isDragging){this.positionDrag();var t=this;d(function(){t.animate()})}},p.setLeftTop=function(){this.element.style.left=this.position.x+"px",this.element.style.top=this.position.y+"px"},p.positionDrag=function(){this.element.style[c]="translate3d( "+this.dragPoint.x+"px, "+this.dragPoint.y+"px, 0)"},p.staticClick=function(t,e){this.dispatchEvent("staticClick",t,[e])},p.enable=function(){this.isEnabled=!0},p.disable=function(){this.isEnabled=!1,this.isDragging&&this.dragEnd()},p.destroy=function(){this.disable(),this.element.style[c]="",this.element.style.left="",this.element.style.top="",this.element.style.position="",this.unbindHandles(),this.$element&&this.$element.removeData("draggabilly")},p._init=i,f&&f.bridget&&f.bridget("draggabilly",s),s}); | ||
!function(t,i){"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(e){i(t,e)}):"object"==typeof module&&module.exports?module.exports=i(t,require("jquery")):t.jQueryBridget=i(t,t.jQuery)}(window,function(t,i){function e(e,r,a){function h(t,i,n){var o,r="$()."+e+'("'+i+'")';return t.each(function(t,h){var d=a.data(h,e);if(!d)return void s(e+" not initialized. Cannot call methods, i.e. "+r);var u=d[i];if(!u||"_"==i.charAt(0))return void s(r+" is not a valid method");var p=u.apply(d,n);o=void 0===o?p:o}),void 0!==o?o:t}function d(t,i){t.each(function(t,n){var o=a.data(n,e);o?(o.option(i),o._init()):(o=new r(n,i),a.data(n,e,o))})}a=a||i||t.jQuery,a&&(r.prototype.option||(r.prototype.option=function(t){a.isPlainObject(t)&&(this.options=a.extend(!0,this.options,t))}),a.fn[e]=function(t){if("string"==typeof t){var i=o.call(arguments,1);return h(this,t,i)}return d(this,t),this},n(a))}function n(t){!t||t&&t.bridget||(t.bridget=e)}var o=Array.prototype.slice,r=t.console,s="undefined"==typeof r?function(){}:function(t){r.error(t)};return n(i||t.jQuery),e}),function(t,i){"function"==typeof define&&define.amd?define("get-size/get-size",[],function(){return i()}):"object"==typeof module&&module.exports?module.exports=i():t.getSize=i()}(window,function(){function t(t){var i=parseFloat(t),e=-1==t.indexOf("%")&&!isNaN(i);return e&&i}function i(){}function e(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},i=0;d>i;i++){var e=h[i];t[e]=0}return t}function n(t){var i=getComputedStyle(t);return i||a("Style returned "+i+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),i}function o(){if(!u){u=!0;var i=document.createElement("div");i.style.width="200px",i.style.padding="1px 2px 3px 4px",i.style.borderStyle="solid",i.style.borderWidth="1px 2px 3px 4px",i.style.boxSizing="border-box";var e=document.body||document.documentElement;e.appendChild(i);var o=n(i);r.isBoxSizeOuter=s=200==t(o.width),e.removeChild(i)}}function r(i){if(o(),"string"==typeof i&&(i=document.querySelector(i)),i&&"object"==typeof i&&i.nodeType){var r=n(i);if("none"==r.display)return e();var a={};a.width=i.offsetWidth,a.height=i.offsetHeight;for(var u=a.isBorderBox="border-box"==r.boxSizing,p=0;d>p;p++){var c=h[p],f=r[c],g=parseFloat(f);a[c]=isNaN(g)?0:g}var l=a.paddingLeft+a.paddingRight,v=a.paddingTop+a.paddingBottom,m=a.marginLeft+a.marginRight,y=a.marginTop+a.marginBottom,b=a.borderLeftWidth+a.borderRightWidth,P=a.borderTopWidth+a.borderBottomWidth,E=u&&s,_=t(r.width);_!==!1&&(a.width=_+(E?0:l+b));var x=t(r.height);return x!==!1&&(a.height=x+(E?0:v+P)),a.innerWidth=a.width-(l+b),a.innerHeight=a.height-(v+P),a.outerWidth=a.width+m,a.outerHeight=a.height+y,a}}var s,a="undefined"==typeof console?i:function(t){console.error(t)},h=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],d=h.length,u=!1;return r}),function(t,i){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",i):"object"==typeof module&&module.exports?module.exports=i():t.EvEmitter=i()}(this,function(){function t(){}var i=t.prototype;return i.on=function(t,i){if(t&&i){var e=this._events=this._events||{},n=e[t]=e[t]||[];return-1==n.indexOf(i)&&n.push(i),this}},i.once=function(t,i){if(t&&i){this.on(t,i);var e=this._onceEvents=this._onceEvents||{},n=e[t]=e[t]||[];return n[i]=!0,this}},i.off=function(t,i){var e=this._events&&this._events[t];if(e&&e.length){var n=e.indexOf(i);return-1!=n&&e.splice(n,1),this}},i.emitEvent=function(t,i){var e=this._events&&this._events[t];if(e&&e.length){var n=0,o=e[n];i=i||[];for(var r=this._onceEvents&&this._onceEvents[t];o;){var s=r&&r[o];s&&(this.off(t,o),delete r[o]),o.apply(this,i),n+=s?0:1,o=e[n]}return this}},t}),function(t,i){"function"==typeof define&&define.amd?define("unipointer/unipointer",["ev-emitter/ev-emitter"],function(e){return i(t,e)}):"object"==typeof module&&module.exports?module.exports=i(t,require("ev-emitter")):t.Unipointer=i(t,t.EvEmitter)}(window,function(t,i){function e(){}function n(){}var o=n.prototype=Object.create(i.prototype);o.bindStartEvent=function(t){this._bindStartEvent(t,!0)},o.unbindStartEvent=function(t){this._bindStartEvent(t,!1)},o._bindStartEvent=function(i,e){e=void 0===e?!0:!!e;var n=e?"addEventListener":"removeEventListener";t.navigator.pointerEnabled?i[n]("pointerdown",this):t.navigator.msPointerEnabled?i[n]("MSPointerDown",this):(i[n]("mousedown",this),i[n]("touchstart",this))},o.handleEvent=function(t){var i="on"+t.type;this[i]&&this[i](t)},o.getTouch=function(t){for(var i=0;i<t.length;i++){var e=t[i];if(e.identifier==this.pointerIdentifier)return e}},o.onmousedown=function(t){var i=t.button;i&&0!==i&&1!==i||this._pointerDown(t,t)},o.ontouchstart=function(t){this._pointerDown(t,t.changedTouches[0])},o.onMSPointerDown=o.onpointerdown=function(t){this._pointerDown(t,t)},o._pointerDown=function(t,i){this.isPointerDown||(this.isPointerDown=!0,this.pointerIdentifier=void 0!==i.pointerId?i.pointerId:i.identifier,this.pointerDown(t,i))},o.pointerDown=function(t,i){this._bindPostStartEvents(t),this.emitEvent("pointerDown",[t,i])};var r={mousedown:["mousemove","mouseup"],touchstart:["touchmove","touchend","touchcancel"],pointerdown:["pointermove","pointerup","pointercancel"],MSPointerDown:["MSPointerMove","MSPointerUp","MSPointerCancel"]};return o._bindPostStartEvents=function(i){if(i){var e=r[i.type];e.forEach(function(i){t.addEventListener(i,this)},this),this._boundPointerEvents=e}},o._unbindPostStartEvents=function(){this._boundPointerEvents&&(this._boundPointerEvents.forEach(function(i){t.removeEventListener(i,this)},this),delete this._boundPointerEvents)},o.onmousemove=function(t){this._pointerMove(t,t)},o.onMSPointerMove=o.onpointermove=function(t){t.pointerId==this.pointerIdentifier&&this._pointerMove(t,t)},o.ontouchmove=function(t){var i=this.getTouch(t.changedTouches);i&&this._pointerMove(t,i)},o._pointerMove=function(t,i){this.pointerMove(t,i)},o.pointerMove=function(t,i){this.emitEvent("pointerMove",[t,i])},o.onmouseup=function(t){this._pointerUp(t,t)},o.onMSPointerUp=o.onpointerup=function(t){t.pointerId==this.pointerIdentifier&&this._pointerUp(t,t)},o.ontouchend=function(t){var i=this.getTouch(t.changedTouches);i&&this._pointerUp(t,i)},o._pointerUp=function(t,i){this._pointerDone(),this.pointerUp(t,i)},o.pointerUp=function(t,i){this.emitEvent("pointerUp",[t,i])},o._pointerDone=function(){this.isPointerDown=!1,delete this.pointerIdentifier,this._unbindPostStartEvents(),this.pointerDone()},o.pointerDone=e,o.onMSPointerCancel=o.onpointercancel=function(t){t.pointerId==this.pointerIdentifier&&this._pointerCancel(t,t)},o.ontouchcancel=function(t){var i=this.getTouch(t.changedTouches);i&&this._pointerCancel(t,i)},o._pointerCancel=function(t,i){this._pointerDone(),this.pointerCancel(t,i)},o.pointerCancel=function(t,i){this.emitEvent("pointerCancel",[t,i])},n.getPointerPoint=function(t){return{x:t.pageX,y:t.pageY}},n}),function(t,i){"function"==typeof define&&define.amd?define("unidragger/unidragger",["unipointer/unipointer"],function(e){return i(t,e)}):"object"==typeof module&&module.exports?module.exports=i(t,require("unipointer")):t.Unidragger=i(t,t.Unipointer)}(window,function(t,i){function e(){}function n(){}var o=n.prototype=Object.create(i.prototype);o.bindHandles=function(){this._bindHandles(!0)},o.unbindHandles=function(){this._bindHandles(!1)};var r=t.navigator;return o._bindHandles=function(t){t=void 0===t?!0:!!t;var i;i=r.pointerEnabled?function(i){i.style.touchAction=t?"none":""}:r.msPointerEnabled?function(i){i.style.msTouchAction=t?"none":""}:e;for(var n=t?"addEventListener":"removeEventListener",o=0;o<this.handles.length;o++){var s=this.handles[o];this._bindStartEvent(s,t),i(s),s[n]("click",this)}},o.pointerDown=function(t,i){if("INPUT"==t.target.nodeName&&"range"==t.target.type)return this.isPointerDown=!1,void delete this.pointerIdentifier;this._dragPointerDown(t,i);var e=document.activeElement;e&&e.blur&&e.blur(),this._bindPostStartEvents(t),this.emitEvent("pointerDown",[t,i])},o._dragPointerDown=function(t,e){this.pointerDownPoint=i.getPointerPoint(e);var n=this.canPreventDefaultOnPointerDown(t,e);n&&t.preventDefault()},o.canPreventDefaultOnPointerDown=function(t){return"SELECT"!=t.target.nodeName},o.pointerMove=function(t,i){var e=this._dragPointerMove(t,i);this.emitEvent("pointerMove",[t,i,e]),this._dragMove(t,i,e)},o._dragPointerMove=function(t,e){var n=i.getPointerPoint(e),o={x:n.x-this.pointerDownPoint.x,y:n.y-this.pointerDownPoint.y};return!this.isDragging&&this.hasDragStarted(o)&&this._dragStart(t,e),o},o.hasDragStarted=function(t){return Math.abs(t.x)>3||Math.abs(t.y)>3},o.pointerUp=function(t,i){this.emitEvent("pointerUp",[t,i]),this._dragPointerUp(t,i)},o._dragPointerUp=function(t,i){this.isDragging?this._dragEnd(t,i):this._staticClick(t,i)},o._dragStart=function(t,e){this.isDragging=!0,this.dragStartPoint=i.getPointerPoint(e),this.isPreventingClicks=!0,this.dragStart(t,e)},o.dragStart=function(t,i){this.emitEvent("dragStart",[t,i])},o._dragMove=function(t,i,e){this.isDragging&&this.dragMove(t,i,e)},o.dragMove=function(t,i,e){t.preventDefault(),this.emitEvent("dragMove",[t,i,e])},o._dragEnd=function(t,i){this.isDragging=!1,setTimeout(function(){delete this.isPreventingClicks}.bind(this)),this.dragEnd(t,i)},o.dragEnd=function(t,i){this.emitEvent("dragEnd",[t,i])},o.onclick=function(t){this.isPreventingClicks&&t.preventDefault()},o._staticClick=function(t,i){if(!this.isIgnoringMouseUp||"mouseup"!=t.type){var e=t.target.nodeName;("INPUT"==e||"TEXTAREA"==e)&&t.target.focus(),this.staticClick(t,i),"mouseup"!=t.type&&(this.isIgnoringMouseUp=!0,setTimeout(function(){delete this.isIgnoringMouseUp}.bind(this),400))}},o.staticClick=function(t,i){this.emitEvent("staticClick",[t,i])},n.getPointerPoint=i.getPointerPoint,n}),function(t,i){"function"==typeof define&&define.amd?define(["get-size/get-size","unidragger/unidragger"],function(e,n){return i(t,e,n)}):"object"==typeof module&&module.exports?module.exports=i(t,require("get-size"),require("unidragger")):t.Draggabilly=i(t,t.getSize,t.Unidragger)}(window,function(t,i,e){function n(){}function o(t,i){for(var e in i)t[e]=i[e];return t}function r(t){return t instanceof HTMLElement}function s(t,i){this.element="string"==typeof t?h.querySelector(t):t,f&&(this.$element=f(this.element)),this.options=o({},this.constructor.defaults),this.option(i),this._create()}function a(t,i,e){return e=e||"round",i?Math[e](t/i)*i:t}var h=t.document,d=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame,u=0;d||(d=function(t){var i=(new Date).getTime(),e=Math.max(0,16-(i-u)),n=setTimeout(t,e);return u=i+e,n});var p=h.documentElement,c="string"==typeof p.style.transform?"transform":"WebkitTransform",f=t.jQuery,g=s.prototype=Object.create(e.prototype);return s.defaults={},g.option=function(t){o(this.options,t)},g._create=function(){this.position={},this._getPosition(),this.startPoint={x:0,y:0},this.dragPoint={x:0,y:0},this.startPosition=o({},this.position);var t=getComputedStyle(this.element);"relative"!=t.position&&"absolute"!=t.position&&(this.element.style.position="relative"),this.enable(),this.setHandles()},g.setHandles=function(){this.handles=this.options.handle?this.element.querySelectorAll(this.options.handle):[this.element],this.bindHandles()},g.dispatchEvent=function(i,e,n){var o=[e].concat(n);this.emitEvent(i,o);var r=t.jQuery;if(r&&this.$element)if(e){var s=r.Event(e);s.type=i,this.$element.trigger(s,n)}else this.$element.trigger(i,n)},s.prototype._getPosition=function(){var t=getComputedStyle(this.element),i=this._getPositionCoord(t.left,"width"),e=this._getPositionCoord(t.top,"height");this.position.x=isNaN(i)?0:i,this.position.y=isNaN(e)?0:e,this._addTransformPosition(t)},s.prototype._getPositionCoord=function(t,e){if(-1!=t.indexOf("%")){var n=i(this.element.parentNode);return parseFloat(t)/100*n[e]}return parseInt(t,10)},g._addTransformPosition=function(t){var i=t[c];if(0===i.indexOf("matrix")){var e=i.split(","),n=0===i.indexOf("matrix3d")?12:4,o=parseInt(e[n],10),r=parseInt(e[n+1],10);this.position.x+=o,this.position.y+=r}},g.pointerDown=function(t,i){this._dragPointerDown(t,i);var e=h.activeElement;e&&e.blur&&e!=h.body&&e.blur(),this._bindPostStartEvents(t),this.element.classList.add("is-pointer-down"),this.dispatchEvent("pointerDown",t,[i])},g.pointerMove=function(t,i){var e=this._dragPointerMove(t,i);this.dispatchEvent("pointerMove",t,[i,e]),this._dragMove(t,i,e)},g.dragStart=function(t,i){this.isEnabled&&(this._getPosition(),this.measureContainment(),this.startPosition.x=this.position.x,this.startPosition.y=this.position.y,this.setLeftTop(),this.dragPoint.x=0,this.dragPoint.y=0,this.element.classList.add("is-dragging"),this.dispatchEvent("dragStart",t,[i]),this.animate())},g.measureContainment=function(){var t=this.options.containment;if(t){var e=r(t)?t:"string"==typeof t?h.querySelector(t):this.element.parentNode,n=i(this.element),o=i(e),s=this.element.getBoundingClientRect(),a=e.getBoundingClientRect(),d=o.borderLeftWidth+o.borderRightWidth,u=o.borderTopWidth+o.borderBottomWidth,p=this.relativeStartPosition={x:s.left-(a.left+o.borderLeftWidth),y:s.top-(a.top+o.borderTopWidth)};this.containSize={width:o.width-d-p.x-n.width,height:o.height-u-p.y-n.height}}},g.dragMove=function(t,i,e){if(this.isEnabled){var n=e.x,o=e.y,r=this.options.grid,s=r&&r[0],h=r&&r[1];n=a(n,s),o=a(o,h),n=this.containDrag("x",n,s),o=this.containDrag("y",o,h),n="y"==this.options.axis?0:n,o="x"==this.options.axis?0:o,this.position.x=this.startPosition.x+n,this.position.y=this.startPosition.y+o,this.dragPoint.x=n,this.dragPoint.y=o,this.dispatchEvent("dragMove",t,[i,e])}},g.containDrag=function(t,i,e){if(!this.options.containment)return i;var n="x"==t?"width":"height",o=this.relativeStartPosition[t],r=a(-o,e,"ceil"),s=this.containSize[n];return s=a(s,e,"floor"),Math.min(s,Math.max(r,i))},g.pointerUp=function(t,i){this.element.classList.remove("is-pointer-down"),this.dispatchEvent("pointerUp",t,[i]),this._dragPointerUp(t,i)},g.dragEnd=function(t,i){this.isEnabled&&(c&&(this.element.style[c]="",this.setLeftTop()),this.element.classList.remove("is-dragging"),this.dispatchEvent("dragEnd",t,[i]))},g.animate=function(){if(this.isDragging){this.positionDrag();var t=this;d(function(){t.animate()})}},g.setLeftTop=function(){this.element.style.left=this.position.x+"px",this.element.style.top=this.position.y+"px"},g.positionDrag=function(){this.element.style[c]="translate3d( "+this.dragPoint.x+"px, "+this.dragPoint.y+"px, 0)"},g.staticClick=function(t,i){this.dispatchEvent("staticClick",t,[i])},g.enable=function(){this.isEnabled=!0},g.disable=function(){this.isEnabled=!1,this.isDragging&&this.dragEnd()},g.destroy=function(){this.disable(),this.element.style[c]="",this.element.style.left="",this.element.style.top="",this.element.style.position="",this.unbindHandles(),this.$element&&this.$element.removeData("draggabilly")},g._init=n,f&&f.bridget&&f.bridget("draggabilly",s),s}); |
/*! | ||
* Draggabilly v2.0.1 | ||
* Draggabilly v2.1.0 | ||
* Make that shiz draggable | ||
@@ -8,5 +8,7 @@ * http://draggabilly.desandro.com | ||
/*jshint browser: true, strict: true, undef: true, unused: true */ | ||
( function( window, factory ) { | ||
'use strict'; | ||
// universal module definition | ||
/* jshint strict: false */ /*globals define, module, require */ | ||
if ( typeof define == 'function' && define.amd ) { | ||
@@ -21,3 +23,3 @@ // AMD | ||
}); | ||
} else if ( typeof exports == 'object' ) { | ||
} else if ( typeof module == 'object' && module.exports ) { | ||
// CommonJS | ||
@@ -63,10 +65,8 @@ module.exports = factory( | ||
// https://gist.github.com/1866474 | ||
// get rAF and cAF, prefixed, if present | ||
// get rAF, prefixed, if present | ||
var requestAnimationFrame = window.requestAnimationFrame || | ||
window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame; | ||
// fallback to setTimeout | ||
var lastTime = 0; | ||
// fallback to setTimeout and clearTimeout if either request/cancel is not supported | ||
if ( !requestAnimationFrame ) { | ||
@@ -76,5 +76,3 @@ requestAnimationFrame = function( callback ) { | ||
var timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) ); | ||
var id = setTimeout( function() { | ||
callback( currTime + timeToCall ); | ||
}, timeToCall ); | ||
var id = setTimeout( callback, timeToCall ); | ||
lastTime = currTime + timeToCall; | ||
@@ -87,9 +85,5 @@ return id; | ||
var transformProperty = ( function () { | ||
var style = document.documentElement.style; | ||
if ( typeof style.transform == 'string' ) { | ||
return 'transform'; | ||
} | ||
return 'WebkitTransform'; | ||
})(); | ||
var docElem = document.documentElement; | ||
var transformProperty = typeof docElem.style.transform == 'string' ? | ||
'transform' : 'WebkitTransform'; | ||
@@ -163,3 +157,3 @@ var jQuery = window.jQuery; | ||
/** | ||
* emits events via eventEmitter and jQuery events | ||
* emits events via EvEmitter and jQuery events | ||
* @param {String} type - name of event | ||
@@ -189,10 +183,7 @@ * @param {Event} event - original event | ||
// get left/top position from style | ||
proto._getPosition = function() { | ||
// properties | ||
// get x/y position from style | ||
Draggabilly.prototype._getPosition = function() { | ||
var style = getComputedStyle( this.element ); | ||
var x = parseInt( style.left, 10 ); | ||
var y = parseInt( style.top, 10 ); | ||
var x = this._getPositionCoord( style.left, 'width' ); | ||
var y = this._getPositionCoord( style.top, 'height' ); | ||
// clean up 'auto' or other non-integer values | ||
@@ -205,2 +196,12 @@ this.position.x = isNaN( x ) ? 0 : x; | ||
Draggabilly.prototype._getPositionCoord = function( styleSide, measure ) { | ||
if ( styleSide.indexOf('%') != -1 ) { | ||
// convert percent into pixel for Safari, #75 | ||
var parentSize = getSize( this.element.parentNode ); | ||
return ( parseFloat( styleSide ) / 100 ) * parentSize[ measure ]; | ||
} | ||
return parseInt( styleSide, 10 ); | ||
}; | ||
// add transform: translate( x, y ) to position | ||
@@ -207,0 +208,0 @@ proto._addTransformPosition = function( style ) { |
@@ -143,3 +143,3 @@ /*jshint node: true, strict: false */ | ||
var version = args.t; | ||
if ( !version || !/\d\.\d\.\d/.test( version ) ) { | ||
if ( !version || !/^\d+\.\d+\.\d+/.test( version ) ) { | ||
gutil.log( 'invalid version: ' + chalk.red( version ) ); | ||
@@ -151,11 +151,12 @@ return; | ||
gulp.src('draggabilly.js') | ||
.pipe( replace( /Draggabilly v\d\.\d\.\d/, 'Draggabilly v' + version ) ) | ||
.pipe( replace( /Draggabilly v\d+\.\d+\.\d+/, 'Draggabilly v' + version ) ) | ||
.pipe( gulp.dest('.') ); | ||
gulp.src( [ 'bower.json', 'package.json' ] ) | ||
.pipe( replace( /"version": "\d\.\d\.\d"/, '"version": "' + version + '"' ) ) | ||
gulp.src('package.json') | ||
.pipe( replace( /"version": "\d+\.\d+\.\d+"/, '"version": "' + version + '"' ) ) | ||
.pipe( gulp.dest('.') ); | ||
// replace CDN links in README | ||
var minorVersion = version.match(/\d+\.\d+/)[0]; | ||
gulp.src('README.md') | ||
.pipe( replace( /draggabilly@\d\.\d\.\d/g, 'draggabilly@' + version ) ) | ||
.pipe( replace( /draggabilly@\d+\.\d+/g, 'draggabilly@' + minorVersion ) ) | ||
.pipe( gulp.dest('.') ); | ||
@@ -162,0 +163,0 @@ }); |
{ | ||
"name": "draggabilly", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "make that shiz draggable", | ||
@@ -8,3 +8,3 @@ "main": "draggabilly.js", | ||
"get-size": "~2.0.2", | ||
"unidragger": "~2.0.0" | ||
"unidragger": "~2.1.0" | ||
}, | ||
@@ -11,0 +11,0 @@ "devDependencies": { |
@@ -27,5 +27,5 @@ # Draggabilly | ||
``` html | ||
<script src="https://npmcdn.com/draggabilly@2.0.1/dist/draggabilly.pkgd.min.js"></script> | ||
<script src="https://npmcdn.com/draggabilly@2.1/dist/draggabilly.pkgd.min.js"></script> | ||
<!-- or --> | ||
<script src="https://npmcdn.com/draggabilly@2.0.1/dist/draggabilly.pkgd.js"></script> | ||
<script src="https://npmcdn.com/draggabilly@2.1/dist/draggabilly.pkgd.js"></script> | ||
``` | ||
@@ -32,0 +32,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100874
21
2015
+ Addedev-emitter@1.0.3(transitive)
+ Addedunidragger@2.1.0(transitive)
+ Addedunipointer@2.1.0(transitive)
- Removedunidragger@2.0.0(transitive)
- Removedunipointer@2.0.0(transitive)
- Removedwolfy87-eventemitter@4.2.11(transitive)
Updatedunidragger@~2.1.0