| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 | var pullDown = {    threshold: 95,    maxHeight: 200,    callRefresh: 'onrefresh',    callPullingDown: 'onpullingdown',    refreshSelector: '.uni-refresh'};function ready(newValue, oldValue, ownerInstance, instance) {    var state = instance.getState()    state.canPullDown = newValue;    // console.log(newValue);}function touchStart(e, instance) {    var state = instance.getState();    state.refreshInstance = instance.selectComponent(pullDown.refreshSelector);    state.canPullDown = (state.refreshInstance != null && state.refreshInstance != undefined);    if (!state.canPullDown) {        return    }    // console.log("touchStart");    state.height = 0;    state.touchStartY = e.touches[0].pageY || e.changedTouches[0].pageY;    state.refreshInstance.setStyle({        'height': 0    });    state.refreshInstance.callMethod("onchange", true);}function touchMove(e, ownerInstance) {    var instance = e.instance;    var state = instance.getState();    if (!state.canPullDown) {        return    }    var oldHeight = state.height;    var endY = e.touches[0].pageY || e.changedTouches[0].pageY;    var height = endY - state.touchStartY;    if (height > pullDown.maxHeight) {        return;    }    var refreshInstance = state.refreshInstance;    refreshInstance.setStyle({        'height': height + 'px'    });    height = height < pullDown.maxHeight ? height : pullDown.maxHeight;    state.height = height;    refreshInstance.callMethod(pullDown.callPullingDown, {        height: height    });}function touchEnd(e, ownerInstance) {    var state = e.instance.getState();    if (!state.canPullDown) {        return    }    state.refreshInstance.callMethod("onchange", false);    var refreshInstance = state.refreshInstance;    if (state.height > pullDown.threshold) {        refreshInstance.callMethod(pullDown.callRefresh);        return;    }    refreshInstance.setStyle({        'height': 0    });}function propObserver(newValue, oldValue, instance) {    pullDown = newValue;}module.exports = {    touchmove: touchMove,    touchstart: touchStart,    touchend: touchEnd,    propObserver: propObserver}
 |