|
306 | 306 | this.draggable = this.isDraggable;
|
307 | 307 | },
|
308 | 308 | draggable: function () {
|
309 |
| - var self = this; |
| 309 | + const self = this; |
310 | 310 | if (this.interactObj === null || this.interactObj === undefined) {
|
311 | 311 | this.interactObj = interact(this.$refs.item);
|
312 | 312 | }
|
313 | 313 | if (this.draggable) {
|
314 |
| - var opts = { |
| 314 | + const opts = { |
315 | 315 | ignoreFrom: this.dragIgnoreFrom,
|
316 | 316 | allowFrom: this.dragAllowFrom
|
317 |
| - } |
| 317 | + }; |
318 | 318 | this.interactObj.draggable(opts);
|
319 | 319 | /*this.interactObj.draggable({allowFrom: '.vue-draggable-handle'});*/
|
320 | 320 | if (!this.dragEventSet) {
|
|
363 | 363 | this.createStyle();
|
364 | 364 | },
|
365 | 365 | renderRtl: function () {
|
| 366 | + console.log("### renderRtl"); |
| 367 | + this.tryMakeResizable(); |
366 | 368 | this.createStyle();
|
367 | 369 | }
|
368 | 370 | },
|
|
508 | 510 | if (position === null) return; // not possible but satisfies flow
|
509 | 511 | const {x, y} = position;
|
510 | 512 |
|
511 |
| - var shouldUpdate = false; |
| 513 | + let shouldUpdate = false; |
512 | 514 | const newPosition = {top: 0, left: 0};
|
513 | 515 | switch (event.type) {
|
514 | 516 | case "dragstart":
|
515 | 517 | this.previousX = this.innerX;
|
516 | 518 | this.previousY = this.innerY;
|
517 | 519 |
|
518 |
| - var parentRect = event.target.offsetParent.getBoundingClientRect(); |
519 |
| - var clientRect = event.target.getBoundingClientRect(); |
| 520 | + let parentRect = event.target.offsetParent.getBoundingClientRect(); |
| 521 | + let clientRect = event.target.getBoundingClientRect(); |
520 | 522 | if (this.renderRtl) {
|
521 | 523 | newPosition.left = (clientRect.right - parentRect.right) * -1;
|
522 | 524 | } else {
|
|
560 | 562 | }
|
561 | 563 |
|
562 | 564 | // Get new XY
|
| 565 | + let pos; |
563 | 566 | if (this.renderRtl) {
|
564 |
| - var pos = this.calcXY(newPosition.top, newPosition.left); |
| 567 | + pos = this.calcXY(newPosition.top, newPosition.left); |
565 | 568 | } else {
|
566 |
| - var pos = this.calcXY(newPosition.top, newPosition.left); |
| 569 | + pos = this.calcXY(newPosition.top, newPosition.left); |
567 | 570 | }
|
568 | 571 |
|
569 | 572 | this.lastX = x;
|
|
580 | 583 | calcPosition: function (x, y, w, h) {
|
581 | 584 | const colWidth = this.calcColWidth();
|
582 | 585 | // add rtl support
|
| 586 | + let out; |
583 | 587 | if (this.renderRtl) {
|
584 |
| - var out = { |
| 588 | + out = { |
585 | 589 | right: Math.round(colWidth * x + (x + 1) * this.margin[0]),
|
586 | 590 | top: Math.round(this.rowHeight * y + (y + 1) * this.margin[1]),
|
587 | 591 | // 0 * Infinity === NaN, which causes problems with resize constriants;
|
|
591 | 595 | height: h === Infinity ? h : Math.round(this.rowHeight * h + Math.max(0, h - 1) * this.margin[1])
|
592 | 596 | };
|
593 | 597 | } else {
|
594 |
| - var out = { |
| 598 | + out = { |
595 | 599 | left: Math.round(colWidth * x + (x + 1) * this.margin[0]),
|
596 | 600 | top: Math.round(this.rowHeight * y + (y + 1) * this.margin[1]),
|
597 | 601 | // 0 * Infinity === NaN, which causes problems with resize constriants;
|
|
633 | 637 | },
|
634 | 638 | // Helper for generating column width
|
635 | 639 | calcColWidth() {
|
636 |
| - var colWidth = (this.containerWidth - (this.margin[0] * (this.cols + 1))) / this.cols; |
| 640 | + const colWidth = (this.containerWidth - (this.margin[0] * (this.cols + 1))) / this.cols; |
637 | 641 | // console.log("### COLS=" + this.cols + " COL WIDTH=" + colWidth + " MARGIN " + this.margin[0]);
|
638 | 642 | return colWidth;
|
639 | 643 | },
|
|
668 | 672 | this.createStyle();
|
669 | 673 | },
|
670 | 674 | tryMakeResizable: function(){
|
671 |
| - var self = this; |
| 675 | + const self = this; |
672 | 676 | if (this.interactObj === null || this.interactObj === undefined) {
|
673 | 677 | this.interactObj = interact(this.$refs.item);
|
674 | 678 | }
|
675 | 679 | if (this.resizable) {
|
676 | 680 | let maximum = this.calcPosition(0,0,this.maxW, this.maxH);
|
677 | 681 | let minimum = this.calcPosition(0,0, this.minW, this.minH);
|
678 | 682 |
|
679 |
| - var opts = { |
| 683 | + // console.log("### MAX " + JSON.stringify(maximum)); |
| 684 | + // console.log("### MIN " + JSON.stringify(minimum)); |
| 685 | +
|
| 686 | + const opts = { |
680 | 687 | preserveAspectRatio: false,
|
681 | 688 | edges: {
|
682 | 689 | left: false,
|
|
711 | 718 | });
|
712 | 719 | }
|
713 | 720 | },
|
714 |
| - autoSize: function() |
715 |
| - { |
| 721 | + autoSize: function() { |
716 | 722 | // ok here we want to calculate if a resize is needed
|
717 | 723 | this.previousW = this.innerW;
|
718 | 724 | this.previousH = this.innerH;
|
|
0 commit comments