Skip to content

Commit 521c587

Browse files
committed
Fix strange jscript math bug
1 parent 92dc450 commit 521c587

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/QmlControls/DropPanel.qml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,28 @@ Popup {
4141

4242
onAboutToShow: {
4343
// Panel defaults to dropping to the right of click position
44-
_root.x = clickRect.x + clickRect.width
44+
let xPos = clickRect.x + clickRect.width
4545

4646
// If there isn't room to the right then we switch to drop to the left
47-
if (_root.x + _root.width > dropViewPort.x + dropViewPort.width) {
47+
if (xPos + _root.width > dropViewPort.x + dropViewPort.width) {
4848
_dropRight = false
49-
_root.x = clickRect.x - _root.width
49+
xPos = clickRect.x - _root.width
5050
}
5151

5252
// Default position of panel is vertically centered on click position
53-
_root.y = clickRect.y + (clickRect.height / 2)
54-
_root.y -= _root.height / 2
53+
let yPos = clickRect.y + (clickRect.height / 2)
54+
yPos -= _root.height / 2
5555

5656
// Make sure panel is within viewport
57-
let originRootY = _root.y
58-
_root.y = Math.max(_root.y, dropViewPort.y)
59-
_root.y = Math.min(_root.y, dropViewPort.y + dropViewPort.height - _root.height)
57+
let originalYPos = yPos
58+
yPos = Math.max(yPos, dropViewPort.y)
59+
yPos = Math.min(yPos, dropViewPort.y + dropViewPort.height - _root.height)
60+
61+
_root.x = xPos
62+
_root.y = yPos
6063

6164
// Adjust arrow position back to point at click position
62-
_arrowPointPositionY += originRootY - _root.y
65+
_arrowPointPositionY += originalYPos - yPos
6366
}
6467

6568
background: Item {

0 commit comments

Comments
 (0)