Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoplay stops when window is resized on touch device #709

Closed
github0013 opened this issue Apr 10, 2017 · 4 comments
Closed

autoplay stops when window is resized on touch device #709

github0013 opened this issue Apr 10, 2017 · 4 comments

Comments

@github0013
Copy link

env

"react-slick": "^0.14.7"
"slick-carousel": "^1.6.0"

replication

[rails repo] that can replicate this issue (https://github.com/github0013/on_window_resize)

git clone ..
cd ...
rails s 
open http://localhost:3000

problem

on touch devices, I think any browsers hide the address bar. When the address bar is hidden, window.resize event fires.

(when you swipe from bottom to top, this part goes away)

Tested on iPhone6 (safari firefox chrome), when window.resize happens image scrolling stops.
(but for some reasons, Demo works fine in any cases)

I tried this workaround #543 , but this didn't work for me.
Instead, I did this slickNext() https://github.com/github0013/on_window_resize/blob/master/app/javascript/packs/with_debounce.jsx#L10-L25

Anybody having the same issue? or it's just me?

@eHallberg
Copy link

eHallberg commented May 18, 2017

@github0013
Hey,
I had this issue aswell, when changing size of window or pressing a slide (opening modal) it stopped autoplay.
I have found a workaround for this issue, it solves it for me atleast.

    startTimeout() {
        // If autoplay is working we reset timeout and it will never end up inside.
        clearTimeout(this.timer);
        this.timer = setTimeout(() => {
            // This will start play again, important here is to have a timeout that exceeds your "autoplaySpeed". 
            this.slider.innerSlider.play();
        }, 3200);
    }

    render() {
        var settings = {
            infinite: true,
            autoplay: true,
            autoplaySpeed: 3000,
            pauseOnHover: false
        };
        // afterChange and beforeChange docs can be found here: https://github.com/akiran/react-slick
        return (
            <div
                className={ styles.container }
                ref={ item => this.containerRef = item }>
                <Slider
                    ref={ c => this.slider = c }
                    afterChange={ this.startTimeout.bind(this) }
                    beforeChange={ this.startTimeout.bind(this) }
                    {...settings}
                    className={ styles.sliderContainer }>
                    { /*content*/ }
                </Slider>
            </div>
        );
    }

@JesperWe
Copy link

JesperWe commented Jun 16, 2017

Probably fixed in #651 which is a one character fix. A bit simpler.

@akiran akiran closed this as completed Aug 27, 2017
@akiran
Copy link
Owner

akiran commented Aug 27, 2017

Fixed in 0.15 release

@puja1234
Copy link

puja1234 commented Mar 23, 2018

I am not able to get autoplay to work in any browser on touch device like mobiles, until i click on next/previous.

"react-slick": "0.14.11"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants