@@ -4,6 +4,7 @@ var React = require('react');
44var emptyFunction = function ( ) { } ;
55var assign = require ( 'object-assign' ) ;
66var classNames = require ( 'classnames' ) ;
7+ var browserPrefix = require ( './getPrefix' ) ( ) ;
78
89//
910// Helpers. See Element definition below this section.
@@ -21,14 +22,12 @@ function createUIEvent(draggable) {
2122 } ;
2223}
2324
24- function canDragY ( draggable ) {
25- return draggable . props . axis === 'both' ||
26- draggable . props . axis === 'y' ;
25+ function canDragX ( draggable ) {
26+ return draggable . props . axis === 'both' || draggable . props . axis === 'x' ;
2727}
2828
29- function canDragX ( draggable ) {
30- return draggable . props . axis === 'both' ||
31- draggable . props . axis === 'x' ;
29+ function canDragY ( draggable ) {
30+ return draggable . props . axis === 'both' || draggable . props . axis === 'y' ;
3231}
3332
3433function isFunction ( func ) {
@@ -44,14 +43,14 @@ function findInArray(array, callback) {
4443
4544function matchesSelector ( el , selector ) {
4645 var method = findInArray ( [
47- 'matches' ,
48- 'webkitMatchesSelector' ,
49- 'mozMatchesSelector' ,
50- 'msMatchesSelector' ,
51- 'oMatchesSelector'
52- ] , function ( method ) {
53- return isFunction ( el [ method ] ) ;
54- } ) ;
46+ 'matches' ,
47+ 'webkitMatchesSelector' ,
48+ 'mozMatchesSelector' ,
49+ 'msMatchesSelector' ,
50+ 'oMatchesSelector'
51+ ] , function ( method ) {
52+ return isFunction ( el [ method ] ) ;
53+ } ) ;
5554
5655 return el [ method ] . call ( el , selector ) ;
5756}
@@ -73,7 +72,7 @@ var eventsFor = {
7372} ;
7473
7574// Default to mouse events
76- var dragEventFor = eventsFor [ ' mouse' ] ;
75+ var dragEventFor = eventsFor . mouse ;
7776
7877/**
7978 * get {clientX, clientY} positions of control
@@ -214,7 +213,7 @@ function createCSSTransform(style) {
214213 msTransform : 'translate(' + x + ',' + y + ')' ,
215214 MozTransform : 'translate(' + x + ',' + y + ')'
216215 } ;
217- }
216+ }
218217
219218
220219//
@@ -460,7 +459,7 @@ module.exports = React.createClass({
460459 * A workaround option which can be passed if onMouseDown needs to be accessed,
461460 * since it'll always be blocked (due to that there's internal use of onMouseDown)
462461 */
463- onMouseDown : React . PropTypes . func ,
462+ onMouseDown : React . PropTypes . func
464463 } ,
465464
466465 componentWillReceiveProps : function ( newProps ) {
@@ -472,8 +471,8 @@ module.exports = React.createClass({
472471
473472 componentWillUnmount : function ( ) {
474473 // Remove any leftover event handlers
475- removeEvent ( document , dragEventFor [ ' move' ] , this . handleDrag ) ;
476- removeEvent ( document , dragEventFor [ ' end' ] , this . handleDragEnd ) ;
474+ removeEvent ( document , dragEventFor . move , this . handleDrag ) ;
475+ removeEvent ( document , dragEventFor . end , this . handleDragEnd ) ;
477476 removeUserSelectStyles ( this ) ;
478477 } ,
479478
@@ -541,8 +540,8 @@ module.exports = React.createClass({
541540
542541
543542 // Add event handlers
544- addEvent ( document , dragEventFor [ ' move' ] , this . handleDrag ) ;
545- addEvent ( document , dragEventFor [ ' end' ] , this . handleDragEnd ) ;
543+ addEvent ( document , dragEventFor . move , this . handleDrag ) ;
544+ addEvent ( document , dragEventFor . end , this . handleDragEnd ) ;
546545 } ,
547546
548547 handleDragEnd : function ( e ) {
@@ -562,8 +561,8 @@ module.exports = React.createClass({
562561 this . props . onStop ( e , createUIEvent ( this ) ) ;
563562
564563 // Remove event handlers
565- removeEvent ( document , dragEventFor [ ' move' ] , this . handleDrag ) ;
566- removeEvent ( document , dragEventFor [ ' end' ] , this . handleDragEnd ) ;
564+ removeEvent ( document , dragEventFor . move , this . handleDrag ) ;
565+ removeEvent ( document , dragEventFor . end , this . handleDragEnd ) ;
567566 } ,
568567
569568 handleDrag : function ( e ) {
@@ -576,12 +575,14 @@ module.exports = React.createClass({
576575 // Snap to grid if prop has been provided
577576 if ( Array . isArray ( this . props . grid ) ) {
578577 var coords = snapToGrid ( this . props . grid , clientX , clientY ) ;
579- clientX = coords [ 0 ] , clientY = coords [ 1 ] ;
578+ clientX = coords [ 0 ] ;
579+ clientY = coords [ 1 ] ;
580580 }
581581
582582 if ( this . props . bounds ) {
583583 var pos = getBoundPosition ( this , clientX , clientY ) ;
584- clientX = pos [ 0 ] , clientY = pos [ 1 ] ;
584+ clientX = pos [ 0 ] ;
585+ clientY = pos [ 1 ] ;
585586 }
586587
587588 // Call event handler. If it returns explicit false, cancel.
@@ -599,7 +600,7 @@ module.exports = React.createClass({
599600 // Prevent 'ghost click' which happens 300ms after touchstart if the event isn't cancelled.
600601 // We don't cancel the event on touchstart because of #37; we might want to make a scrollable item draggable.
601602 // More on ghost clicks: http://ariatemplates.com/blog/2014/05/ghost-clicks-in-mobile-browsers/
602- if ( dragEventFor == eventsFor [ ' touch' ] ) {
603+ if ( dragEventFor === eventsFor . touch ) {
603604 return ev . preventDefault ( ) ;
604605 }
605606
@@ -608,7 +609,7 @@ module.exports = React.createClass({
608609
609610 onTouchStart : function ( ev ) {
610611 // We're on a touch device now, so change the event handlers
611- dragEventFor = eventsFor [ ' touch' ] ;
612+ dragEventFor = eventsFor . touch ;
612613
613614 return this . handleDragStart . apply ( this , arguments ) ;
614615 } ,
0 commit comments