Skip to content

Commit f7ee852

Browse files
victor-homyakovscottgonzalez
authored andcommitted
Sortable: Optimize _intersectsWithPointer()
Closes jquerygh-1574
1 parent b3a9b13 commit f7ee852

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ui/sortable.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,18 +588,20 @@ return $.widget("ui.sortable", $.ui.mouse, {
588588

589589
_intersectsWithPointer: function(item) {
590590

591-
var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
591+
var verticalDirection, horizontalDirection,
592+
isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
592593
isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
593-
isOverElement = isOverElementHeight && isOverElementWidth,
594-
verticalDirection = this._getDragVerticalDirection(),
595-
horizontalDirection = this._getDragHorizontalDirection();
594+
isOverElement = isOverElementHeight && isOverElementWidth;
596595

597596
if (!isOverElement) {
598597
return false;
599598
}
600599

600+
verticalDirection = this._getDragVerticalDirection();
601+
horizontalDirection = this._getDragHorizontalDirection();
602+
601603
return this.floating ?
602-
( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
604+
( (horizontalDirection === "right" || verticalDirection === "down") ? 2 : 1 )
603605
: ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
604606

605607
},

0 commit comments

Comments
 (0)