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.

Revisions

  1. 4u1kto created this gist Jun 22, 2017.
    26 changes: 26 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    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()
    }
    }
    }