Skip to content

Instantly share code, notes, and snippets.

@0xlitf
Created June 22, 2017 10:33
Show Gist options
  • Save 0xlitf/a53741cac92fedbccad277ce5d9f981e to your computer and use it in GitHub Desktop.
Save 0xlitf/a53741cac92fedbccad277ce5d9f981e to your computer and use it in GitHub Desktop.
QML上拉加载逻辑
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