[英]JavaScript: Owl Carousel - stop slider at last slide
What I want to do: 我想做的事:
I know the dimensions of every slide. 我知道每张幻灯片的尺寸。 I can access $(window).width() for the overall screen size.
我可以访问$(window).width()作为整个屏幕尺寸。 What I want to do, using this js:
我想做什么,使用这个js:
https://jsfiddle.net/8mve0hjy/ https://jsfiddle.net/8mve0hjy/
is stop the slider once it has reached the edge of the window. 到达窗口边缘后停止它。 I am aware of alternatives, such as: Owl Carousel: Run function when last slide is reached
我知道其他选择,例如: 猫头鹰轮播:到达最后一张幻灯片时运行功能
But I would like to use the JS i've provided as it is what is used in the module I'm using. 但是我想使用我提供的JS,因为它是我正在使用的模块中使用的。
Alternatively, I am open to incorporating some function outside of this, that uses the classes .owl-item
for each item, and owl-wrapper
for the container. 另外,我愿意并入一些功能,
.owl-item
每个项目使用.owl-item
类,对容器使用owl-wrapper
。
What I have tried: 我尝试过的
On line 365 I changed: 在365行,我更改了:
maximum = ((base.itemsAmount * base.itemWidth) - base.options.items * base.itemWidth) * -1;
to: 至:
maximum = ((base.itemsAmount * base.itemWidth) - $(window).width()) * -1;
Answer: 回答:
In addition to reseting the maximum, I also had to reset the max slide amount: 除了重置最大值,我还必须重置最大滑动量:
on line 1005: 在第1005行:
maxSwipe = function() {
// return base.maximumPixels + base.newRelativeX / 5; // change to:
return base.maximumPixels; // essentially, it stops it from going higher than the max allowed.
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.