Skip to content

Commit 986313a

Browse files
committed
2.3.0
1 parent 821732e commit 986313a

File tree

6 files changed

+84
-40
lines changed

6 files changed

+84
-40
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Rad because it supports IE10+ and touch devices.
88

9-
Draggabilly v2.2.0
9+
Draggabilly v2.3.0
1010

1111
## Install
1212

dist/draggabilly.pkgd.js

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Draggabilly PACKAGED v2.2.0
2+
* Draggabilly PACKAGED v2.3.0
33
* Make that shiz draggable
44
* https://draggabilly.desandro.com
55
* MIT license
@@ -1055,46 +1055,44 @@ return Unidragger;
10551055
}));
10561056

10571057
/*!
1058-
* Draggabilly v2.2.0
1058+
* Draggabilly v2.3.0
10591059
* Make that shiz draggable
10601060
* https://draggabilly.desandro.com
10611061
* MIT license
10621062
*/
10631063

1064-
/*jshint browser: true, strict: true, undef: true, unused: true */
1064+
/* jshint browser: true, strict: true, undef: true, unused: true */
10651065

10661066
( function( window, factory ) {
10671067
// universal module definition
1068-
/* jshint strict: false */ /*globals define, module, require */
1068+
/* jshint strict: false */ /* globals define */
10691069
if ( typeof define == 'function' && define.amd ) {
10701070
// AMD
10711071
define( [
1072-
'get-size/get-size',
1073-
'unidragger/unidragger'
1074-
],
1075-
function( getSize, Unidragger ) {
1072+
'get-size/get-size',
1073+
'unidragger/unidragger',
1074+
],
1075+
function( getSize, Unidragger ) {
10761076
return factory( window, getSize, Unidragger );
1077-
});
1077+
} );
10781078
} else if ( typeof module == 'object' && module.exports ) {
10791079
// CommonJS
10801080
module.exports = factory(
1081-
window,
1082-
require('get-size'),
1083-
require('unidragger')
1081+
window,
1082+
require('get-size'),
1083+
require('unidragger')
10841084
);
10851085
} else {
10861086
// browser global
10871087
window.Draggabilly = factory(
1088-
window,
1089-
window.getSize,
1090-
window.Unidragger
1088+
window,
1089+
window.getSize,
1090+
window.Unidragger
10911091
);
10921092
}
10931093

10941094
}( window, function factory( window, getSize, Unidragger ) {
10951095

1096-
1097-
10981096
// -------------------------- helpers & variables -------------------------- //
10991097

11001098
// extend objects
@@ -1145,7 +1143,7 @@ proto.option = function( opts ) {
11451143
var positionValues = {
11461144
relative: true,
11471145
absolute: true,
1148-
fixed: true
1146+
fixed: true,
11491147
};
11501148

11511149
proto._create = function() {
@@ -1165,7 +1163,6 @@ proto._create = function() {
11651163
}
11661164

11671165
// events, bridge jQuery events from vanilla
1168-
this.on( 'pointerDown', this.onPointerDown );
11691166
this.on( 'pointerMove', this.onPointerMove );
11701167
this.on( 'pointerUp', this.onPointerUp );
11711168

@@ -1196,13 +1193,14 @@ proto.dispatchEvent = function( type, event, args ) {
11961193
};
11971194

11981195
proto.dispatchJQueryEvent = function( type, event, args ) {
1199-
var jQuery = window.jQuery;
1196+
var jquery = window.jQuery;
12001197
// trigger jQuery event
1201-
if ( !jQuery || !this.$element ) {
1198+
if ( !jquery || !this.$element ) {
12021199
return;
12031200
}
12041201
// create jQuery event
1205-
var $event = jQuery.Event( event );
1202+
/* eslint-disable-next-line new-cap */
1203+
var $event = jquery.Event( event );
12061204
$event.type = type;
12071205
this.$element.trigger( $event, args );
12081206
};
@@ -1257,10 +1255,31 @@ proto.onPointerDown = function( event, pointer ) {
12571255
this.dispatchJQueryEvent( 'pointerDown', event, [ pointer ] );
12581256
};
12591257

1258+
proto.pointerDown = function( event, pointer ) {
1259+
var isOkay = this.okayPointerDown( event );
1260+
if ( !isOkay || !this.isEnabled ) {
1261+
this._pointerReset();
1262+
return;
1263+
}
1264+
// track start event position
1265+
// Safari 9 overrides pageX and pageY. These values needs to be copied. flickity#842
1266+
this.pointerDownPointer = {
1267+
pageX: pointer.pageX,
1268+
pageY: pointer.pageY,
1269+
};
1270+
1271+
event.preventDefault();
1272+
this.pointerDownBlur();
1273+
// bind move and end events
1274+
this._bindPostStartEvents( event );
1275+
this.element.classList.add('is-pointer-down');
1276+
this.dispatchEvent( 'pointerDown', event, [ pointer ] );
1277+
};
1278+
12601279
/**
12611280
* drag start
12621281
* @param {Event} event
1263-
* @param {Event or Touch} pointer
1282+
* @param {[Event, Touch]} pointer
12641283
*/
12651284
proto.dragStart = function( event, pointer ) {
12661285
if ( !this.isEnabled ) {
@@ -1299,12 +1318,12 @@ proto.measureContainment = function() {
12991318

13001319
var position = this.relativeStartPosition = {
13011320
x: elemRect.left - ( containerRect.left + containerSize.borderLeftWidth ),
1302-
y: elemRect.top - ( containerRect.top + containerSize.borderTopWidth )
1321+
y: elemRect.top - ( containerRect.top + containerSize.borderTopWidth ),
13031322
};
13041323

13051324
this.containSize = {
13061325
width: ( containerSize.width - borderSizeX ) - position.x - elemSize.width,
1307-
height: ( containerSize.height - borderSizeY ) - position.y - elemSize.height
1326+
height: ( containerSize.height - borderSizeY ) - position.y - elemSize.height,
13081327
};
13091328
};
13101329

@@ -1335,7 +1354,8 @@ proto.onPointerMove = function( event, pointer, moveVector ) {
13351354
/**
13361355
* drag move
13371356
* @param {Event} event
1338-
* @param {Event or Touch} pointer
1357+
* @param {[Event, Touch]} pointer
1358+
* @param {Object} moveVector - x and y coordinates
13391359
*/
13401360
proto.dragMove = function( event, pointer, moveVector ) {
13411361
if ( !this.isEnabled ) {
@@ -1369,7 +1389,7 @@ proto.dragMove = function( event, pointer, moveVector ) {
13691389

13701390
function applyGrid( value, grid, method ) {
13711391
method = method || 'round';
1372-
return grid ? Math[ method ]( value / grid ) * grid : value;
1392+
return grid ? Math[ method ]( value/grid ) * grid : value;
13731393
}
13741394

13751395
proto.containDrag = function( axis, drag, grid ) {
@@ -1382,15 +1402,15 @@ proto.containDrag = function( axis, drag, grid ) {
13821402
var min = applyGrid( -rel, grid, 'ceil' );
13831403
var max = this.containSize[ measure ];
13841404
max = applyGrid( max, grid, 'floor' );
1385-
return Math.max( min, Math.min( max, drag ) );
1405+
return Math.max( min, Math.min( max, drag ) );
13861406
};
13871407

13881408
// ----- end event ----- //
13891409

13901410
/**
13911411
* pointer up
13921412
* @param {Event} event
1393-
* @param {Event or Touch} pointer
1413+
* @param {[Event, Touch]} pointer
13941414
*/
13951415
proto.onPointerUp = function( event, pointer ) {
13961416
this.element.classList.remove('is-pointer-down');
@@ -1400,7 +1420,7 @@ proto.onPointerUp = function( event, pointer ) {
14001420
/**
14011421
* drag end
14021422
* @param {Event} event
1403-
* @param {Event or Touch} pointer
1423+
* @param {[Event, Touch]} pointer
14041424
*/
14051425
proto.dragEnd = function( event, pointer ) {
14061426
if ( !this.isEnabled ) {
@@ -1426,14 +1446,14 @@ proto.animate = function() {
14261446
var _this = this;
14271447
requestAnimationFrame( function animateFrame() {
14281448
_this.animate();
1429-
});
1449+
} );
14301450

14311451
};
14321452

14331453
// left/top positioning
14341454
proto.setLeftTop = function() {
14351455
this.element.style.left = this.position.x + 'px';
1436-
this.element.style.top = this.position.y + 'px';
1456+
this.element.style.top = this.position.y + 'px';
14371457
};
14381458

14391459
proto.positionDrag = function() {
@@ -1498,5 +1518,5 @@ if ( jQuery && jQuery.bridget ) {
14981518

14991519
return Draggabilly;
15001520

1501-
}));
1521+
} ) );
15021522

0 commit comments

Comments
 (0)