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.

Mobile: slide content scrolling issue

See original GitHub issue

Hi, thanks for your great slider! I’ve a quite big problem with Swiper on mobile browsers: I’ve built a website with nested swipers, slides have 100% width and height and as requirement parent slides should move vertically (as it does with eg. parentSwiper.swiper({direction:'vertical',effect:'slide'})), some slides contain long texts that need a scrollbar when screens become smaller: using overflow-y: auto works great on desktops but on mobiles/touch devices text scrolling doesn’t work (a vertical swipe triggers a slide movements while the text remains unscrollable, it should scroll text and then start moving the slider when reaching text ‘borders’).

Is there a way to have Swiper integrated scrollbar working for slide content? the demos show it working only for swiper-container as an aternative to pagination, it would be very useful for responsive websites/apps to have it working for slide content.

(with another project that used Swiper 2.x I got a semi-working solution for vertical swiper with vertical scrollbar for slides contents by tweaking swiper code, but it was buggy because it needs to rely on timers and double clicks/touches to allow both native overflow scrolling for contents and slides scrolling)

Issue Analytics

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

github_iconTop GitHub Comments

30reactions
nolimits4webcommented, Oct 21, 2015

Ok, here is a pretty nice working solution. Works well on iOS https://jsfiddle.net/8fgphstx/1/

Here is the JS:

var swiper = new Swiper('.swiper-container', {
    direction: 'vertical',
});
var startScroll, touchStart, touchCurrent;
swiper.slides.on('touchstart', function (e) {
    startScroll = this.scrollTop;
    touchStart = e.targetTouches[0].pageY;
}, true);
swiper.slides.on('touchmove', function (e) {
    touchCurrent = e.targetTouches[0].pageY;
    var touchesDiff = touchCurrent - touchStart;
    var slide = this;
    var onlyScrolling = 
            ( slide.scrollHeight > slide.offsetHeight ) && //allow only when slide is scrollable
            (
                ( touchesDiff < 0 && startScroll === 0 ) || //start from top edge to scroll bottom
                ( touchesDiff > 0 && startScroll === ( slide.scrollHeight - slide.offsetHeight ) ) || //start from bottom edge to scroll top
                ( startScroll > 0 && startScroll < ( slide.scrollHeight - slide.offsetHeight ) ) //start from the middle
            );
    if (onlyScrolling) {
        e.stopPropagation();
    }
}, true);
0reactions
lock[bot]commented, Jun 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mobile Responsiveness - Horizontal Scrolling ...
Issue #1 - The margin values are too high. In general, the horizontal scroll bar might appear due to the way you've positioned...
Read more >
How To Fix Horizontal Scrollbar on Mobile When Using ...
The horizontal scrollbar issue on mobile devices can be fixed by setting overflow to hidden. You can do this by using the Elementor...
Read more >
Responsive mobile horizontal scroll issue
Basically, the main reason for this issue happening is that the content of the page has a bigger width than the device's width....
Read more >
Cant scroll on mobile because of slider - Support
Hi,. I checked your site in mobile and was able to scroll past the slider without a problem. Can you provide us a...
Read more >
Carousel stops slide movement on mobile scroll touch
Noticed that the carousel will stop its slide motion when a mobile screen is swiped to scroll the view or if the slide...
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