File tree Expand file tree Collapse file tree
Cloudinary-pwa-kit/packages/pwa-cloudinary/app/components/cloudinary-widgets Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,21 +4,22 @@ import { cloudinary } from '../../../config/default'
44
55const RenderCloudinaryGalleryWidget = ( { cloudinaryImageGallery = { } } ) => {
66
7+ const renderGallery = async ( ) => {
8+ const galleryOptions = cloudinaryImageGallery . cloudinaryImage . galleryWidget . options
9+ galleryOptions . queryParam = cloudinary . CLD_PGW_TRACKING_PARAM
10+ if ( typeof window !== 'undefined' && window . cloudinary && window . cloudinary . galleryWidget ) {
11+ if ( window . cldGallery ) {
12+ await window . cldGallery . update ( galleryOptions )
13+ } else {
14+ window . cldGallery = window . cloudinary . galleryWidget ( galleryOptions )
15+ window . cldGallery . render ( )
16+ }
17+ }
18+ }
19+
720 useEffect ( ( ) => {
821 if ( cloudinaryImageGallery && cloudinaryImageGallery . galleryEnabled ) {
9- const gallery = document . querySelector ( '#cld-gallery' )
10- const galleryOptions = cloudinaryImageGallery . cloudinaryImage . galleryWidget . options
11- galleryOptions . queryParam = cloudinary . CLD_PGW_TRACKING_PARAM
12- if ( typeof window !== 'undefined' && window . cloudinary && window . cloudinary . galleryWidget ) {
13- if ( window . cldGallery ) {
14- gallery . style . visibility = 'hidden'
15- cldGallery . update ( galleryOptions )
16- gallery . style . visibility = 'visible'
17- } else {
18- window . cldGallery = window . cloudinary . galleryWidget ( galleryOptions )
19- }
20- cldGallery . render ( )
21- }
22+ renderGallery ( )
2223 }
2324 } , [ cloudinaryImageGallery ] )
2425
You can’t perform that action at this time.
0 commit comments