关闭 ImageFlow Gallery 上的鼠标滚轮滚动
我正在尝试禁用 Imageflow 画廊插件上的鼠标滚轮滚动(http://imageflow.finnrudolph.de/) 我尝试注释掉与鼠标滚轮相关的部分;但它似乎会影响自动滚动选项。任何帮助将不胜感激。 这是代码: var我的=这个;
/* 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';
}
}
}
};
I'm trying to disable mouse wheel scrolling on the Imageflow gallery plugin (http://imageflow.finnrudolph.de/)
I've tried commenting out sections that relate to mousewheel; but it seems to affect the autoscroll option. Any helped would be much appreciated.
Here' the code:
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';
}
}
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也有同样的问题。但是在未修改的版本 1.3.0 中,我编辑了第 313 行,其中包含:
只需将其注释掉。
现在我也让它自动滚动,但是当你单击 div 或图像时,它会停止,所以我使用注释禁用了第 819 行。
I had the same problem. But of an unmodified version 1.3.0 I edit line 313 which contains:
Just comment it out.
Now I had it auto scroll too, but when you click the div or image, it stops, so I disabled line 819 using a comment.