don`t recalculate offset if it is passed to the update method

This commit is contained in:
vieron
2012-07-23 11:03:06 +02:00
parent 0446186c98
commit 3e1d005585

View File

@@ -8,7 +8,7 @@
;(function($, window, document, undefined){
/**
* Coords description
* Coords
*
* @class Coords
* @param {HTMLElement|Object} obj HTMLElement or a literal Object with the left, top, width and height properties.
@@ -34,12 +34,20 @@
this.original_coords = this.get();
};
fn.set = function() {
fn.set = function(update, not_update_offsets) {
var el = this.el;
if (el) {
this.data = el.offset();
this.data.width || (this.data.width = el.width());
this.data.height || (this.data.height = el.height());
if (el && !update) {
this.data = {} || el.offset();
this.data.width = el.width();
this.data.height = el.height();
};
if (el && update && !not_update_offsets) {
var offset = el.offset();
this.data.top = offset.top;
this.data.left = offset.left;
}
var d = this.data;
@@ -57,19 +65,23 @@
return this;
};
fn.update = function(data){
if (!data && !this.el) {
return this;
}
if (data) {
var new_data = $.extend(this.data, data);
var new_data = $.extend({}, this.data, data);
this.data = new_data;
return this.set(true, true);
}
this.set();
this.set(true);
return this;
};
fn.get = function(){
return this.coords;
};