从HTML页面调用js函数

时间:2013-06-19 05:14:55

标签: jquery html css

我正在使用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句柄函数,如何调用该函数??

0 个答案:

没有答案