4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-util-Offset'>/**
19 </span> * @class Ext.util.Offset
22 Ext.define('Ext.util.Offset', {
24 /* Begin Definitions */
27 fromObject: function(obj) {
28 return new this(obj.x, obj.y);
34 constructor: function(x, y) {
35 this.x = (x != null && !isNaN(x)) ? x : 0;
36 this.y = (y != null && !isNaN(y)) ? y : 0;
42 return new Ext.util.Offset(this.x, this.y);
45 copyFrom: function(p) {
50 toString: function() {
51 return "Offset[" + this.x + "," + this.y + "]";
54 equals: function(offset) {
56 if(!(offset instanceof this.statics())) {
57 Ext.Error.raise('Offset must be an instance of Ext.util.Offset');
61 return (this.x == offset.x && this.y == offset.y);
66 var factor = Math.pow(10, to);
67 this.x = Math.round(this.x * factor) / factor;
68 this.y = Math.round(this.y * factor) / factor;
70 this.x = Math.round(this.x);
71 this.y = Math.round(this.y);
76 return this.x == 0 && this.y == 0;