question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Miscalculation of Swiper parent width in IE11, unable to scroll to last slide

See original GitHub issue

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • Swiper Version: 4.4.2

  • Platform/Target and Browser Versions: IE11 (11.407.17134.0) Windows 10 Pro

  • Live Link or JSFiddle/Codepen or website with issue: https://codepen.io/saltymouse/full/ZmMPxW/

What you did

In the above Codepen demo (Bootstrap layout similar to my original project), using the mouse to drag/swipe (from right to left) to go to the final slide in the grey, numbered (0,1,2…) tab-slides.

Expected Behavior

Be able to drag/swipe all the way right to the bring the final slide into view. All other modern browsers except IE11 perform as expected.

Actual Behavior

IE11 stops the drag process at about slide ‘16 sixteen’ unable to continue dragging to the final slide (‘23 isEnd’). Checking at the console, IE tells me that tabbyTop.isEnd // true even though it has stopped midway.

Interestingly, the bottom Swiper (with photos and articles) works as expected in IE11, dragging to the last slide. The two Swipers are connected only 1-way: tabbyBottom.controller.control = tabbyTop;

I tried setting the parent width to 100% as suggested in #1258, but had no effect on how IE makes its calculations.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
DKvistgaardcommented, Jul 19, 2019

I’ve noticed the same issue. I’ve boiled down the issue to being the calculation of the size of each slide when using box-sizing: border-box; and the slidesPerView: 'auto' (as you mention).

So I looked into the code at it seems to be that each slide size is calculated using getPropertyValue('width') and doesn’t add paddings (left and right) to the calculated width, if the slide has a box-sizing: border-box styling. That is a correct calculation for most browsers (as the width includes padding in these cases), but apparently IE doesn’t include the paddings in the width returned by getPropertyValue('width').

A quick fix is to change the box-sizing styling on the slide items.

I will see if I can possibly find some time to do a PR with a fix for this.

1reaction
saltymousecommented, Nov 28, 2018

Apparently this is related to IE’s ability to (not) handle slidesPerView: 'auto'. I was able to work around this by conditionally setting a fixed number of slides for IE, but ‘auto’ for normal browsers. Perhaps this will help someone else until the bug is fixed.

var ieUser = /MSIE \d|Trident.*rv:/; // IE user agent regex
var tabbyTopSlidesPerView;

ieUser.test(navigator.userAgent)
  ? tabbyTopSlidesPerView = 4 // for IE
  : tabbyTopSlidesPerView = 'auto'; // for everyone else

var tabbyTop = new Swiper('.tabby-top.swiper-container', {
  loop: false,
  slidesPerView: tabbyTopSlidesPerView, // the conditional variable we set above
  freeMode: true,
  grabCursor: true,
  spaceBetween: 0,
  // ... other settings
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Continue to scroll after Swiper.js last slide - Stack Overflow
This does what I want for scrolling down and past the container but I can't find a way to reverse it for scrolling...
Read more >
issues with scrollintoview javascript method in ie10.
Hi, scollintoview(false) javascript method causing the entire web page to shift to the left side of the window in ie10.
Read more >
Slider Revolution Changelog
One click of a button will update the Slider Revolution WordPress Builder to the latest available version, directly from our update servers.
Read more >
Maps JavaScript API Release Notes - Google Developers
Internet Explorer 11 is now decommissioned in the Maps Embed API. ... cooperative : The user must swipe with one finger to scroll...
Read more >
Extras for Elementor Changelog - Namogo Shop
Fixed: Posts — Elementor compatibility with recent pagination fix ... case js error with empty slider controls size values; Fixed: Swiper destroy on...
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