Skip to content

Commit

Permalink
Fixed deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
theoplawinski committed Jul 16, 2024
1 parent 56114e3 commit f51c519
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions apps/front/src/components/lazyImage/LazyImage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CSSProperties, useEffect, useRef, useState } from "react"
import { cls } from "@cher-ami/utils"
import React, { CSSProperties, useEffect, useRef, useState } from "react"
import css from "./LazyImage.module.scss"
import { cls } from "@cher-ami/utils"

interface IProps {
src?: string
Expand All @@ -16,6 +16,9 @@ interface IProps {

export type Lazy = "lazyload" | "lazyloading" | "lazyloaded"

/**
* @name LazyImage
*/
function LazyImage(props: IProps) {
const imageRef = useRef<HTMLImageElement>(null)
const [lazyState, setLazyState] = useState<Lazy>("lazyload")
Expand Down Expand Up @@ -78,6 +81,7 @@ function LazyImage(props: IProps) {
// Set new src fallback
image.src = props.src ?? "data:,"

// end!
setLazyState("lazyloaded")
props.onLoaded?.(image)
observer.disconnect()
Expand All @@ -104,9 +108,9 @@ function LazyImage(props: IProps) {
ref={imageRef}
className={cls(css.image, lazyState)}
src={"data:,"}
data-src={props.dataSrc}
data-srcset={props.dataSrcSet}
alt={props.alt}
data-src={props?.dataSrc}
data-srcset={props?.dataSrcSet}
alt={props?.alt}
width={props.width}
height={props.height}
style={props.style}
Expand Down

0 comments on commit f51c519

Please sign in to comment.