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.

animated Slide change with currentSlide property.

See original GitHub issue

i would like autoplay to work while preserving the animation while changing slides in componentDidMount.

i was able to achieve autoplay with mentioned answers in #46. but doing so i would like to have the animation of onClick Dot component.

is there a way to achieve this?

class Comp extends Component {
  constructor() {
        super();
        this.state = {
            totalSlides: 3,
            currentSlide: 0
        };
  }
  
  componentDidMount() {
        setInterval(() => {
            let currentSlide = this.state.currentSlide + 1;
            if (currentSlide === 3) currentSlide = 0
            this.setState({ currentSlide });
        }, 3000);
  }

  render() {
      return (
                <CarouselProvider
                    naturalSlideHeight={0.5}
                    naturalSlideWidth={1}
                    totalSlides={this.state.totalSlides}
                    currentSlide={this.state.currentSlide}
                    id="home"
                >
                    <Slider>
                        <Slide index={0}  >SOME CONTENT</Slide>
                        <Slide index={1}  >SOME CONTENT</Slide>
                        <Slide index={2}  >SOME CONTENT</Slide>
                    </Slider>
                    <DotGroup  />
                </CarouselProvider>
        );
    }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
mrbinky3000commented, Apr 3, 2018

Well, maybe it’s not a bug. When you update the currentSlide property on the CarouselProvider, it just jumps to the slide. When you update the currentSlide property in the carousel’s store, it animates. I think I did this so that, when the component is mounted, it will just START at currentSlide. Otherwise, if you wanted to start in the middle of a bunch of slides, it would animate when the component is first mounted. I don’t think that’s a desirable option.

The solution is to make a component, wrap it with the WithStore higher order component, add the timer there, and have the timer call setStoreState({ currentSlide: x }). This new component should live as a child of CarouselProvider. I will create a demo and add it to the project. Maybe I’ll just make it a new component, StartButton

1reaction
camel113commented, Mar 23, 2018

No I think he is asking why when you change the currentSlide programmatically, the transition effect is not the same as when you click on dots to change slides.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add, change, or remove transitions between slides
Slide transitions are the animation-like effects that occur when you move from one ... You can control the speed, add sound, and customize...
Read more >
Animating Slide Transitions - Help+Manual
Slide transition animation is defined in the Position & Timing section in the Properties pane. You can only turn animation on or off...
Read more >
Video starts when current slide // Superslides - Stack Overflow
set autoPlay:false in the data-property attribute and change ur code to jQuery('#fullscreen').on('animated.slides', function () { var ...
Read more >
Build a Custom Full Page Slider with CSS and JavaScript
When moving an HTML element, whether it be a transition or animation, it is advised to use the transform property. I see a...
Read more >
Angular Animations — Let's create a carousel with reusable ...
Interact with the Slides. In carousel.component.ts we declare the property currentSlide . We will use this property to determine which slide is ...
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