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.
@@ -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
  */
@@ -669,9 +669,7 @@ function onDidWindowResizeEnd(element, cb) {
669
669
  function shiftAbsoluteElementIntoView(element, root, options = { buffer: 10 }) {
670
670
  const buffer = options.buffer;
671
671
  const rect = element.getBoundingClientRect();
672
- const rootRect = element.getBoundingClientRect();
673
- const viewportWidth = root.clientWidth;
674
- const viewportHeight = root.clientHeight;
672
+ const rootRect = root.getBoundingClientRect();
675
673
  let translateX = 0;
676
674
  let translateY = 0;
677
675
  const left = rect.left - rootRect.left;
@@ -682,15 +680,15 @@ function shiftAbsoluteElementIntoView(element, root, options = { buffer: 10 }) {
682
680
  if (left < buffer) {
683
681
  translateX = buffer - left;
684
682
  }
685
- else if (right > viewportWidth - buffer) {
686
- translateX = viewportWidth - right - buffer;
683
+ else if (right > buffer) {
684
+ translateX = -buffer - right;
687
685
  }
688
686
  // Check vertical overflow
689
687
  if (top < buffer) {
690
688
  translateY = buffer - top;
691
689
  }
692
- else if (bottom > viewportHeight - buffer) {
693
- translateY = viewportHeight - bottom - buffer;
690
+ else if (bottom > buffer) {
691
+ translateY = -bottom - buffer;
694
692
  }
695
693
  // Apply the translation if needed
696
694
  if (translateX !== 0 || translateY !== 0) {
@@ -4971,6 +4969,8 @@ function addGhostImage(dataTransfer, ghostElement, options) {
4971
4969
  var _a, _b;
4972
4970
  // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
4973
4971
  addClasses(ghostElement, 'dv-dragged');
4972
+ // move the element off-screen initially otherwise it may in some cases be rendered at (0,0) momentarily
4973
+ ghostElement.style.top = '-9999px';
4974
4974
  document.body.appendChild(ghostElement);
4975
4975
  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);
4976
4976
  setTimeout(() => {