]> source.dussan.org Git - jquery-ui.git/commitdiff
Draggable: Check for grid elements set to 0 to prevent divide by 0 error causing... 268/head
authorkborchers <k_borchers@yahoo.com>
Fri, 13 May 2011 15:23:44 +0000 (10:23 -0500)
committerkborchers <k_borchers@yahoo.com>
Fri, 13 May 2011 15:23:44 +0000 (10:23 -0500)
ui/jquery.ui.draggable.js

index d7bc095783619509ee191d28c97f68e33c9fa0db..10d7e8a135fb2d5dfe7063c9f73381f1ee4ed96e 100644 (file)
@@ -436,10 +436,11 @@ $.widget("ui.draggable", $.ui.mouse, {
                        }
 
                        if(o.grid) {
-                               var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
+                               //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
+                               var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
                                pageY = containment ? (!(top - this.offset.click.top < containment[1] || top - this.offset.click.top > containment[3]) ? top : (!(top - this.offset.click.top < containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
 
-                               var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
+                               var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
                                pageX = containment ? (!(left - this.offset.click.left < containment[0] || left - this.offset.click.left > containment[2]) ? left : (!(left - this.offset.click.left < containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
                        }