Skip to content

Commit

Permalink
Merge remote-tracking branch 'eric/master'
Browse files Browse the repository at this point in the history
  Grunt changes
  Add an optional final parameter to add_widget.
  Bumping to v0.5.7
  Grunt
  Fix Widget Right Edge Collission Detection
  re-name model_id parameter
  add model_id parameter to add_widget method in order to create a relationship between widget and backbone model
  Fix the memory leak that was incorrectly iterating rows and columns
  Cache $(window) and $(this) selectors for performance
  fix (Gridster.js):  destroy  resize_api
  • Loading branch information
David Morse committed Apr 7, 2015
2 parents 37d8e0e + ee7b5be commit cec85c5
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 103 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@

* **gridster:** make grid responsive ([a3913043](http://github.com/DecksterTeam/gridster.js/commit/a3913043579bae9f5ef28e34524ad7a8ae7dcafd))

<a name="v0.5.7"></a>
### v0.5.7 (2015-02-17)

<a name="v0.5.6"></a>
### v0.5.6 (2014-09-25)

Expand Down
85 changes: 52 additions & 33 deletions dist/jquery.gridster.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@

var d = this.data;

typeof d.left === 'undefined' && (d.left = d.x1);
typeof d.top === 'undefined' && (d.top = d.y1);
if ( d.left === undefined ) {
d.left = d.x1;
}

if ( d.top === undefined ) {
d.top = d.y1;
}

this.coords.x1 = d.left;
this.coords.y1 = d.top;
Expand Down Expand Up @@ -283,20 +288,22 @@
var area_coords = self.calculate_overlapped_area_coords(
player_coords, collider_coords);
var area = self.calculate_overlapped_area(area_coords);
var collider_data = {
area: area,
area_coords : area_coords,
region: region,
coords: collider_coords,
player_coords: player_coords,
el: $collider
};

if (self.options.on_overlap) {
self.options.on_overlap.call(this, collider_data);
if ( 0 != area ) {
var collider_data = {
area: area,
area_coords : area_coords,
region: region,
coords: collider_coords,
player_coords: player_coords,
el: $collider
};

if (self.options.on_overlap) {
self.options.on_overlap.call(this, collider_data);
}
colliders_coords.push($collider_coords_ins);
colliders_data.push(collider_data);
}
colliders_coords.push($collider_coords_ins);
colliders_data.push(collider_data);
}
}

Expand Down Expand Up @@ -520,7 +527,7 @@
this.disabled = false;
this.events();

$(window).bind(this.nsEvent('resize'),
$window.bind(this.nsEvent('resize'),
throttle($.proxy(this.calculate_dimensions, this), 200));
};

Expand Down Expand Up @@ -578,9 +585,9 @@
var diff_y = Math.round(mouse_actual_pos.top - this.mouse_init_pos.top);

var left = Math.round(this.el_init_offset.left +
diff_x - this.baseX + $(window).scrollLeft() - this.win_offset_x);
diff_x - this.baseX + $window.scrollLeft() - this.win_offset_x);
var top = Math.round(this.el_init_offset.top +
diff_y - this.baseY + $(window).scrollTop() - this.win_offset_y);
diff_y - this.baseY + $window.scrollTop() - this.win_offset_y);

if (this.options.limit) {
if (left > this.player_max_left) {
Expand All @@ -598,8 +605,8 @@
pointer: {
left: mouse_actual_pos.left,
top: mouse_actual_pos.top,
diff_left: diff_x + ($(window).scrollLeft() - this.win_offset_x),
diff_top: diff_y + ($(window).scrollTop() - this.win_offset_y)
diff_left: diff_x + ($window.scrollLeft() - this.win_offset_x),
diff_top: diff_y + ($window.scrollTop() - this.win_offset_y)
}
};
};
Expand Down Expand Up @@ -747,8 +754,8 @@
this.helper = false;
}

this.win_offset_y = $(window).scrollTop();
this.win_offset_x = $(window).scrollLeft();
this.win_offset_y = $window.scrollTop();
this.win_offset_x = $window.scrollLeft();
this.scroll_offset_y = 0;
this.scroll_offset_x = 0;
this.el_init_offset = this.$player.offset();
Expand Down Expand Up @@ -827,7 +834,7 @@

this.$container.off(this.ns);
this.$document.off(this.ns);
$(window).off(this.ns);
$window.off(this.ns);

$.removeData(this.$container, 'drag');
};
Expand Down Expand Up @@ -864,7 +871,8 @@

}(this, function($, Draggable, Collision) {

var defaults = {
var $window = $( window ),
defaults = {
namespace: '',
widget_selector: 'li',
widget_margins: [10, 10],
Expand Down Expand Up @@ -972,7 +980,7 @@
* `[min_cols_occupied, min_rows_occupied]`
* @param {Function} [options.resize.start] Function executed
* when resizing starts.
* @param {Function} [otions.resize.resize] Function executed
* @param {Function} [options.resize.resize] Function executed
* during the resizing.
* @param {Function} [options.resize.stop] Function executed
* when resizing stops.
Expand Down Expand Up @@ -1112,7 +1120,7 @@
}, this), 0);
}

$(window).bind('resize.gridster', throttle(
$window.bind('resize.gridster', throttle(
$.proxy(this.recalculate_faux_grid, this), 200));
};

Expand Down Expand Up @@ -1235,6 +1243,7 @@
}

return $w.fadeIn({complete: function () { if(callback) callback.call(this); }});

};


Expand Down Expand Up @@ -1704,10 +1713,11 @@
});

$nexts.not($exclude).each($.proxy(function(i, w) {
var wgd = $(w).coords().grid;
var $w = $( w ),
wgd = $w.coords().grid;
if ( !(wgd.row <= (row + size_y - 1))) { return; }
var diff = (row + size_y) - wgd.row;
this.move_widget_down($(w), diff);
this.move_widget_down($w, diff);
}, this));

this.set_dom_grid_height();
Expand Down Expand Up @@ -4185,6 +4195,8 @@
* @return {Object} Returns the instance of the Gridster class.
*/
fn.add_faux_rows = function(rows) {
rows = window.parseInt( rows, 10 );

var actual_rows = this.rows;
var max_rows = actual_rows + (rows || 1);

Expand All @@ -4211,6 +4223,8 @@
* @return {Object} Returns the instance of the Gridster class.
*/
fn.add_faux_cols = function(cols) {
cols = window.parseInt( cols, 10 );

var actual_cols = this.cols;
var max_cols = actual_cols + (cols || 1);
max_cols = Math.min(max_cols, this.options.max_cols);
Expand Down Expand Up @@ -4240,7 +4254,7 @@
*/
fn.recalculate_faux_grid = function() {
var aw = this.$wrapper.width();
this.baseX = ($(window).width() - aw) / 2;
this.baseX = ($window.width() - aw) / 2;
this.baseY = this.$wrapper.offset().top;

$.each(this.faux_grid, $.proxy(function(i, coords) {
Expand Down Expand Up @@ -4371,7 +4385,7 @@

this.rows = Math.max(max_rows, this.options.min_rows);

this.baseX = ($(window).width() - aw) / 2;
this.baseX = ($window.width() - aw) / 2;
this.baseY = this.$wrapper.offset().top;

if (this.options.autogenerate_stylesheet) {
Expand All @@ -4392,12 +4406,16 @@
this.$el.removeData('gridster');

// remove bound callback on window resize
$(window).unbind('.gridster');
$window.unbind('.gridster');

if (this.drag_api) {
this.drag_api.destroy();
}

if (this.resize_api) {
this.resize_api.destroy();
}

this.remove_style_tags();

remove && this.$el.remove();
Expand All @@ -4409,8 +4427,9 @@
//jQuery adapter
$.fn.gridster = function(options) {
return this.each(function() {
if (! $(this).data('gridster')) {
$(this).data('gridster', new Gridster( this, options ));
var $this = $( this );
if (! $this.data('gridster')) {
$this.data('gridster', new Gridster( this, options ));
}
});
};
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.gridster.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit cec85c5

Please sign in to comment.