Disable mousewheel debounce for swiper.js - javascript

I'm trying to create a vertically scrollable and draggable list with swiper.js, and I've almost reached the goal. There is only one issue left:
The mousewheel scrolling feels very laggy. After every scroll, there is a small delay before the next one is registered. Check out the behavior here:
http://idangero.us/swiper/demos/20-mousewheel-control.html
This is my configuration so far:
this.swiper = new Swiper(this.$el, {
direction: 'vertical',
centeredSlides: true,
spaceBetween: 0,
grabCursor: true,
slidesPerView: 'auto',
mousewheelControl: true,
}
I haven't found a way to disable this. The only property that sounds like it could help, mousewheelSensitivity, does not seem to change the behavior at all.
Is this even possible or do I need to change swiper.js internals for this to work?

I have the same issue, and haven't found a final answer for this, however, I noticed that adding the next options helps a little:
mousewheelSensitivity: 0,
mousewheelReleaseOnEdges: true,
If you have found any other solution, please share it with us.

Mousewheel Methods & Properties:
function disableScrolling() {
swiper.mousewheel.disable();
}

Related

How to add arrows on full screen slider

I recently completed a website for a photography friend and he came back to me saying that the sliders on his project pages were hard to use and he would like arrows, whenever I have tried adding arrows into it I've found the Navigation pushes the arrows out of view, I was wondering if anyone knows of a way of fixing this.
Please see the link below to the page. Thank you in advance.
Daniels Website
The website you linked uses Swiper, which is a framework for sliders. According to the Getting Started, you need to add two arrows, which your friend seems to have commented out. Since your site has jQuery, you also need to initialize it within the document.ready event. Try putting the code within the event like this:
$(document).ready(function () {
//initialize swiper when document ready
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
paginationClickable: true,
spaceBetween: 0,
loop: true,
centeredSlides: true,
autoplay: 7000,
autoplayDisableOnInteraction: false,
slidesPerView: 1,
effect: 'fade'
})
});

How to prevent swiping by dragging in idangero swiper?

I need to prevent swiping by dragging (mouse, fingers), but keep it when using pagination buttons and next or prev button.
Here is how I initialize it:
var pcSwiper = new Swiper('.swiper-container_pc', {
direction: 'horizontal',
slidesPerView: 'auto',
spaceBetween: 20,
nested: true
});
As I found out disableTouchControl method also disables mouse dragging (not only touch dragging). So, the name and description of this method are a little bit unclear, but it works.
pcSwiper.disableTouchControl();

Need help properly extending jQuery Slick Slider plugin to change how it slides

I have been given a task to change how our slider works. We use the jQuery plugin called Slick Slider to display news blurbs.
What they want me to do is to have the previous/next buttons and autoplay to all move the slider one slide at a time in all modes (mobile, tablet, and desktop). Ok not a problem, I set that up easily enough. Then they asked me to change it so that it displays one dot for every 3 slides and clicking those dots moves the slider 3 slides at a time.
Obviously this is going to require me making modifications to the functions in slick.js. I don't see any built in functionality to do this. I am trying to figure out how to extend this library and override the functions one at a time. To be honest I am not sure how to do this properly with jQuery plugins.
This is complicated by the fact that we are running this in Drupal. I have setup a JS Fiddle with a close approximation of what we are doing right now.
JS Fiddle: https://jsfiddle.net/9z52tfkw/
My slick initiation code is here:
(function($) {
$('.my-slider').slick({
speed: 1000,
autoplay: true,
dots: true,
mobileFirst: true,
slidesToShow: 1,
slidesToScroll: 1,
focusOnSelect: true,
appendArrows: $('.controls'),
prevArrow: '<button type="button" class="prev">Prev</button>',
nextArrow: '<button type="button" class="next">Next</button>',
responsive: [
{
breakpoint: 960,
settings: {
dots: true,
slidesToShow: 3
}
},
{
breakpoint: 769,
settings: {
dots: true,
slidesToShow: 2
}
}
]
});
}(jQuery));
Slick Slider details and code can be found here: http://kenwheeler.github.io/slick
I am using version 1.5.6. A copy of the same version of slick.js can be found here: https://github.com/kenwheeler/slick/blob/1.5.6/slick/slick.js
To clarify, I am not asking that anyone do the overrides for me. Instead I am asking for help in overriding the plugin's functions or otherwise extending the plugin. I am capable from there, though will be grateful for any help provided.
I think this will also help me in the future with other jQuery plugins. Thanks!
You can always just remove 2 out of three of the dots :)
i.e. add this to the end of the init:
.find('.slick-dots li').filter(function(i,e){
return (i % 3 != 0);
}).hide();
JSFiddle: https://jsfiddle.net/TrueBlueAussie/9z52tfkw/2/
For a more obvious example: jsfiddle.net/9z52tfkw/3

jCarouselLite plugin not working as expected

This problem is plaguing me. I've used jCarouselLite for years and years, I even added a "fade" feature to the original library released by Ganeshji Marwaha for my own use. I recently switched to the new plug-in because it is still supported, it uses touch events, and it can be responsive. But I have had no luck in using it.
I am almost certainly doing something stupid, but I can not figure out what... Can anyone take a look with fresh eyes at this homepage implementation?
http://staging.tbc1927.com/www/
The implementation here is not responsive, but I would like swipe supported.
$().ready(function() {
$(".homecarousel").jCarouselLite({
visible: 1,
auto: 12000,
speed: 800,
responsive: false,
swipe: true,
circular: true,
btnNext: ".next",
btnPrev: ".previous"
});
});
The CSS is simple enough, and I am letting the plug in do the heavy lifting. The jQuery I am using is the same as they recommend (1.7.2), though I had been using a newer version as well with no luck (1.8).
When the carousel initially loads, the first slide is fine. Then it goes away, and the whole carousel is positioned WAY off the page. The longer the carousel runs, the more off the page it is positioned.
What am I missing?
The author of the plug in helped me out here. The plug in changed the "auto" option to a boolean value, and the "12000" value was throwing it off. To set the animation delay, the plug in now uses a parameter called "timeout". The correct implementation script should be:
$().ready(function() {
$(".homecarousel").jCarouselLite({
visible: 1,
auto: true,
timeout: 12000,
speed: 800,
responsive: false,
swipe: true,
circular: true,
btnNext: ".next",
btnPrev: ".previous"
});
});

carousel trigger when continuous scrolling not working

The carousel (caroufredsel) scroll (check this for example) continously to the left. When I hover to an arrow to the right it will stop scrolling then it will reverse it's direction. I tried using custom events but it appears that it's not working. Here's a code of the carousel.
$('#gallery').carouFredSel({
width: "variable",
auto: {
items : 4,
duration :"40000",
easing :"linear",
timeoutDuration :0,
pauseOnHover :"immediate"
},
items: {
visible: 3
}
});
Now my custom event that will cause the carousel to reverse is direction is like this. But it's not working until the whole items where finished scrolling. What I want to achieve is to instantaneously reverse the direction when hovering.
$('a.prev').hover(function()
{
$('#gallery').trigger("pause");
$('#gallery').trigger("configuration",["direction",right]);
$('#gallery').trigger("play");
}
The code above doesn't work and I've tried different events that will simulate the reversal of scrolling but had no luck with it.
If there's no workaround for this. I'm willing to change another plugin that will easily do the work. If you know something that can do it easily please leave your suggestions. Thank you very much!
That totally depends how the carousel is implemented. A possible solution might be to stop the eventPropagation. It may or may not work depending on the implementation of the carousel.
$('a.prev').hover(function(event)
{
event.stopPropagation();
$('#gallery').trigger("pause");
$('#gallery').trigger("configuration",["direction",right]);
$('#gallery').trigger("play");
}

Categories

Resources