browser resize breaks it
works like a charm but when i resize the browser (or change mobile orientation), the slider doesn't update its size.
is there a way to 'restart' the slider?
I changed windows resize function for that.. This way its not try to resize browser million times when resizing window. this way when you relase screen, function wil fire once. but the right way is plugin owner can add this future and let users set delay time. I set delay time to 500 ms.
line 139 ;
/**
* Controller
* When resize browser window
* Pause autoplay in fear of escalation
* Reinit plugin for new slider dimensions
* Correct crop to current slide
* Start autoplay from beginning
*/
$(window).on({
orientationchange: Debouncer(function (e) {
// Reinit plugin (set new slider dimensions)
_.init();
// Crop to current slide
_.slide(0);
}), resize: Debouncer(function (e) {
// Reinit plugin (set new slider dimensions)
_.init();
// Crop to current slide
_.slide(0);
})
});
// Window Resize Debouncer
function Debouncer(func, timeout) {
var timeoutID, timeout = timeout || 500;
return function () {
var scope = this, args = arguments;
clearTimeout(timeoutID);
timeoutID = setTimeout(function () {
func.apply(scope, Array.prototype.slice.call(args));
}, timeout);
}
}
Yeah, this may be caused by a multitude of calculations. But on all devices, which it was tested, there was never such a problem.
To reinit slider you need to:
// Calculate slider elements dimensions
_.init()
// Reset slider position to current slide
_.slide(0);
thank you for your support, but I can't get it right: diegelernten.de#referenzen
You have added paddings to '.slide', so width of each slide is higher than slider wrapper. After resize, script include all paddings into final width.
You should add next wapper inside each slide and onlyhis padding.