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