Skip to content

Commit c554aa8

Browse files
committed
Release 0.5.2
1 parent 021a6c2 commit c554aa8

8 files changed

+73
-38
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
<a name="v0.5.2"></a>
2+
### v0.5.2 (2014-06-16)
3+
4+
5+
#### Bug Fixes
6+
7+
* **draggable:**
8+
* 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))
9+
* replaced scrollX/Y with scrollLeft/Top ([bb7463a3](http://github.com/ducksboard/gridster.js/commit/bb7463a3241750397492dfbac133cea193f0254f))
10+
* fix offset during drag ([c726c4ad](http://github.com/ducksboard/gridster.js/commit/c726c4ad9c18fea95e4b46b9bacd36c42aa9691c))
11+
* bind drag events to $document ([dd6c7420](http://github.com/ducksboard/gridster.js/commit/dd6c7420087d5810a9f6b02bf9d81a04a60ae840))
12+
* **gridster:**
13+
* fix add_widget to use correct size_y when adding rows ([7d22e6c8](http://github.com/ducksboard/gridster.js/commit/7d22e6c8b201de33e33def77a93dc9009d0aa4cb))
14+
* Removing previously added style tags before adding new one. ([93c46ff4](http://github.com/ducksboard/gridster.js/commit/93c46ff45ebe59f3658b7f32f05b67109aa87311))
15+
16+
17+
#### Features
18+
19+
* **draggable:**
20+
* allow ignore_dragging config option to be a function ([69fcfe45](http://github.com/ducksboard/gridster.js/commit/69fcfe459678e833cb53de040b9fbc96dd687543))
21+
* option to not remove helper on drag stop ([03910df9](http://github.com/ducksboard/gridster.js/commit/03910df967a1ae7bcb2fa3aadd58255e0bcbf327))
22+
123
<a name="v0.5.1"></a>
224
### v0.5.1 (2014-03-05)
325

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.1 - 2014-03-26
1+
/*! gridster.js - v0.5.2 - 2014-06-16
22
* http://gridster.net/
33
* Copyright (c) 2014 ducksboard; Licensed MIT */
44

dist/jquery.gridster.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! gridster.js - v0.5.1 - 2014-03-26
1+
/*! gridster.js - v0.5.2 - 2014-06-16
22
* http://gridster.net/
33
* Copyright (c) 2014 ducksboard; Licensed MIT */
44

@@ -430,9 +430,9 @@
430430
var dir_map = { x : 'left', y : 'top' };
431431
var isTouch = !!('ontouchstart' in window);
432432
var pointer_events = {
433-
start: isTouch ? 'touchstart.gridster-draggable' : 'mousedown.gridster-draggable',
434-
move: isTouch ? 'touchmove.gridster-draggable' : 'mousemove.gridster-draggable',
435-
end: isTouch ? 'touchend.gridster-draggable' : 'mouseup.gridster-draggable'
433+
start: 'touchstart.gridster-draggable mousedown.gridster-draggable',
434+
move: 'touchmove.gridster-draggable mousemove.gridster-draggable',
435+
end: 'touchend.gridster-draggable mouseup.gridster-draggable'
436436
};
437437

438438
var capitalize = function(str) {
@@ -467,7 +467,7 @@
467467
*/
468468
function Draggable(el, options) {
469469
this.options = $.extend({}, defaults, options);
470-
this.$body = $(document.body);
470+
this.$document = $(document);
471471
this.$container = $(el);
472472
this.$dragitems = $(this.options.items, this.$container);
473473
this.is_dragging = false;
@@ -495,10 +495,10 @@
495495
this.$container.on(pointer_events.start, this.options.items,
496496
$.proxy(this.drag_handler, this));
497497

498-
this.$body.on(pointer_events.end, $.proxy(function(e) {
498+
this.$document.on(pointer_events.end, $.proxy(function(e) {
499499
this.is_dragging = false;
500500
if (this.disabled) { return; }
501-
this.$body.off(pointer_events.move);
501+
this.$document.off(pointer_events.move);
502502
if (this.drag_start) {
503503
this.on_dragstop(e);
504504
}
@@ -512,7 +512,7 @@
512512

513513

514514
fn.get_mouse_pos = function(e) {
515-
if (isTouch) {
515+
if (e.originalEvent && e.originalEvent.touches) {
516516
var oe = e.originalEvent;
517517
e = oe.touches.length ? oe.touches[0] : oe.changedTouches[0];
518518
}
@@ -532,9 +532,9 @@
532532
var diff_y = Math.round(mouse_actual_pos.top - this.mouse_init_pos.top);
533533

534534
var left = Math.round(this.el_init_offset.left +
535-
diff_x - this.baseX + this.scroll_offset_x);
535+
diff_x - this.baseX + $(window).scrollLeft() - this.win_offset_x);
536536
var top = Math.round(this.el_init_offset.top +
537-
diff_y - this.baseY + this.scroll_offset_y);
537+
diff_y - this.baseY + $(window).scrollTop() - this.win_offset_y);
538538

539539
if (this.options.limit) {
540540
if (left > this.player_max_left) {
@@ -552,8 +552,8 @@
552552
pointer: {
553553
left: mouse_actual_pos.left,
554554
top: mouse_actual_pos.top,
555-
diff_left: diff_x + this.scroll_offset_x,
556-
diff_top: diff_y + this.scroll_offset_y
555+
diff_left: diff_x + ($(window).scrollLeft() - this.win_offset_x),
556+
diff_top: diff_y + ($(window).scrollTop() - this.win_offset_y)
557557
}
558558
};
559559
};
@@ -636,6 +636,7 @@
636636

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

655-
this.$body.on(pointer_events.move, function(mme) {
656+
this.$document.on(pointer_events.move, function(mme) {
656657
var mouse_actual_pos = self.get_mouse_pos(mme);
657658
var diff_x = Math.abs(
658659
mouse_actual_pos.left - self.mouse_init_pos.left);
@@ -700,6 +701,8 @@
700701
this.helper = false;
701702
}
702703

704+
this.win_offset_y = $(window).scrollTop();
705+
this.win_offset_x = $(window).scrollLeft();
703706
this.scroll_offset_y = 0;
704707
this.scroll_offset_x = 0;
705708
this.el_init_offset = this.$player.offset();
@@ -777,7 +780,7 @@
777780
this.disable();
778781

779782
this.$container.off('.gridster-draggable');
780-
this.$body.off('.gridster-draggable');
783+
this.$document.off('.gridster-draggable');
781784
$(window).off('.gridster-draggable');
782785

783786
$.removeData(this.$container, 'drag');
@@ -1028,7 +1031,9 @@
10281031
}else{
10291032
pos = {
10301033
col: col,
1031-
row: row
1034+
row: row,
1035+
size_x: size_x,
1036+
size_y: size_y
10321037
};
10331038

10341039
this.empty_cells(col, row, size_x, size_y);
@@ -3592,8 +3597,8 @@
35923597
(x * opts.widget_base_dimensions[0] +
35933598
(x - 1) * (opts.widget_margins[0] * 2)) + 'px; }\n');
35943599
}
3595-
3596-
this.remove_style_tags();
3600+
3601+
this.remove_style_tags();
35973602

35983603
return this.add_style_tag(styles);
35993604
};

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 & 1 deletion
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: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! gridster.js - v0.5.1 - 2014-03-26
1+
/*! gridster.js - v0.5.2 - 2014-06-16
22
* http://gridster.net/
33
* Copyright (c) 2014 ducksboard; Licensed MIT */
44

@@ -430,9 +430,9 @@
430430
var dir_map = { x : 'left', y : 'top' };
431431
var isTouch = !!('ontouchstart' in window);
432432
var pointer_events = {
433-
start: isTouch ? 'touchstart.gridster-draggable' : 'mousedown.gridster-draggable',
434-
move: isTouch ? 'touchmove.gridster-draggable' : 'mousemove.gridster-draggable',
435-
end: isTouch ? 'touchend.gridster-draggable' : 'mouseup.gridster-draggable'
433+
start: 'touchstart.gridster-draggable mousedown.gridster-draggable',
434+
move: 'touchmove.gridster-draggable mousemove.gridster-draggable',
435+
end: 'touchend.gridster-draggable mouseup.gridster-draggable'
436436
};
437437

438438
var capitalize = function(str) {
@@ -467,7 +467,7 @@
467467
*/
468468
function Draggable(el, options) {
469469
this.options = $.extend({}, defaults, options);
470-
this.$body = $(document.body);
470+
this.$document = $(document);
471471
this.$container = $(el);
472472
this.$dragitems = $(this.options.items, this.$container);
473473
this.is_dragging = false;
@@ -495,10 +495,10 @@
495495
this.$container.on(pointer_events.start, this.options.items,
496496
$.proxy(this.drag_handler, this));
497497

498-
this.$body.on(pointer_events.end, $.proxy(function(e) {
498+
this.$document.on(pointer_events.end, $.proxy(function(e) {
499499
this.is_dragging = false;
500500
if (this.disabled) { return; }
501-
this.$body.off(pointer_events.move);
501+
this.$document.off(pointer_events.move);
502502
if (this.drag_start) {
503503
this.on_dragstop(e);
504504
}
@@ -512,7 +512,7 @@
512512

513513

514514
fn.get_mouse_pos = function(e) {
515-
if (isTouch) {
515+
if (e.originalEvent && e.originalEvent.touches) {
516516
var oe = e.originalEvent;
517517
e = oe.touches.length ? oe.touches[0] : oe.changedTouches[0];
518518
}
@@ -532,9 +532,9 @@
532532
var diff_y = Math.round(mouse_actual_pos.top - this.mouse_init_pos.top);
533533

534534
var left = Math.round(this.el_init_offset.left +
535-
diff_x - this.baseX + this.scroll_offset_x);
535+
diff_x - this.baseX + $(window).scrollLeft() - this.win_offset_x);
536536
var top = Math.round(this.el_init_offset.top +
537-
diff_y - this.baseY + this.scroll_offset_y);
537+
diff_y - this.baseY + $(window).scrollTop() - this.win_offset_y);
538538

539539
if (this.options.limit) {
540540
if (left > this.player_max_left) {
@@ -552,8 +552,8 @@
552552
pointer: {
553553
left: mouse_actual_pos.left,
554554
top: mouse_actual_pos.top,
555-
diff_left: diff_x + this.scroll_offset_x,
556-
diff_top: diff_y + this.scroll_offset_y
555+
diff_left: diff_x + ($(window).scrollLeft() - this.win_offset_x),
556+
diff_top: diff_y + ($(window).scrollTop() - this.win_offset_y)
557557
}
558558
};
559559
};
@@ -636,6 +636,7 @@
636636

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

655-
this.$body.on(pointer_events.move, function(mme) {
656+
this.$document.on(pointer_events.move, function(mme) {
656657
var mouse_actual_pos = self.get_mouse_pos(mme);
657658
var diff_x = Math.abs(
658659
mouse_actual_pos.left - self.mouse_init_pos.left);
@@ -700,6 +701,8 @@
700701
this.helper = false;
701702
}
702703

704+
this.win_offset_y = $(window).scrollTop();
705+
this.win_offset_x = $(window).scrollLeft();
703706
this.scroll_offset_y = 0;
704707
this.scroll_offset_x = 0;
705708
this.el_init_offset = this.$player.offset();
@@ -777,7 +780,7 @@
777780
this.disable();
778781

779782
this.$container.off('.gridster-draggable');
780-
this.$body.off('.gridster-draggable');
783+
this.$document.off('.gridster-draggable');
781784
$(window).off('.gridster-draggable');
782785

783786
$.removeData(this.$container, 'drag');
@@ -1028,7 +1031,9 @@
10281031
}else{
10291032
pos = {
10301033
col: col,
1031-
row: row
1034+
row: row,
1035+
size_x: size_x,
1036+
size_y: size_y
10321037
};
10331038

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

3601+
this.remove_style_tags();
3602+
35963603
return this.add_style_tag(styles);
35973604
};
35983605

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.1",
5+
"version": "0.5.2",
66
"homepage": "http://gridster.net/",
77
"author": {
88
"name": "ducksboard",

0 commit comments

Comments
 (0)