Changeset 435
- Timestamp:
- 07/09/08 17:56:29 (20 months ago)
- Files:
-
- 1 modified
-
trunk/ui/ui.sortable.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ui/ui.sortable.js
r432 r435 91 91 var l = item.left, r = l + item.width, 92 92 t = item.top, b = t + item.height; 93 94 if (this.options.tolerance == "pointer" || this.options.forcePointerForContainers || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) { 95 return (y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r); 93 94 var dyClick = this.offset.click.top, dxClick = this.offset.click.left; 95 var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r; 96 97 if(this.options.tolerance == "pointer" || this.options.forcePointerForContainers || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) { 98 return isOverElement; 96 99 } else { 100 97 101 return (l < x1 + (this.helperProportions.width / 2) // Right Half 98 102 && x2 - (this.helperProportions.width / 2) < r // Left Half 99 103 && t < y1 + (this.helperProportions.height / 2) // Bottom Half 100 104 && y2 - (this.helperProportions.height / 2) < b ); // Top Half 101 }102 105 106 } 103 107 }, 104 108 intersectsWithEdge: function(item) { 105 109 var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width, 106 110 y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height; 111 107 112 var l = item.left, r = l + item.width, 108 113 t = item.top, b = t + item.height; 109 114 115 var dyClick = this.offset.click.top, dxClick = this.offset.click.left; 116 var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r; 117 110 118 if(this.options.tolerance == "pointer" || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) { 111 112 if(!(y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r)) return false; 113 119 if(!isOverElement) return false; 120 114 121 if(this.floating) { 115 if (x1 + this.offset.click.left > l && x1 + this.offset.click.left< l + item.width/2) return 2;116 if (x1 + this.offset.click.left > l+item.width/2 && x1 + this.offset.click.left< r) return 1;122 if ((x1 + dxClick) > l && (x1 + dxClick) < l + item.width/2) return 2; 123 if ((x1 + dxClick) > l + item.width/2 && (x1 + dxClick) < r) return 1; 117 124 } else { 118 if(y1 + this.offset.click.top > t && y1 + this.offset.click.top < t) return 2; 119 if(y1 + this.offset.click.top > t && y1 + this.offset.click.top < b) return 1; 125 var height = item.height, helperHeight = this.helperProportions.height; 126 var direction = y1 - this.originalPosition.top < 0 ? 2 : 1; // 2 = up 127 128 if (direction == 1 && (y1 + dyClick) < t + height/2) { return 2; } // up 129 else if (direction == 2 && (y1 + dyClick) > t + height/2) { return 1; } // down 120 130 } 121 131 122 132 } else { 123 124 133 if (!(l < x1 + (this.helperProportions.width / 2) // Right Half 125 134 && x2 - (this.helperProportions.width / 2) < r // Left Half … … 134 143 if(y1 < b && y2 > b) return 2; //Crosses bottom edge 135 144 } 136 137 145 } 138 146