2 * @class Ext.util.Offset
5 Ext.define('Ext.util.Offset', {
7 /* Begin Definitions */
10 fromObject: function(obj) {
11 return new this(obj.x, obj.y);
17 constructor: function(x, y) {
18 this.x = (x != null && !isNaN(x)) ? x : 0;
19 this.y = (y != null && !isNaN(y)) ? y : 0;
25 return new Ext.util.Offset(this.x, this.y);
28 copyFrom: function(p) {
33 toString: function() {
34 return "Offset[" + this.x + "," + this.y + "]";
37 equals: function(offset) {
39 if(!(offset instanceof this.statics())) {
40 Ext.Error.raise('Offset must be an instance of Ext.util.Offset');
44 return (this.x == offset.x && this.y == offset.y);
49 var factor = Math.pow(10, to);
50 this.x = Math.round(this.x * factor) / factor;
51 this.y = Math.round(this.y * factor) / factor;
53 this.x = Math.round(this.x);
54 this.y = Math.round(this.y);
59 return this.x == 0 && this.y == 0;