Created
June 22, 2017 10:33
-
-
Save 0xlitf/a53741cac92fedbccad277ce5d9f981e to your computer and use it in GitHub Desktop.
QML上拉加载逻辑
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function once(fn, context) { | |
var result | |
return function () { | |
if (fn) { | |
result = fn.apply(context || this, arguments) | |
fn = null | |
} | |
return result | |
} | |
} | |
property var showNotification | |
onDraggingVerticallyChanged: { | |
showNotification = once(function () { | |
notification.show("上拉加载") | |
}) | |
} | |
onContentYChanged: { | |
if (draggingVertically && contentHeight > height | |
&& contentY - originY > contentHeight - height) { | |
var dy = (contentY - originY) - (contentHeight - height) | |
if (dy > 40 && model.count >= 100) { | |
showNotification() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment