| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- define(function(require, exports, module) {
- "use strict";
- var Util = require('./util');
- function Boundry(cfg) {
- this.cfg = Util.mix({
- width: 0,
- height: 0
- }, cfg)
- this.init();
- }
- Util.mix(Boundry.prototype, {
- init: function() {
- var self = this;
- self._xtop = 0;
- self._xright = 0;
- self._xleft = 0;
- self._xbottom = 0;
- self.refresh({
- width: self.cfg.width,
- height: self.cfg.height
- });
- },
- reset: function() {
- this.resetTop();
- this.resetLeft();
- this.resetBottom();
- this.resetRight();
- return this;
- },
- resetTop: function() {
- this._xtop = 0;
- this.refresh();
- return this;
- },
- resetLeft: function() {
- this._xleft = 0;
- this.refresh();
- return this;
- },
- resetBottom: function() {
- this._xbottom = 0;
- this.refresh();
- return this;
- },
- resetRight: function() {
- this._xright = 0;
- this.refresh();
- return this;
- },
- expandTop: function(top) {
- this._xtop = top;
- this.refresh();
- return this;
- },
- expandLeft: function(left) {
- this._xleft = left;
- this.refresh();
- return this;
- },
- expandRight: function(right) {
- this._xright = right;
- this.refresh();
- return this;
- },
- expandBottom: function(bottom) {
- this._xbottom = bottom;
- this.refresh();
- return this;
- },
- refresh: function(cfg) {
- Util.mix(this.cfg, cfg);
- this.top = this._xtop;
- this.left = this._xleft;
- this.bottom = (cfg && cfg.height || this.cfg.height || 0) - this._xbottom;
- this.right = (cfg && cfg.width || this.cfg.width || 0) - this._xright;
- this.width = this.right - this.left > 0 ? this.right - this.left : 0;
- this.height = this.bottom - this.top > 0 ? this.bottom - this.top : 0;
- return this;
- }
- });
- if (typeof module == 'object' && module.exports) {
- module.exports = Boundry;
- }
- /** ignored by jsdoc **/
- else{
- return Boundry;
- }
- });
|