fix: dash currentItem null ref
This commit is contained in:
parent
e2552f604d
commit
c96c9c4038
1 changed files with 8 additions and 5 deletions
|
|
@ -99,15 +99,15 @@ Item {
|
||||||
|
|
||||||
flickableDirection: Flickable.HorizontalFlick
|
flickableDirection: Flickable.HorizontalFlick
|
||||||
|
|
||||||
implicitWidth: currentItem.implicitWidth
|
implicitWidth: currentItem?.implicitWidth ?? 0
|
||||||
implicitHeight: currentItem.implicitHeight
|
implicitHeight: currentItem?.implicitHeight ?? 0
|
||||||
|
|
||||||
contentX: currentItem.x
|
contentX: currentItem?.x ?? 0
|
||||||
contentWidth: row.implicitWidth
|
contentWidth: row.implicitWidth
|
||||||
contentHeight: row.implicitHeight
|
contentHeight: row.implicitHeight
|
||||||
|
|
||||||
onContentXChanged: {
|
onContentXChanged: {
|
||||||
if (!moving)
|
if (!moving || !currentItem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const x = contentX - currentItem.x;
|
const x = contentX - currentItem.x;
|
||||||
|
|
@ -118,13 +118,16 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onDragEnded: {
|
onDragEnded: {
|
||||||
|
if (!currentItem)
|
||||||
|
return;
|
||||||
|
|
||||||
const x = contentX - currentItem.x;
|
const x = contentX - currentItem.x;
|
||||||
if (x > currentItem.implicitWidth / 10)
|
if (x > currentItem.implicitWidth / 10)
|
||||||
root.state.currentTab = Math.min(root.state.currentTab + 1, tabs.count - 1);
|
root.state.currentTab = Math.min(root.state.currentTab + 1, tabs.count - 1);
|
||||||
else if (x < -currentItem.implicitWidth / 10)
|
else if (x < -currentItem.implicitWidth / 10)
|
||||||
root.state.currentTab = Math.max(root.state.currentTab - 1, 0);
|
root.state.currentTab = Math.max(root.state.currentTab - 1, 0);
|
||||||
else
|
else
|
||||||
contentX = Qt.binding(() => currentItem.x);
|
contentX = Qt.binding(() => currentItem?.x ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue