3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.util.Offset
19 Ext.define('Ext.util.Offset', {
21 /* Begin Definitions */
24 fromObject: function(obj) {
25 return new this(obj.x, obj.y);
31 constructor: function(x, y) {
32 this.x = (x != null && !isNaN(x)) ? x : 0;
33 this.y = (y != null && !isNaN(y)) ? y : 0;
39 return new Ext.util.Offset(this.x, this.y);
42 copyFrom: function(p) {
47 toString: function() {
48 return "Offset[" + this.x + "," + this.y + "]";
51 equals: function(offset) {
53 if(!(offset instanceof this.statics())) {
54 Ext.Error.raise('Offset must be an instance of Ext.util.Offset');
58 return (this.x == offset.x && this.y == offset.y);
63 var factor = Math.pow(10, to);
64 this.x = Math.round(this.x * factor) / factor;
65 this.y = Math.round(this.y * factor) / factor;
67 this.x = Math.round(this.x);
68 this.y = Math.round(this.y);
73 return this.x == 0 && this.y == 0;