Отключите прокрутку колесика мыши в галерее ImageFlow - PullRequest
1 голос
/ 26 октября 2011

Я пытаюсь отключить прокрутку колесика мыши в плагине галереи потока изображений (http://imageflow.finnrudolph.de/) Я пробовал комментировать разделы, относящиеся к колесу мыши; но, похоже, это влияет на параметр автопрокрутки. Любая помощь будет принята с благодарностью. Здесь'код: var my = this;

/* Initiate ImageFlow */
this.init = function (options)
{
    /* Evaluate options */
    for(var name in my.defaults) 
    {
        this[name] = (options !== undefined && options[name] !== undefined) ? options[name] : my.defaults[name];
    }

    /* Try to get ImageFlow div element */
    var ImageFlowDiv = document.getElementById(my.ImageFlowID);
    if(ImageFlowDiv)
    {
        /* Set it global within the ImageFlow scope */
        ImageFlowDiv.style.visibility = 'visible';
        this.ImageFlowDiv = ImageFlowDiv;

        /* Try to create XHTML structure */
        if(this.createStructure())
        {
            this.imagesDiv = document.getElementById(my.ImageFlowID+'_images');
            this.captionDiv = document.getElementById(my.ImageFlowID+'_caption');
            this.navigationDiv = document.getElementById(my.ImageFlowID+'_navigation');
            this.scrollbarDiv = document.getElementById(my.ImageFlowID+'_scrollbar');
            this.sliderDiv = document.getElementById(my.ImageFlowID+'_slider');
            this.buttonNextDiv = document.getElementById(my.ImageFlowID+'_next');
            this.buttonPreviousDiv = document.getElementById(my.ImageFlowID+'_previous');
            this.buttonSlideshow = document.getElementById(my.ImageFlowID+'_slideshow');

            this.indexArray = [];
            this.current = 0;
            this.imageID = 0;
            this.target = 0;
            this.memTarget = 0;
            this.firstRefresh = true;
            this.firstCheck = true;
            this.busy = false;

            /* Set height of the ImageFlow container and center the loading bar */
            var width = this.ImageFlowDiv.offsetWidth;
            var height = Math.round(width / my.aspectRatio);
            document.getElementById(my.ImageFlowID+'_loading_txt').style.paddingTop = ((height * 0.5) -22) + 'px';
            ImageFlowDiv.style.height = height + 'px';

            /* Init loading progress */
            this.loadingProgress();
        }
    }
};


/* Create HTML Structure */
this.createStructure = function()
{
    /* Create images div container */
    var imagesDiv = my.Helper.createDocumentElement('div','images');

    /* Shift all images into the images div */
    var node, version, src, imageNode;
    var max = my.ImageFlowDiv.childNodes.length;
    for(var index = 0; index < max; index++)
    {
        node = my.ImageFlowDiv.childNodes[index];
        if (node && node.nodeType == 1 && node.nodeName == 'IMG')
        {
            /* Add 'reflect.php?img=' */
            if(my.reflections === true)
            {
                version = (my.reflectionPNG) ? '3' : '2';
                src = my.imagePath+node.getAttribute('src',2);
                src = my.reflectPath+'reflect'+version+'.php?img='+src+my.reflectionGET;
                node.setAttribute('src',src);
            }

            /* Clone image nodes and append them to the images div */
            imageNode = node.cloneNode(true);
            imagesDiv.appendChild(imageNode);
        }
    }

    /* Clone some more images to make a circular animation possible */
    if(my.circular)
    {
        /* Create temporary elements to hold the cloned images */
        var first = my.Helper.createDocumentElement('div','images');
        var last = my.Helper.createDocumentElement('div','images');

        /* Make sure, that there are enough images to use circular mode */
        max = imagesDiv.childNodes.length;
        if(max < my.imageFocusMax)
        {
            my.imageFocusMax = max;
        }

        /* Do not clone anything if there is only one image */
        if(max > 1)
        {
            /* Clone the first and last images */
            var i;
            for(i = 0; i < max; i++)
            {
                /* Number of clones on each side equals the imageFocusMax */
                node = imagesDiv.childNodes[i];
                if(i < my.imageFocusMax)
                {
                    imageNode = node.cloneNode(true);
                    first.appendChild(imageNode);
                }
                if(max-i < my.imageFocusMax+1)
                {
                    imageNode = node.cloneNode(true);
                    last.appendChild(imageNode);
                }
            }

            /* Sort the image nodes in the following order: last | originals | first */
            for(i = 0; i < max; i++)
            {
                node = imagesDiv.childNodes[i];
                imageNode = node.cloneNode(true);
                last.appendChild(imageNode);
            }
            for(i = 0; i < my.imageFocusMax; i++)
            {
                node = first.childNodes[i];
                imageNode = node.cloneNode(true);
                last.appendChild(imageNode);
            }

            /* Overwrite the imagesDiv with the new order */
            imagesDiv = last;
        }
    }

    /* Create slideshow button div and append it to the images div */
    if(my.slideshow)
    {
        var slideshowButton = my.Helper.createDocumentElement('div','slideshow');
        imagesDiv.appendChild(slideshowButton);
    }

    /* Create loading text container */
    var loadingP = my.Helper.createDocumentElement('p','loading_txt');
    var loadingText = document.createTextNode(' ');
    loadingP.appendChild(loadingText);

    /* Create loading div container */
    var loadingDiv = my.Helper.createDocumentElement('div','loading');

    /* Create loading bar div container inside the loading div */
    var loadingBarDiv = my.Helper.createDocumentElement('div','loading_bar');
    loadingDiv.appendChild(loadingBarDiv);

    /* Create captions div container */
    var captionDiv = my.Helper.createDocumentElement('div','caption');

    /* Create slider and button div container inside the scrollbar div */
    var scrollbarDiv = my.Helper.createDocumentElement('div','scrollbar');
    var sliderDiv = my.Helper.createDocumentElement('div','slider');
    scrollbarDiv.appendChild(sliderDiv);
    if(my.buttons)
    {
        var buttonPreviousDiv = my.Helper.createDocumentElement('div','previous', 'button');
        var buttonNextDiv = my.Helper.createDocumentElement('div','next', 'button');
        scrollbarDiv.appendChild(buttonPreviousDiv);
        scrollbarDiv.appendChild(buttonNextDiv);
    }

    /* Create navigation div container beneath images div */
    var navigationDiv = my.Helper.createDocumentElement('div','navigation');
    navigationDiv.appendChild(captionDiv);
    navigationDiv.appendChild(scrollbarDiv);

    /* Update document structure and return true on success */
    var success = false;
    if (my.ImageFlowDiv.appendChild(imagesDiv) &&
        my.ImageFlowDiv.appendChild(loadingP) &&
        my.ImageFlowDiv.appendChild(loadingDiv) &&
        my.ImageFlowDiv.appendChild(navigationDiv))
    {
        /* Remove image nodes outside the images div */
        max = my.ImageFlowDiv.childNodes.length;
        for(index = 0; index < max; index++)
        {
            node = my.ImageFlowDiv.childNodes[index];
            if (node && node.nodeType == 1 && node.nodeName == 'IMG')
            {
                my.ImageFlowDiv.removeChild(node);
            }
        }
        success = true;
    }
    return success;
};


/* Manage loading progress and call the refresh function */
this.loadingProgress = function()
{
    var p = my.loadingStatus();
    if((p < 100 || my.firstCheck) && my.preloadImages)
    {
        /* Insert a short delay if the browser loads rapidly from its cache */
        if(my.firstCheck && p == 100)
        {
            my.firstCheck = false;
            window.setTimeout(my.loadingProgress, 100);
        }
        else
        {
            window.setTimeout(my.loadingProgress, 40);
        }
    }
    else
    {
        /* Hide loading elements */
        document.getElementById(my.ImageFlowID+'_loading_txt').style.display = 'none';
        document.getElementById(my.ImageFlowID+'_loading').style.display = 'none';

        /* Refresh ImageFlow on window resize - delay adding this event for the IE */
        window.setTimeout(my.Helper.addResizeEvent, 1000);

        /* Call refresh once on startup to display images */
        my.refresh();

        /* Only initialize navigation elements if there is more than one image */
        if(my.max > 1)
        {
            /* Initialize mouse, touch and key support */
            my.MouseWheel.init();
            my.MouseDrag.init();
            my.Touch.init();
            my.Key.init();

            /* Toggle slideshow */
            if(my.slideshow)
            {
                my.Slideshow.init();
            }

            /* Toggle scrollbar visibility */
            if(my.slider)
            {
                my.scrollbarDiv.style.visibility = 'visible';
            }
        }
    }
};

1 Ответ

1 голос
/ 16 ноября 2011

У меня была такая же проблема. Но для неизмененной версии 1.3.0 я редактирую строку 313, которая содержит:

my.MouseWheel.init();

Просто закомментируйте это.

Теперь у меня тоже была автопрокрутка, но когда вы щелкаете по div или изображению, оно останавливается, поэтому я отключил строку 819, используя комментарий.

my.Slideshow.stop();
...