Swiper js fade in effect has performance issue on ipad

See original GitHub issue

https://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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

1reaction
mattpilottcommented, Oct 31, 2019

Can confirm this bug, seemingly no solution. Would be great to get it fixed!

1reaction
WesWeddingcommented, Sep 17, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swiper Changelog
3.0.8 - Released on June 14th, 2015. Fixed issue with wrong active index and callbacks in Fade effect; New mousewheel parameters:.
Read more >
Autoplay stops after 1 fade when using fade effect in swiper js
I have a slider that I want to set to autoplay and have a fade effect. Everything works fine when using the normal...
Read more >
Building modern sliders with HTML, CSS, and Swiper
Virtual slides for better performance; Nested sliders; Full navigation control; Transition effects (fade, 3D Cube, 3D overflow, parallax, cards, ...
Read more >
Set Up Swiper.js for Angular Slides [Example] - Ionic Framework
Read this guide to learn how to get Swiper.js for Angular set up in your Ionic Framework application for a modern touch slider...
Read more >
Safari Technology Preview Release Notes - Apple Developer
Safari Extensions. Fixed an issue where browser.tabs sometimes returned an incorrect URL for pinned tabs. Bug Fixes. Fixed the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found