Skip to content

Commit f7c22fb

Browse files
committed
fix(vtkMouseBoxSelectorManipulator.applyStyleToDiv): rectangle position
Fixed a problem with rectangle rendering. It didn't render to right position if container is having margins or page is scrolled. This fix closes issue #2177.
1 parent 758989e commit f7c22fb

File tree

1 file changed

+5
-3
lines changed
  • Sources/Interaction/Manipulators/MouseBoxSelectorManipulator

1 file changed

+5
-3
lines changed

Sources/Interaction/Manipulators/MouseBoxSelectorManipulator/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ function vtkMouseBoxSelectionManipulator(publicAPI, model) {
5151
return;
5252
}
5353
const [viewWidth, viewHeight] = view.getSize();
54-
const { width, height } = container.getBoundingClientRect();
54+
const { width, height, top, left } = container.getBoundingClientRect();
5555
const [xMin, xMax, yMin, yMax] = getBounds();
56-
div.style.left = `${(width * xMin) / viewWidth}px`;
57-
div.style.top = `${height - (height * yMax) / viewHeight}px`;
56+
const xShift = left + window.scrollX;
57+
const yShift = top + window.scrollY;
58+
div.style.left = `${xShift + (width * xMin) / viewWidth}px`;
59+
div.style.top = `${yShift + height - (height * yMax) / viewHeight}px`;
5860
div.style.width = `${(width * (xMax - xMin)) / viewWidth}px`;
5961
div.style.height = `${(height * (yMax - yMin)) / viewHeight}px`;
6062
}

0 commit comments

Comments
 (0)