@@ -65,6 +65,55 @@ For more examples, see [`example/App.jsx`](https://github.com/xiaolin/react-imag
6565
6666<br />
6767
68+ ## 📘 TypeScript
69+
70+ This package includes TypeScript definitions. Import types for props, items, and refs:
71+
72+ ``` tsx
73+ import ImageGallery from " react-image-gallery" ;
74+ import type {
75+ GalleryItem ,
76+ ImageGalleryProps ,
77+ ImageGalleryRef ,
78+ } from " react-image-gallery" ;
79+
80+ const images: GalleryItem [] = [
81+ {
82+ original: " https://picsum.photos/id/1018/1000/600/" ,
83+ thumbnail: " https://picsum.photos/id/1018/250/150/" ,
84+ originalAlt: " Mountain landscape" ,
85+ description: " A beautiful mountain view" ,
86+ },
87+ {
88+ original: " https://picsum.photos/id/1015/1000/600/" ,
89+ thumbnail: " https://picsum.photos/id/1015/250/150/" ,
90+ originalAlt: " Flowing river" ,
91+ },
92+ {
93+ original: " https://picsum.photos/id/1019/1000/600/" ,
94+ thumbnail: " https://picsum.photos/id/1019/250/150/" ,
95+ originalAlt: " Sunset over the ocean" ,
96+ },
97+ ];
98+
99+ function MyGallery() {
100+ const galleryRef = useRef <ImageGalleryRef >(null );
101+
102+ const handleClick = () => {
103+ galleryRef .current ?.fullScreen ();
104+ };
105+
106+ return (
107+ <>
108+ <ImageGallery ref = { galleryRef } items = { images } />
109+ <button onClick = { handleClick } >Enter Fullscreen</button >
110+ </>
111+ );
112+ }
113+ ```
114+
115+ <br />
116+
68117## ⚙️ Props
69118
70119- ` items ` : (required) Array of objects. Available properties:
@@ -153,9 +202,12 @@ For more examples, see [`example/App.jsx`](https://github.com/xiaolin/react-imag
153202
154203The following functions can be accessed using [ refs] ( https://reactjs.org/docs/refs-and-the-dom.html )
155204
156- - ` play() ` : plays the slides
157- - ` pause() ` : pauses the slides
158- - ` toggleFullScreen() ` : toggles full screen
205+ - ` play() ` : starts the slideshow
206+ - ` pause() ` : pauses the slideshow
207+ - ` togglePlay() ` : toggles between play and pause
208+ - ` fullScreen() ` : enters fullscreen mode
209+ - ` exitFullScreen() ` : exits fullscreen mode
210+ - ` toggleFullScreen() ` : toggles fullscreen mode
159211- ` slideToIndex(index) ` : slides to a specific index
160212- ` getCurrentIndex() ` : returns the current index
161213
0 commit comments