Skip to content

Commit 8314837

Browse files
committed
build js
1 parent 6017f34 commit 8314837

File tree

3 files changed

+55
-32
lines changed

3 files changed

+55
-32
lines changed

dist/gridstack.js

Lines changed: 53 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,22 @@
635635

636636
var cell_width, cell_height;
637637

638+
var drag_or_resize = function(event, ui) {
639+
var x = Math.round(ui.position.left / cell_width),
640+
y = Math.floor((ui.position.top + cell_height / 2) / cell_height),
641+
width, height;
642+
if (event.type != "drag") {
643+
width = Math.round(ui.size.width / cell_width);
644+
height = Math.round(ui.size.height / cell_height);
645+
}
646+
647+
if (!self.grid.can_move_node(node, x, y, width, height)) {
648+
return;
649+
}
650+
self.grid.move_node(node, x, y, width, height);
651+
self._update_container_height();
652+
};
653+
638654
var on_start_moving = function(event, ui) {
639655
self.container.append(self.placeholder);
640656
var o = $(this);
@@ -652,6 +668,10 @@
652668

653669
el.resizable('option', 'minWidth', Math.round(cell_width * (node.min_width || 1)));
654670
el.resizable('option', 'minHeight', self.opts.cell_height * (node.min_height || 1));
671+
672+
if (event.type == 'resizestart') {
673+
o.find('.grid-stack-item').trigger('resizestart');
674+
}
655675
};
656676

657677
var on_end_moving = function(event, ui) {
@@ -669,36 +689,27 @@
669689
self._trigger_change_event();
670690

671691
self.grid.end_update();
672-
};
673692

674-
el.draggable(_.extend(this.opts.draggable, {
675-
start: on_start_moving,
676-
stop: on_end_moving,
677-
drag: function(event, ui) {
678-
var x = Math.round(ui.position.left / cell_width),
679-
y = Math.floor((ui.position.top + cell_height / 2) / cell_height);
680-
if (!self.grid.can_move_node(node, x, y, node.width, node.height)) {
681-
return;
682-
}
683-
self.grid.move_node(node, x, y);
684-
self._update_container_height();
685-
},
686-
containment: this.opts.is_nested ? this.container.parent() : null
687-
})).resizable(_.extend(this.opts.resizable, {
688-
start: on_start_moving,
689-
stop: on_end_moving,
690-
resize: function(event, ui) {
691-
var x = Math.round(ui.position.left / cell_width),
692-
y = Math.floor((ui.position.top + cell_height / 2) / cell_height),
693-
width = Math.round(ui.size.width / cell_width),
694-
height = Math.round(ui.size.height / cell_height);
695-
if (!self.grid.can_move_node(node, x, y, width, height)) {
696-
return;
697-
}
698-
self.grid.move_node(node, x, y, width, height);
699-
self._update_container_height();
693+
var nested_grids = o.find('.grid-stack');
694+
if (nested_grids.length && event.type == 'resizestop') {
695+
nested_grids.each(function(index, el) {
696+
$(el).data('gridstack').on_resize_handler();
697+
});
698+
o.find('.grid-stack-item').trigger('resizestop');
700699
}
701-
}));
700+
};
701+
702+
el
703+
.draggable(_.extend(this.opts.draggable, {
704+
containment: this.opts.is_nested ? this.container.parent() : null
705+
}))
706+
.on('dragstart', on_start_moving)
707+
.on('dragstop', on_end_moving)
708+
.on('drag', drag_or_resize)
709+
.resizable(_.extend(this.opts.resizable, {}))
710+
.on('resizestart', on_start_moving)
711+
.on('resizestop', on_end_moving)
712+
.on('resize', drag_or_resize);
702713

703714
if (node.no_move || this._is_one_column_mode()) {
704715
el.draggable('disable');
@@ -980,10 +991,22 @@
980991

981992
scope.GridStackUI.Utils = Utils;
982993

994+
function event_stop_propagate(event) {
995+
event.stopPropagation();
996+
}
983997
$.fn.gridstack = function(opts) {
984998
return this.each(function() {
985-
if (!$(this).data('gridstack')) {
986-
$(this).data('gridstack', new GridStack(this, opts));
999+
var o = $(this);
1000+
if (!o.data('gridstack')) {
1001+
o
1002+
.data('gridstack', new GridStack(this, opts))
1003+
.on('dragstart', event_stop_propagate)
1004+
.on('dragstop', event_stop_propagate)
1005+
.on('drag', event_stop_propagate)
1006+
.on('resizestart', event_stop_propagate)
1007+
.on('resizestop', event_stop_propagate)
1008+
.on('resize', event_stop_propagate)
1009+
.on('change', event_stop_propagate);
9871010
}
9881011
});
9891012
};

0 commit comments

Comments
 (0)