|
354 | 354 | float: false,
|
355 | 355 | _class: 'grid-stack-' + (Math.random() * 10000).toFixed(0),
|
356 | 356 | animate: Boolean(this.container.attr('data-gs-animate')) || false,
|
357 |
| - always_show_resize_handle: opts.always_show_resize_handle || false |
| 357 | + always_show_resize_handle: opts.always_show_resize_handle || false, |
| 358 | + resizable: _.defaults(opts.resizable || {}, { |
| 359 | + autoHide: !(opts.always_show_resize_handle || false), |
| 360 | + handles: 'se' |
| 361 | + }), |
| 362 | + draggable: _.defaults(opts.draggable || {}, { |
| 363 | + handle: '.grid-stack-item-content', |
| 364 | + scroll: true, |
| 365 | + appendTo: 'body', |
| 366 | + }) |
358 | 367 | });
|
359 | 368 |
|
360 | 369 | this.container.addClass(this.opts._class);
|
|
551 | 560 | self.grid.end_update();
|
552 | 561 | };
|
553 | 562 |
|
554 |
| - el.draggable({ |
555 |
| - handle: this.opts.handle, |
556 |
| - scroll: true, |
557 |
| - appendTo: 'body', |
558 |
| - |
| 563 | + el.draggable(_.extend(this.opts.draggable, { |
559 | 564 | start: on_start_moving,
|
560 | 565 | stop: on_end_moving,
|
561 | 566 | drag: function (event, ui) {
|
|
567 | 572 | self.grid.move_node(node, x, y);
|
568 | 573 | self._update_container_height();
|
569 | 574 | }
|
570 |
| - }).resizable({ |
571 |
| - autoHide: !this.opts.always_show_resize_handle, |
572 |
| - handles: 'se', |
| 575 | + })).resizable(_.extend(this.opts.resizable, { |
573 | 576 | minHeight: this.opts.cell_height - 10,
|
574 |
| - minWidth: 70, |
575 | 577 |
|
576 | 578 | start: on_start_moving,
|
577 | 579 | stop: on_end_moving,
|
578 | 580 | resize: function (event, ui) {
|
579 |
| - var width = Math.round(ui.size.width / cell_width), |
| 581 | + var x = Math.round(ui.position.left / cell_width), |
| 582 | + y = Math.floor((ui.position.top + cell_height/2) / cell_height), |
| 583 | + width = Math.round(ui.size.width / cell_width), |
580 | 584 | height = Math.round(ui.size.height / cell_height);
|
581 |
| - if (!self.grid.can_move_node(node, node.x, node.y, width, height)) { |
| 585 | + if (!self.grid.can_move_node(node, x, y, width, height)) { |
582 | 586 | return;
|
583 | 587 | }
|
584 |
| - self.grid.move_node(node, node.x, node.y, width, height); |
| 588 | + self.grid.move_node(node, x, y, width, height); |
585 | 589 | self._update_container_height();
|
586 | 590 | }
|
587 |
| - }); |
| 591 | + })); |
588 | 592 |
|
589 | 593 | if (node.no_move || this._is_one_column_mode()) {
|
590 | 594 | el.draggable('disable');
|
|
0 commit comments