|
627 | 627 |
|
628 | 628 | var cell_width, cell_height; |
629 | 629 |
|
| 630 | + var drag_or_resize = function(event, ui) { |
| 631 | + var x = Math.round(ui.position.left / cell_width), |
| 632 | + y = Math.floor((ui.position.top + cell_height / 2) / cell_height), |
| 633 | + width, height; |
| 634 | + if (event.type != "drag") { |
| 635 | + width = Math.round(ui.size.width / cell_width); |
| 636 | + height = Math.round(ui.size.height / cell_height); |
| 637 | + } |
| 638 | + |
| 639 | + if (!self.grid.can_move_node(node, x, y, width, height)) { |
| 640 | + return; |
| 641 | + } |
| 642 | + self.grid.move_node(node, x, y, width, height); |
| 643 | + self._update_container_height(); |
| 644 | + }; |
| 645 | + |
630 | 646 | var on_start_moving = function(event, ui) { |
631 | 647 | self.container.append(self.placeholder); |
632 | 648 | var o = $(this); |
|
663 | 679 | self.grid.end_update(); |
664 | 680 | }; |
665 | 681 |
|
666 | | - el.draggable(_.extend(this.opts.draggable, { |
667 | | - start: on_start_moving, |
668 | | - stop: on_end_moving, |
669 | | - drag: function(event, ui) { |
670 | | - var x = Math.round(ui.position.left / cell_width), |
671 | | - y = Math.floor((ui.position.top + cell_height / 2) / cell_height); |
672 | | - if (!self.grid.can_move_node(node, x, y, node.width, node.height)) { |
673 | | - return; |
674 | | - } |
675 | | - self.grid.move_node(node, x, y); |
676 | | - self._update_container_height(); |
677 | | - }, |
| 682 | + el |
| 683 | + .draggable(_.extend(this.opts.draggable, { |
678 | 684 | containment: this.opts.is_nested ? this.container.parent() : null |
679 | | - })).resizable(_.extend(this.opts.resizable, { |
680 | | - start: on_start_moving, |
681 | | - stop: on_end_moving, |
682 | | - resize: function(event, ui) { |
683 | | - var x = Math.round(ui.position.left / cell_width), |
684 | | - y = Math.floor((ui.position.top + cell_height / 2) / cell_height), |
685 | | - width = Math.round(ui.size.width / cell_width), |
686 | | - height = Math.round(ui.size.height / cell_height); |
687 | | - if (!self.grid.can_move_node(node, x, y, width, height)) { |
688 | | - return; |
689 | | - } |
690 | | - self.grid.move_node(node, x, y, width, height); |
691 | | - self._update_container_height(); |
692 | | - } |
693 | | - })); |
| 685 | + })) |
| 686 | + .on("dragstart", on_start_moving) |
| 687 | + .on("dragstop", on_end_moving) |
| 688 | + .on("drag", drag_or_resize) |
| 689 | + .resizable(_.extend(this.opts.resizable, {})) |
| 690 | + .on("resizestart", on_start_moving) |
| 691 | + .on("resizestop", on_end_moving) |
| 692 | + .on("resize", drag_or_resize); |
694 | 693 |
|
695 | 694 | if (node.no_move || this._is_one_column_mode()) { |
696 | 695 | el.draggable('disable'); |
|
0 commit comments