Skip to content

Commit

Permalink
added extra "centeroversized" flag to positionViewAtItemXXXX
Browse files Browse the repository at this point in the history
  • Loading branch information
whoozle committed Nov 24, 2019
1 parent c0d6d42 commit a95c9bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions core/BaseView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ BaseLayout {
this.content._updateScrollPositions(x, y, layout)
}

function positionViewAtItemHorizontally(itemBox, center) {
function positionViewAtItemHorizontally(itemBox, center, centerOversized) {
var cx = this.contentX, cy = this.contentY
var x = itemBox[0], y = itemBox[1]
var iw = itemBox[2], ih = itemBox[3]
Expand All @@ -307,14 +307,14 @@ BaseLayout {
if (center && this.contentWidth > w)
this.contentX = atCenter < 0 ? 0 : x > this.contentWidth - w / 2 - iw / 2 ? this.contentWidth - w : atCenter
else if (iw > w)
this.contentX = atCenter
else if (x - cx < 0)
this.contentX = centerOversized? atCenter: x
else if (x - cx <= 0)
this.contentX = x
else if (x - cx + iw > w)
this.contentX = x + iw - w
}

function positionViewAtItemVertically(itemBox, center) {
function positionViewAtItemVertically(itemBox, center, centerOversized) {
var cx = this.contentX, cy = this.contentY
var x = itemBox[0], y = itemBox[1]
var iw = itemBox[2], ih = itemBox[3]
Expand All @@ -324,8 +324,8 @@ BaseLayout {
if (center && this.contentHeight > h)
this.contentY = atCenter < 0 ? 0 : y > this.contentHeight - h / 2 - ih / 2 ? this.contentHeight - h : atCenter
else if (ih > h)
this.contentY = atCenter
else if (y - cy < 0)
this.contentY = centerOversized? atCenter: y
else if (y - cy <= 0)
this.contentY = y
else if (y - cy + ih > h)
this.contentY = y + ih - h
Expand Down
4 changes: 2 additions & 2 deletions core/ListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ BaseView {
var center = this.positionMode === this.Center

if (horizontal) {
this.positionViewAtItemHorizontally(itemBox, center)
this.positionViewAtItemHorizontally(itemBox, center, true)
} else {
this.positionViewAtItemVertically(itemBox, center)
this.positionViewAtItemVertically(itemBox, center, true)
}
}

Expand Down

0 comments on commit a95c9bb

Please sign in to comment.