diff --git a/src/QmlControls/JoystickThumbPad.qml b/src/QmlControls/JoystickThumbPad.qml index 6050f00b3ff1ff601acd480281f1abdd498f7c4b..6889ab3eda72784b3906e4be0f3aa659bc33946c 100644 --- a/src/QmlControls/JoystickThumbPad.qml +++ b/src/QmlControls/JoystickThumbPad.qml @@ -22,14 +22,27 @@ Item { QGCMapPalette { id: mapPal } - onStickPositionXChanged: { + onWidthChanged: calculateXAxis() + onStickPositionXChanged: calculateXAxis() + onHeightChanged: calculateYAxis() + onStickPositionYChanged: calculateYAxis() + + function calculateXAxis() + { + if(!visible()) { + return; + } var xAxisTemp = stickPositionX / width xAxisTemp *= 2.0 xAxisTemp -= 1.0 xAxis = xAxisTemp } - onStickPositionYChanged: { + function calculateYAxis() + { + if(!visible()) { + return; + } var yAxisTemp = stickPositionY / height yAxisTemp *= 2.0 yAxisTemp -= 1.0