dockview-core 4.2.4 → 4.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,8 @@ function addGhostImage(dataTransfer, ghostElement, options) {
6
6
  var _a, _b;
7
7
  // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
8
8
  (0, dom_1.addClasses)(ghostElement, 'dv-dragged');
9
+ // move the element off-screen initially otherwise it may in some cases be rendered at (0,0) momentarily
10
+ ghostElement.style.top = '-9999px';
9
11
  document.body.appendChild(ghostElement);
10
12
  dataTransfer.setDragImage(ghostElement, (_a = options === null || options === void 0 ? void 0 : options.x) !== null && _a !== void 0 ? _a : 0, (_b = options === null || options === void 0 ? void 0 : options.y) !== null && _b !== void 0 ? _b : 0);
11
13
  setTimeout(function () {
package/dist/cjs/dom.js CHANGED
@@ -482,9 +482,7 @@ function shiftAbsoluteElementIntoView(element, root, options) {
482
482
  if (options === void 0) { options = { buffer: 10 }; }
483
483
  var buffer = options.buffer;
484
484
  var rect = element.getBoundingClientRect();
485
- var rootRect = element.getBoundingClientRect();
486
- var viewportWidth = root.clientWidth;
487
- var viewportHeight = root.clientHeight;
485
+ var rootRect = root.getBoundingClientRect();
488
486
  var translateX = 0;
489
487
  var translateY = 0;
490
488
  var left = rect.left - rootRect.left;
@@ -495,15 +493,15 @@ function shiftAbsoluteElementIntoView(element, root, options) {
495
493
  if (left < buffer) {
496
494
  translateX = buffer - left;
497
495
  }
498
- else if (right > viewportWidth - buffer) {
499
- translateX = viewportWidth - right - buffer;
496
+ else if (right > buffer) {
497
+ translateX = -buffer - right;
500
498
  }
501
499
  // Check vertical overflow
502
500
  if (top < buffer) {
503
501
  translateY = buffer - top;
504
502
  }
505
- else if (bottom > viewportHeight - buffer) {
506
- translateY = viewportHeight - bottom - buffer;
503
+ else if (bottom > buffer) {
504
+ translateY = -bottom - buffer;
507
505
  }
508
506
  // Apply the translation if needed
509
507
  if (translateX !== 0 || translateY !== 0) {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 4.2.4
3
+ * @version 4.2.5
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -671,9 +671,7 @@ define(['exports'], (function (exports) { 'use strict';
671
671
  function shiftAbsoluteElementIntoView(element, root, options = { buffer: 10 }) {
672
672
  const buffer = options.buffer;
673
673
  const rect = element.getBoundingClientRect();
674
- const rootRect = element.getBoundingClientRect();
675
- const viewportWidth = root.clientWidth;
676
- const viewportHeight = root.clientHeight;
674
+ const rootRect = root.getBoundingClientRect();
677
675
  let translateX = 0;
678
676
  let translateY = 0;
679
677
  const left = rect.left - rootRect.left;
@@ -684,15 +682,15 @@ define(['exports'], (function (exports) { 'use strict';
684
682
  if (left < buffer) {
685
683
  translateX = buffer - left;
686
684
  }
687
- else if (right > viewportWidth - buffer) {
688
- translateX = viewportWidth - right - buffer;
685
+ else if (right > buffer) {
686
+ translateX = -buffer - right;
689
687
  }
690
688
  // Check vertical overflow
691
689
  if (top < buffer) {
692
690
  translateY = buffer - top;
693
691
  }
694
- else if (bottom > viewportHeight - buffer) {
695
- translateY = viewportHeight - bottom - buffer;
692
+ else if (bottom > buffer) {
693
+ translateY = -bottom - buffer;
696
694
  }
697
695
  // Apply the translation if needed
698
696
  if (translateX !== 0 || translateY !== 0) {
@@ -4973,6 +4971,8 @@ define(['exports'], (function (exports) { 'use strict';
4973
4971
  var _a, _b;
4974
4972
  // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
4975
4973
  addClasses(ghostElement, 'dv-dragged');
4974
+ // move the element off-screen initially otherwise it may in some cases be rendered at (0,0) momentarily
4975
+ ghostElement.style.top = '-9999px';
4976
4976
  document.body.appendChild(ghostElement);
4977
4977
  dataTransfer.setDragImage(ghostElement, (_a = options === null || options === void 0 ? void 0 : options.x) !== null && _a !== void 0 ? _a : 0, (_b = options === null || options === void 0 ? void 0 : options.y) !== null && _b !== void 0 ? _b : 0);
4978
4978
  setTimeout(() => {