]> source.dussan.org Git - jquery-ui.git/commitdiff
Sortable: Optimize `_intersectsWithPointer()`
authorVictor Homyakov <vkhomyackov@gmail.com>
Wed, 8 Jul 2015 10:53:13 +0000 (13:53 +0300)
committerScott González <scott.gonzalez@gmail.com>
Wed, 8 Jul 2015 17:00:50 +0000 (13:00 -0400)
Closes gh-1574

ui/sortable.js

index 6d872cbe6e723d0a10fbba58708602ca1b2d93fd..bf1bf6a8925f3d4ede73afb6f1d40b8fcf57c476 100644 (file)
@@ -588,18 +588,20 @@ return $.widget("ui.sortable", $.ui.mouse, {
 
        _intersectsWithPointer: function(item) {
 
-               var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
+               var verticalDirection, horizontalDirection,
+                       isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
                        isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
-                       isOverElement = isOverElementHeight && isOverElementWidth,
-                       verticalDirection = this._getDragVerticalDirection(),
-                       horizontalDirection = this._getDragHorizontalDirection();
+                       isOverElement = isOverElementHeight && isOverElementWidth;
 
                if (!isOverElement) {
                        return false;
                }
 
+               verticalDirection = this._getDragVerticalDirection();
+               horizontalDirection = this._getDragHorizontalDirection();
+
                return this.floating ?
-                       ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
+                       ( (horizontalDirection === "right" || verticalDirection === "down") ? 2 : 1 )
                        : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
 
        },