Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add resize_widget_dimensions() to change widget dimensions after gridster initialization #336

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7fe912f
add resize_widget_dimension()
hrosenbauer Apr 1, 2014
6554499
fix min-width and min-height after resize
hrosenbauer Apr 8, 2014
dd6c742
fix(draggable): bind drag events to $document
hrosenbauer Apr 14, 2014
93c46ff
fix(gridster): Removing previously added style tags before adding new…
dasmall Apr 10, 2014
c726c4a
fix(draggable): fix offset during drag
hrosenbauer Apr 8, 2014
bb7463a
fix(draggable): replaced scrollX/Y with scrollLeft/Top
hrosenbauer Apr 8, 2014
7d22e6c
fix(gridster): fix add_widget to use correct size_y when adding rows
kwak27 Apr 3, 2014
021a6c2
fix(draggable): handle both touch and click events
vieron Jun 16, 2014
c554aa8
Release 0.5.2
vieron Jun 16, 2014
b232391
chore: move sorting methods in prototype to the constructor
vieron Jun 24, 2014
aef185c
style: some formatting changes
vieron Jun 24, 2014
8ec307b
feat(gridster): move widget up when added if there is space available
vieron Jun 24, 2014
5c6d25c
fix(gridster): sort widgets appropriately when reading them from DOM
vieron Jun 24, 2014
589d7fd
feat: make gridster AMD compatible
vieron Jun 24, 2014
a9c76d5
feature(gridster): added `auto_init` config option, default to true
vieron Jun 25, 2014
21a294c
chore: add reference to defaults in constructors
vieron Jun 25, 2014
6bcfa6e
fix(gridster): custom `ignore_dragging` overwrites the default value
vieron Jun 25, 2014
c0bc1b9
add resize_widget_dimension()
hrosenbauer Apr 1, 2014
c9ecfdb
fix min-width and min-height after resize
hrosenbauer Apr 8, 2014
97cc8b3
Merge branch 'resize-widget-dimensions' of https://github.com/rebugge…
hrosenbauer Jun 26, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
<a name="v0.5.2"></a>
### v0.5.2 (2014-06-16)


#### Bug Fixes

* **draggable:**
* handle both touch and click events ([021a6c23](http://github.com/ducksboard/gridster.js/commit/021a6c23e851210c1b817bd353a1e5e19ce10b90), closes [#207](http://github.com/ducksboard/gridster.js/issues/207), [#236](http://github.com/ducksboard/gridster.js/issues/236), [#329](http://github.com/ducksboard/gridster.js/issues/329), [#380](http://github.com/ducksboard/gridster.js/issues/380))
* replaced scrollX/Y with scrollLeft/Top ([bb7463a3](http://github.com/ducksboard/gridster.js/commit/bb7463a3241750397492dfbac133cea193f0254f))
* fix offset during drag ([c726c4ad](http://github.com/ducksboard/gridster.js/commit/c726c4ad9c18fea95e4b46b9bacd36c42aa9691c))
* bind drag events to $document ([dd6c7420](http://github.com/ducksboard/gridster.js/commit/dd6c7420087d5810a9f6b02bf9d81a04a60ae840))
* **gridster:**
* fix add_widget to use correct size_y when adding rows ([7d22e6c8](http://github.com/ducksboard/gridster.js/commit/7d22e6c8b201de33e33def77a93dc9009d0aa4cb))
* Removing previously added style tags before adding new one. ([93c46ff4](http://github.com/ducksboard/gridster.js/commit/93c46ff45ebe59f3658b7f32f05b67109aa87311))


#### Features

* **draggable:**
* allow ignore_dragging config option to be a function ([69fcfe45](http://github.com/ducksboard/gridster.js/commit/69fcfe459678e833cb53de040b9fbc96dd687543))
* option to not remove helper on drag stop ([03910df9](http://github.com/ducksboard/gridster.js/commit/03910df967a1ae7bcb2fa3aadd58255e0bcbf327))

<a name="v0.5.1"></a>
### v0.5.1 (2014-03-05)

Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.gridster.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! gridster.js - v0.5.1 - 2014-03-26
/*! gridster.js - v0.5.2 - 2014-06-16
* http://gridster.net/
* Copyright (c) 2014 ducksboard; Licensed MIT */

Expand Down
37 changes: 22 additions & 15 deletions dist/jquery.gridster.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! gridster.js - v0.5.1 - 2014-03-26
/*! gridster.js - v0.5.2 - 2014-06-16
* http://gridster.net/
* Copyright (c) 2014 ducksboard; Licensed MIT */

Expand Down Expand Up @@ -430,9 +430,9 @@
var dir_map = { x : 'left', y : 'top' };
var isTouch = !!('ontouchstart' in window);
var pointer_events = {
start: isTouch ? 'touchstart.gridster-draggable' : 'mousedown.gridster-draggable',
move: isTouch ? 'touchmove.gridster-draggable' : 'mousemove.gridster-draggable',
end: isTouch ? 'touchend.gridster-draggable' : 'mouseup.gridster-draggable'
start: 'touchstart.gridster-draggable mousedown.gridster-draggable',
move: 'touchmove.gridster-draggable mousemove.gridster-draggable',
end: 'touchend.gridster-draggable mouseup.gridster-draggable'
};

var capitalize = function(str) {
Expand Down Expand Up @@ -467,7 +467,7 @@
*/
function Draggable(el, options) {
this.options = $.extend({}, defaults, options);
this.$body = $(document.body);
this.$document = $(document);
this.$container = $(el);
this.$dragitems = $(this.options.items, this.$container);
this.is_dragging = false;
Expand Down Expand Up @@ -495,10 +495,10 @@
this.$container.on(pointer_events.start, this.options.items,
$.proxy(this.drag_handler, this));

this.$body.on(pointer_events.end, $.proxy(function(e) {
this.$document.on(pointer_events.end, $.proxy(function(e) {
this.is_dragging = false;
if (this.disabled) { return; }
this.$body.off(pointer_events.move);
this.$document.off(pointer_events.move);
if (this.drag_start) {
this.on_dragstop(e);
}
Expand All @@ -512,7 +512,7 @@


fn.get_mouse_pos = function(e) {
if (isTouch) {
if (e.originalEvent && e.originalEvent.touches) {
var oe = e.originalEvent;
e = oe.touches.length ? oe.touches[0] : oe.changedTouches[0];
}
Expand All @@ -532,9 +532,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 + this.scroll_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 + this.scroll_offset_y);
diff_y - this.baseY + $(window).scrollTop() - this.win_offset_y);

if (this.options.limit) {
if (left > this.player_max_left) {
Expand All @@ -552,8 +552,8 @@
pointer: {
left: mouse_actual_pos.left,
top: mouse_actual_pos.top,
diff_left: diff_x + this.scroll_offset_x,
diff_top: diff_y + this.scroll_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 @@ -636,6 +636,7 @@

fn.drag_handler = function(e) {
var node = e.target.nodeName;
// skip if drag is disabled, or click was not done with the mouse primary button
if (this.disabled || e.which !== 1 && !isTouch) {
return;
}
Expand All @@ -652,7 +653,7 @@
this.mouse_init_pos = this.get_mouse_pos(e);
this.offsetY = this.mouse_init_pos.top - this.el_init_pos.top;

this.$body.on(pointer_events.move, function(mme) {
this.$document.on(pointer_events.move, function(mme) {
var mouse_actual_pos = self.get_mouse_pos(mme);
var diff_x = Math.abs(
mouse_actual_pos.left - self.mouse_init_pos.left);
Expand Down Expand Up @@ -700,6 +701,8 @@
this.helper = false;
}

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 @@ -777,7 +780,7 @@
this.disable();

this.$container.off('.gridster-draggable');
this.$body.off('.gridster-draggable');
this.$document.off('.gridster-draggable');
$(window).off('.gridster-draggable');

$.removeData(this.$container, 'drag');
Expand Down Expand Up @@ -1028,7 +1031,9 @@
}else{
pos = {
col: col,
row: row
row: row,
size_x: size_x,
size_y: size_y
};

this.empty_cells(col, row, size_x, size_y);
Expand Down Expand Up @@ -3593,6 +3598,8 @@
(x - 1) * (opts.widget_margins[0] * 2)) + 'px; }\n');
}

this.remove_style_tags();

return this.add_style_tag(styles);
};

Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.gridster.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/jquery.gridster.min.js

Large diffs are not rendered by default.

37 changes: 22 additions & 15 deletions dist/jquery.gridster.with-extras.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! gridster.js - v0.5.1 - 2014-03-26
/*! gridster.js - v0.5.2 - 2014-06-16
* http://gridster.net/
* Copyright (c) 2014 ducksboard; Licensed MIT */

Expand Down Expand Up @@ -430,9 +430,9 @@
var dir_map = { x : 'left', y : 'top' };
var isTouch = !!('ontouchstart' in window);
var pointer_events = {
start: isTouch ? 'touchstart.gridster-draggable' : 'mousedown.gridster-draggable',
move: isTouch ? 'touchmove.gridster-draggable' : 'mousemove.gridster-draggable',
end: isTouch ? 'touchend.gridster-draggable' : 'mouseup.gridster-draggable'
start: 'touchstart.gridster-draggable mousedown.gridster-draggable',
move: 'touchmove.gridster-draggable mousemove.gridster-draggable',
end: 'touchend.gridster-draggable mouseup.gridster-draggable'
};

var capitalize = function(str) {
Expand Down Expand Up @@ -467,7 +467,7 @@
*/
function Draggable(el, options) {
this.options = $.extend({}, defaults, options);
this.$body = $(document.body);
this.$document = $(document);
this.$container = $(el);
this.$dragitems = $(this.options.items, this.$container);
this.is_dragging = false;
Expand Down Expand Up @@ -495,10 +495,10 @@
this.$container.on(pointer_events.start, this.options.items,
$.proxy(this.drag_handler, this));

this.$body.on(pointer_events.end, $.proxy(function(e) {
this.$document.on(pointer_events.end, $.proxy(function(e) {
this.is_dragging = false;
if (this.disabled) { return; }
this.$body.off(pointer_events.move);
this.$document.off(pointer_events.move);
if (this.drag_start) {
this.on_dragstop(e);
}
Expand All @@ -512,7 +512,7 @@


fn.get_mouse_pos = function(e) {
if (isTouch) {
if (e.originalEvent && e.originalEvent.touches) {
var oe = e.originalEvent;
e = oe.touches.length ? oe.touches[0] : oe.changedTouches[0];
}
Expand All @@ -532,9 +532,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 + this.scroll_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 + this.scroll_offset_y);
diff_y - this.baseY + $(window).scrollTop() - this.win_offset_y);

if (this.options.limit) {
if (left > this.player_max_left) {
Expand All @@ -552,8 +552,8 @@
pointer: {
left: mouse_actual_pos.left,
top: mouse_actual_pos.top,
diff_left: diff_x + this.scroll_offset_x,
diff_top: diff_y + this.scroll_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 @@ -636,6 +636,7 @@

fn.drag_handler = function(e) {
var node = e.target.nodeName;
// skip if drag is disabled, or click was not done with the mouse primary button
if (this.disabled || e.which !== 1 && !isTouch) {
return;
}
Expand All @@ -652,7 +653,7 @@
this.mouse_init_pos = this.get_mouse_pos(e);
this.offsetY = this.mouse_init_pos.top - this.el_init_pos.top;

this.$body.on(pointer_events.move, function(mme) {
this.$document.on(pointer_events.move, function(mme) {
var mouse_actual_pos = self.get_mouse_pos(mme);
var diff_x = Math.abs(
mouse_actual_pos.left - self.mouse_init_pos.left);
Expand Down Expand Up @@ -700,6 +701,8 @@
this.helper = false;
}

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 @@ -777,7 +780,7 @@
this.disable();

this.$container.off('.gridster-draggable');
this.$body.off('.gridster-draggable');
this.$document.off('.gridster-draggable');
$(window).off('.gridster-draggable');

$.removeData(this.$container, 'drag');
Expand Down Expand Up @@ -1028,7 +1031,9 @@
}else{
pos = {
col: col,
row: row
row: row,
size_x: size_x,
size_y: size_y
};

this.empty_cells(col, row, size_x, size_y);
Expand Down Expand Up @@ -3593,6 +3598,8 @@
(x - 1) * (opts.widget_margins[0] * 2)) + 'px; }\n');
}

this.remove_style_tags();

return this.add_style_tag(styles);
};

Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.gridster.with-extras.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "gridster",
"title": "gridster.js",
"description": "a drag-and-drop multi-column jQuery grid plugin",
"version": "0.5.1",
"version": "0.5.2",
"homepage": "http://gridster.net/",
"author": {
"name": "ducksboard",
Expand Down
15 changes: 13 additions & 2 deletions src/jquery.collision.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@
* Licensed under the MIT licenses.
*/

;(function($, window, document, undefined){
;(function(root, factory) {

if (typeof define === 'function' && define.amd) {
define('gridster-collision', ['jquery', 'gridster-coords'], factory);
} else {
root.GridsterCollision = factory(root.$ || root.jQuery,
root.GridsterCoords);
}

}(this, function($, Coords) {

var defaults = {
colliders_context: document.body,
Expand Down Expand Up @@ -50,6 +59,7 @@
this.init();
}

Collision.defaults = defaults;

var fn = Collision.prototype;

Expand Down Expand Up @@ -227,5 +237,6 @@
return new Collision( this, collider, options );
};

return Collision;

}(jQuery, window, document));
}));
14 changes: 12 additions & 2 deletions src/jquery.coords.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
* Licensed under the MIT licenses.
*/

;(function($, window, document, undefined){
;(function(root, factory) {

if (typeof define === 'function' && define.amd) {
define('gridster-coords', ['jquery'], factory);
} else {
root.GridsterCoords = factory(root.$ || root.jQuery);
}

}(this, function($) {
/**
* Creates objects with coordinates (x1, y1, x2, y2, cx, cy, width, height)
* to simulate DOM elements on the screen.
Expand Down Expand Up @@ -112,4 +120,6 @@
return ins;
};

}(jQuery, window, document));
return Coords;

}));
Loading