What I want to do:
I know the dimensions of every slide. I can access $(window).width() for the overall screen size. What I want to do, using this js:
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.
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.
What I have tried:
On line 365 I changed:
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:
maxSwipe = function() {
// return base.maximumPixels + base.newRelativeX / 5; // change to:
return base.maximumPixels; // essentially, it stops it from going higher than the max allowed.
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.