Ticket #1085: Geometry_Rectangle_move.00.patch
| File Geometry_Rectangle_move.00.patch, 1.6 kB (added by fredj, 1 year ago) |
|---|
-
tests/Geometry/test_Rectangle.html
old new 79 79 t.eq(rect.getArea(), testArea, "testArea() works"); 80 80 } 81 81 82 function test_Rectangle_move(t) { 83 t.plan(5); 82 84 85 var x = 1; 86 var y = - 2; 87 var w = 10; 88 var h = 20; 89 var rect = new OpenLayers.Geometry.Rectangle(x, y, w, h); 83 90 91 var dx = 10 * Math.random(); 92 var dy = 10 * Math.random(); 93 94 rect.bounds = "foo"; 95 rect.move(dx, dy); 96 97 t.eq(rect.x, x + dx, "move() correctly modifies x"); 98 t.eq(rect.y, y + dy, "move() correctly modifies y"); 99 t.eq(rect.width, w, "move() don't modifies width"); 100 t.eq(rect.height, h, "move() don't modifies height"); 101 102 t.ok(rect.bounds == null, "bounds is cleared after a move()"); 103 } 104 84 105 </script> 85 106 </head> 86 107 <body> -
lib/OpenLayers/Geometry/Rectangle.js
old new 89 89 return area; 90 90 }, 91 91 92 /** 93 * APIMethod: move 94 * Moves a rectangle 95 * 96 * Parameters: 97 * x - {Float} 98 * y - {Float} 99 */ 100 move: function(x, y) { 101 this.x = this.x + x; 102 this.y = this.y + y; 103 this.clearBounds(); 104 }, 105 92 106 CLASS_NAME: "OpenLayers.Geometry.Rectangle" 93 107 });
