我如何扩展jquery.mobile.scrollview?

问题描述 投票:1回答:1

我想向jquery.mobile.scrollvew添加一些代码,以显示上一次dragMove事件的时间。如果我可以将自己的事件添加到_handleDragMove事件中,但我真的不知道如何做到这一点,那将非常方便。

我正在考虑制作一个扩展自scrollview的新小部件,但这似乎需要2行代码完成很多工作。

lastStopTime: 0,  // MED add a property
_handleDragMove: function(e, ex, ey)
{

    // MED added this timing hack to check to see if we are scrolling
    $.mobile.scrollview.prototype.lastStopTime = getCurrentTime();
    // MED

    this._lastMove = getCurrentTime();

    var v = this._$view;
}

g +上的一个朋友给了我以下代码片段,效果很好。我可以使用常规的scrollview小部件并添加一些自己的代码:

$.mobile.scrollview.prototype._handleDragMove = (function() {
    var origDragMove = $.mobile.scrollview.prototype._handleDragMove;
    return function __handleDragMove() {
        // Your code
        origDragMove.apply(this, arguments);
    };
}());

我认为这是我正在寻找的内容,即使它在语法上很沉重。

jquery jquery-mobile
1个回答
0
投票

请参阅:

© www.soinside.com 2019 - 2024. All rights reserved.