Swiper js fade in effect has performance issue on ipad
See original GitHub issuehttps://github.com/nolimits4web/swiper/issues/2759
I also having the same issue mentioned above. I have more than 30 images.
As I can see for every frame transition, we currently changing transition-duration and opacity for all the frames instead of current, next and previous which is causing performance issue.
After changing below browser does not crash :-
var swiper = this;
var slides = swiper.slides;
**************here instead of all the images I am just doing for 3 images
for (var i = swiper.activeIndex; i < swiper.activeIndex+2; i += 1) {
var $slideEl = swiper.slides.eq(i);
var offset = $slideEl[0].swiperSlideOffset;
var tx = -offset;
if (!swiper.params.virtualTranslate) { tx -= swiper.translate; }
var ty = 0;
if (!swiper.isHorizontal()) {
ty = tx;
tx = 0;
}debugger;
var slideOpacity = swiper.params.fadeEffect.crossFade
? Math.max(1 - Math.abs($slideEl[0].progress), 0)
: 1 + Math.min(Math.max($slideEl[0].progress, -1), 0);
$slideEl
.css({
opacity: slideOpacity,
})
.transform(("translate3d(" + tx + "px, " + ty + "px, 0px)"));
}
},
setTransition: function setTransition(duration) {
var swiper = this;
**************Here instead of all the images I am sending only one image`
var slides = swiper.slides.eq(swiper.activeIndex);
var $wrapperEl = swiper.$wrapperEl;
slides.transition(duration);
if (swiper.params.virtualTranslate && duration !== 0) {
var eventTriggered = false;
slides.transitionEnd(function () {
if (eventTriggered) { return; }
if (!swiper || swiper.destroyed) { return; }
eventTriggered = true;
swiper.animating = false;
var triggerEvents = ['webkitTransitionEnd', 'transitionend'];
for (var i = 0; i < triggerEvents.length; i += 1) {
$wrapperEl.trigger(triggerEvents[i]);
}
});
}
},
};
After doing these changes, browser does not crash on ipad but I can see some issues related to transition in fade in effect may be because of my temporary changes.
@nolimits4web Can I expect some refactoring for fade in effect so that while transition, transition-duration and opacity style will apply to only 2/3 frames instead of all, which is causing performance issue on ipad if we have large images.
Note:- Everything works fine if we go with slide in Effect.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9
Top Related StackOverflow Question
Can confirm this bug, seemingly no solution. Would be great to get it fixed!
I’ve run into this issue, too. Butter-smooth in iOS Webkit or iOS Safari until ‘fade’ effect is added.
Pretty hard to pin down, too; maybe some JS code somewhere is running rapid fire? When iOS Safari is open with an inspector flashing red on draws, the slideshow is rapidly redrawing constantly. With enough slides (40+) the browser will completely crash. Add a zoom container to the image and zoom in and I see a repeated pulse of fuzziness as if the image is being re-rendered rapidly.
Unfortunately I can find no CSS adjustments through experimentation to resolve some kind of style conflict. I had to resort to just adjusting client expectations and use the default transition style, which I preferred anyway.