Skip to content

How would I add an overlay div on top of a slide image? #223

Answered by igordanchenko
bojandurmic asked this question in Q&A
Discussion options

You must be logged in to vote

@bojandurmic, here is an alternative implementation that I believe addresses the issue I was seeing in my tests.

import * as React from "react";
import {
  Lightbox,
  RenderSlideProps,
  ImageSlide,
  SlideImage,
  isImageSlide,
} from "yet-another-react-lightbox";
import Zoom from "yet-another-react-lightbox/plugins/zoom";
import "yet-another-react-lightbox/styles.css";

function ImageWithOverlay({ slide, offset, rect }: RenderSlideProps<SlideImage>) {
  const [loaded, setLoaded] = React.useState(false);

  return (
    <div
      style={{
        position: "relative",
        ...(slide.width && slide.height
          ? {
              maxWidth: `min(${slide.width}px, 100%)`,

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@igordanchenko
Comment options

@bojandurmic
Comment options

@igordanchenko
Comment options

@igordanchenko
Comment options

Answer selected by igordanchenko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants