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.

Crossfading slides between one another on transition?

See original GitHub issue

Hey there 👋

I was wondering if it is currently possible with this package to perform a crossfade between one carousel slide and another during a transition

By this I mean the image fades in on top of one another like this example

Currently I have been able to perform a fadeIn and fadeOut effect using the classNameVisible and classNameHidden classes however due to the transform applied the previous slide is always offscreen and a seamless transition cannot be performed.

Is this possible currently using this package?

Many thanks, Paul

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
dschicommented, Feb 20, 2022

This seems to be working for me:

  • diable transition translateX
  • move each child to position 0
  • add fade in and fade out animation (the code works for 10 slides)
.carousel__slider-tray {
   transform: none !important;
  .carousel__slide {
    opacity: 1;
    &.carousel__slide--visible {
      animation: fade-in-carousel 0.7s forwards;
    }
    &.carousel__slide--hidden {
      animation: fade-out-carousel 0.7s forwards;
    }
    @for $i from 1 through 10 {
      &:nth-child(#{$i + 1}) {
        $width: $i * -100 + '%';
        transform: translateX(#{$width}) translateX(0px);
      }
    }
  }
}
@keyframes fade-in-carousel {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes fade-out-carousel {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
1reaction
lukethacodercommented, Aug 3, 2020

attempted this one with the below but couldn’t get it working properly.

.slider__initial {
  background-color: green;
  opacity: 1;
  transition-property: background-color, opacity;
  transition-timing-function: ease;
  transition-duration: 2s, 1s;
}
.slider__active {
  background-color: blue;
  opacity: 0;
}
<CarouselProvider
  naturalSlideWidth={100}
  naturalSlideHeight={125}
  totalSlides={3}
  currentSlide={slide}
  visibleSlides={1}
>
  <Slider className="slider__initial" classNameAnimation="slider__active">
    <Slide index={0}>first</Slide>
    <Slide index={1}>second</Slide>
    <Slide index={2}>third</Slide>
  </Slider>
</CarouselProvider>

I did manage to get classNameHidden and classNameVisible working, but the sliding animations still happen. Passing a random class to classNameAnimation stops the sliding animation, but doesn’t stop the sliding ability. Ideally it would be able to fadeIn/Out.


Would be awesome if we had an example of using classNameAnimation to achieve different slide transition animations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Crossfade animations in PowerPoint
The simplest way to achieve crossfade animations in PowerPoint is using the fade transition provided. First, insert an image on each slide.
Read more >
Crossfading Two Views | Android Developers
This animation is useful for situations where you want to switch content or views in your app. Crossfades are very subtle and short...
Read more >
Crossfade audio: What crossfade is and how to edit it
Crossfading is an audio editing technique that creates a smooth transition between two audio clips. When you crossfade audio, you make one ...
Read more >
Crossfade audio in Final Cut Pro
A crossfade is a common type of audio transition between two clips, in which the first clip's audio fades down while the second...
Read more >
Add transitions between slides
Try it! · Select the slide you want to add a transition to. · Select the Transitions tab and choose a transition. Select...
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