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