akiran / react-slick

React carousel component
http://react-slick.neostack.com/
MIT License
11.62k stars 2.09k forks source link

How can I add linear-gradient on slick-track level? #2342

Closed fzn0x closed 4 months ago

fzn0x commented 4 months ago

Hi @akiran thanks for maintaining this amazing open source, I would like to ask you or other contributors, how can I add linear-gradient on slick-track level?

I'm using the slider to capture the expected result below:

Screenshot 2024-02-07 174457

Instead on slider level, i want the linear-gradient above the slider, from what I inspect, it is the slide-track element that was above the slides, I already modify the slick-track CSS but somehow it messed up other styles.

Thanks!

fzn0x commented 4 months ago

Screenshot 2024-02-07 175055

Why not use the gradient on slider? This is what happen, we need the gradient on the parent element, which is slide-track, or maybe other?

fzn0x commented 4 months ago

Solved by adding new parent with pointer-events: none;

.SliderViewPortGradient {
  width: 100%;
  aspect-ratio: 9/3;
  height: 100%;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0.9) 100%);
  position: absolute;
  z-index: 100;
  pointer-events: none; /* Add this line to allow pointer events to pass through */
}