1

我正在使用 ImageFlow 制作图像滑块,我在 JS 文件中有功能

  /* Closure for this */
var my = this;

// Mouse Wheel support 
this.MouseWheel =
{

    init: function()
    {
        // Init mouse wheel listener 
        if(window.addEventListener)
        {
            my.ImageFlowDiv.addEventListener('DOMMouseScroll', my.MouseWheel.get, false);
        }
        my.Helper.addEvent(my.ImageFlowDiv,'mousewheel',my.MouseWheel.get);
    },

    get: function(event)
    {
        var delta = 0;
        if (!event)
        {
            event = window.event;
        }
        if (event.wheelDelta)
        {
            delta = event.wheelDelta / 120;
        }
        else if (event.detail)
        {
            delta = -event.detail / 3;
        }
        if (delta)
        {
            my.MouseWheel.handle(delta);
        }
        my.Helper.suppressBrowserDefault(event);
    },

    handle: function(delta)
    {
    alert('handle called');
        var change = false;
        var newImageID = 0;
        if(delta > 0)
        {
            if(my.imageID >= 1)
            {
                newImageID = my.imageID -3;
                change = true;
            }
        }
        else
        {
            if(my.imageID < (my.max-1))
            {
                newImageID = my.imageID +4;
                change = true;
            }
        }

        /* Glide to next (mouse wheel down) / previous (mouse wheel up) image  */
        if(change)
        {
        //alert('new image id='+newImageID);
            my.glideOnEvent(newImageID);
        }
    }
};

我想从我的 html 页面调用这个方法,我试过了

         document.addEventListener('touchmove',

      function(event, direction, distance, duration, fingerCount) {

        my.MouseWheel.handle(-1);
        if(direction == 'left'){
        my.MouseWheel.handle(-1);
        }
        else if (direction == 'right'){

        my.MouseWheel.handle(1);
        }

      }

      , false);

但是 MouseWheel 句柄函数没有被调用,如何调用该函数?

4

0 回答 0