Skip to content

Commit b84f364

Browse files
committed
Release v0.5.1
1 parent dc09f19 commit b84f364

File tree

8 files changed

+68
-27
lines changed

8 files changed

+68
-27
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
<a name="v0.5.1"></a>
2+
### v0.5.1 (2014-03-05)
3+
4+
5+
#### Features
6+
7+
* **collision:** overlapping region as a config option ([720d487e](http://github.com/ducksboard/gridster.js/commit/720d487e3988593e2c60909c88aaff13fbd4f842))
8+
* **coords:**
9+
* allow both (left/x1) and (top/y1) attr keys ([6f22217f](http://github.com/ducksboard/gridster.js/commit/6f22217f056e4fc52f6405f2af49596105aae150))
10+
* add destroy method ([fdeee4f6](http://github.com/ducksboard/gridster.js/commit/fdeee4f636266c7a0579ced833f04fec013b6863))
11+
* **draggable:** keep container position prop if different than static ([04868a38](http://github.com/ducksboard/gridster.js/commit/04868a384d655d110f2d153d2fddb94b1c6d54a9))
12+
* **gridster:** destroy element's data and optionally remove from DOM ([dc09f191](http://github.com/ducksboard/gridster.js/commit/dc09f191d8503669cfa4737122c77cb0f5b9c3d2))
13+
114
<a name="v0.5.0"></a>
215
## v0.5.0 (2014-02-14)
316

dist/jquery.gridster.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! gridster.js - v0.5.0 - 2014-02-14
1+
/*! gridster.js - v0.5.1 - 2014-03-05
22
* http://gridster.net/
33
* Copyright (c) 2014 ducksboard; Licensed MIT */
44

dist/jquery.gridster.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! gridster.js - v0.5.0 - 2014-02-14
1+
/*! gridster.js - v0.5.1 - 2014-03-05
22
* http://gridster.net/
33
* Copyright (c) 2014 ducksboard; Licensed MIT */
44

@@ -55,6 +55,9 @@
5555

5656
var d = this.data;
5757

58+
typeof d.left === 'undefined' && (d.left = d.x1);
59+
typeof d.top === 'undefined' && (d.top = d.y1);
60+
5861
this.coords.x1 = d.left;
5962
this.coords.y1 = d.top;
6063
this.coords.x2 = d.left + d.width;
@@ -89,6 +92,10 @@
8992
return this.coords;
9093
};
9194

95+
fn.destroy = function() {
96+
this.el.removeData('coords');
97+
delete this.el;
98+
};
9299

93100
//jQuery adapter
94101
$.fn.coords = function() {
@@ -106,7 +113,8 @@
106113
;(function($, window, document, undefined){
107114

108115
var defaults = {
109-
colliders_context: document.body
116+
colliders_context: document.body,
117+
overlapping_region: 'C'
110118
// ,on_overlap: function(collider_data){},
111119
// on_overlap_start : function(collider_data){},
112120
// on_overlap_stop : function(collider_data){}
@@ -124,6 +132,9 @@
124132
* of HTMLElements or an Array of Coords instances.
125133
* @param {Object} [options] An Object with all options you want to
126134
* overwrite:
135+
* @param {String} [options.overlapping_region] Determines when collision
136+
* is valid, depending on the overlapped area. Values can be: 'N', 'S',
137+
* 'W', 'E', 'C' or 'all'. Default is 'C'.
127138
* @param {Function} [options.on_overlap_start] Executes a function the first
128139
* time each `collider ` is overlapped.
129140
* @param {Function} [options.on_overlap_stop] Executes a function when a
@@ -223,6 +234,7 @@
223234

224235
fn.find_collisions = function(player_data_coords){
225236
var self = this;
237+
var overlapping_region = this.options.overlapping_region;
226238
var colliders_coords = [];
227239
var colliders_data = [];
228240
var $colliders = (this.colliders || this.$colliders);
@@ -246,7 +258,8 @@
246258
player_coords, collider_coords);
247259

248260
//todo: make this an option
249-
if (region === 'C'){
261+
if (region === overlapping_region || overlapping_region === 'all') {
262+
250263
var area_coords = self.calculate_overlapped_area_coords(
251264
player_coords, collider_coords);
252265
var area = self.calculate_overlapped_area(area_coords);
@@ -464,8 +477,9 @@
464477
var fn = Draggable.prototype;
465478

466479
fn.init = function() {
480+
var pos = this.$container.css('position');
467481
this.calculate_dimensions();
468-
this.$container.css('position', 'relative');
482+
this.$container.css('position', pos === 'static' ? 'relative' : pos);
469483
this.disabled = false;
470484
this.events();
471485

@@ -3820,9 +3834,12 @@
38203834
* Destroy this gridster by removing any sign of its presence, making it easy to avoid memory leaks
38213835
*
38223836
* @method destroy
3823-
* @return {undefined}
3837+
* @param {Boolean} remove If true, remove gridster from DOM.
3838+
* @return {Object} Returns the instance of the Gridster class.
38243839
*/
3825-
fn.destroy = function(){
3840+
fn.destroy = function(remove) {
3841+
this.$el.removeData('gridster');
3842+
38263843
// remove bound callback on window resize
38273844
$(window).unbind('.gridster');
38283845

@@ -3832,10 +3849,7 @@
38323849

38333850
this.remove_style_tags();
38343851

3835-
// lastly, remove gridster element
3836-
// this will additionally cause any data associated to this element to be removed, including this
3837-
// very gridster instance
3838-
this.$el.remove();
3852+
remove && this.$el.remove();
38393853

38403854
return this;
38413855
};

dist/jquery.gridster.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.gridster.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.gridster.with-extras.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! gridster.js - v0.5.0 - 2014-02-14
1+
/*! gridster.js - v0.5.1 - 2014-03-05
22
* http://gridster.net/
33
* Copyright (c) 2014 ducksboard; Licensed MIT */
44

@@ -55,6 +55,9 @@
5555

5656
var d = this.data;
5757

58+
typeof d.left === 'undefined' && (d.left = d.x1);
59+
typeof d.top === 'undefined' && (d.top = d.y1);
60+
5861
this.coords.x1 = d.left;
5962
this.coords.y1 = d.top;
6063
this.coords.x2 = d.left + d.width;
@@ -89,6 +92,10 @@
8992
return this.coords;
9093
};
9194

95+
fn.destroy = function() {
96+
this.el.removeData('coords');
97+
delete this.el;
98+
};
9299

93100
//jQuery adapter
94101
$.fn.coords = function() {
@@ -106,7 +113,8 @@
106113
;(function($, window, document, undefined){
107114

108115
var defaults = {
109-
colliders_context: document.body
116+
colliders_context: document.body,
117+
overlapping_region: 'C'
110118
// ,on_overlap: function(collider_data){},
111119
// on_overlap_start : function(collider_data){},
112120
// on_overlap_stop : function(collider_data){}
@@ -124,6 +132,9 @@
124132
* of HTMLElements or an Array of Coords instances.
125133
* @param {Object} [options] An Object with all options you want to
126134
* overwrite:
135+
* @param {String} [options.overlapping_region] Determines when collision
136+
* is valid, depending on the overlapped area. Values can be: 'N', 'S',
137+
* 'W', 'E', 'C' or 'all'. Default is 'C'.
127138
* @param {Function} [options.on_overlap_start] Executes a function the first
128139
* time each `collider ` is overlapped.
129140
* @param {Function} [options.on_overlap_stop] Executes a function when a
@@ -223,6 +234,7 @@
223234

224235
fn.find_collisions = function(player_data_coords){
225236
var self = this;
237+
var overlapping_region = this.options.overlapping_region;
226238
var colliders_coords = [];
227239
var colliders_data = [];
228240
var $colliders = (this.colliders || this.$colliders);
@@ -246,7 +258,8 @@
246258
player_coords, collider_coords);
247259

248260
//todo: make this an option
249-
if (region === 'C'){
261+
if (region === overlapping_region || overlapping_region === 'all') {
262+
250263
var area_coords = self.calculate_overlapped_area_coords(
251264
player_coords, collider_coords);
252265
var area = self.calculate_overlapped_area(area_coords);
@@ -464,8 +477,9 @@
464477
var fn = Draggable.prototype;
465478

466479
fn.init = function() {
480+
var pos = this.$container.css('position');
467481
this.calculate_dimensions();
468-
this.$container.css('position', 'relative');
482+
this.$container.css('position', pos === 'static' ? 'relative' : pos);
469483
this.disabled = false;
470484
this.events();
471485

@@ -3820,9 +3834,12 @@
38203834
* Destroy this gridster by removing any sign of its presence, making it easy to avoid memory leaks
38213835
*
38223836
* @method destroy
3823-
* @return {undefined}
3837+
* @param {Boolean} remove If true, remove gridster from DOM.
3838+
* @return {Object} Returns the instance of the Gridster class.
38243839
*/
3825-
fn.destroy = function(){
3840+
fn.destroy = function(remove) {
3841+
this.$el.removeData('gridster');
3842+
38263843
// remove bound callback on window resize
38273844
$(window).unbind('.gridster');
38283845

@@ -3832,10 +3849,7 @@
38323849

38333850
this.remove_style_tags();
38343851

3835-
// lastly, remove gridster element
3836-
// this will additionally cause any data associated to this element to be removed, including this
3837-
// very gridster instance
3838-
this.$el.remove();
3852+
remove && this.$el.remove();
38393853

38403854
return this;
38413855
};

dist/jquery.gridster.with-extras.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gridster",
33
"title": "gridster.js",
44
"description": "a drag-and-drop multi-column jQuery grid plugin",
5-
"version": "0.5.0",
5+
"version": "0.5.1",
66
"homepage": "http://gridster.net/",
77
"author": {
88
"name": "ducksboard",

0 commit comments

Comments
 (0)