-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from k-t18/main
feat: ❇️ added image magnification library
- Loading branch information
Showing
4 changed files
with
307 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useState } from 'react'; | ||
import { CONSTANTS } from '../../services/config/app-config'; | ||
|
||
const useImageGallery = ({ slideShowImages }: any) => { | ||
const [enlargeImg, setEnlargeImg] = useState<string>(slideShowImages?.[0] || ''); // Track the enlarged image | ||
const [activeImgIndex, setActiveImgIndex] = useState<number>(0); // Track the active thumbnail index | ||
|
||
const handleSelectedImage = (imageLink: string, imgIndex: number) => { | ||
setEnlargeImg(imageLink); | ||
setActiveImgIndex(imgIndex); // Update the active index | ||
}; | ||
|
||
// Create srcSet for different screen resolutions | ||
const generateSrcSet = (image: string) => { | ||
return `${CONSTANTS.API_BASE_URL}/${image} 600w, | ||
${CONSTANTS.API_BASE_URL}/${image} 1200w, | ||
${CONSTANTS.API_BASE_URL}/${image} 1800w`; | ||
}; | ||
|
||
return { enlargeImg, activeImgIndex, handleSelectedImage, generateSrcSet }; | ||
}; | ||
|
||
export default useImageGallery; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface ProductSlideshowImages { | ||
slideShowImages: string[]; | ||
} |
Oops, something went wrong.