Gallery won't open on load page with pid and gid in params
tomasztomys opened this issue · 2 comments
Gallery won't open on load page with pid and gid in params:
http://localhost:3000/dashboard/company/1/gallery#&gid=1&pid=1
should open gallery with photo (gid = 1, pid = 1)
https://codepen.io/daveclay/pen/LLPwKP
I'm trying to just get the instance of PhotoSwipe
to open by default, but setting isOpen={true}
doesn't do anything. It results in an empty photoswipe instance.
Hi, faced the same issue, isOpen should be definitely working, but it's not
here is how I made it work
-
is items add id
<PhotoSwipeGallery
items={[ {src, thumbnail, id: pictureId} ]} -
add id to img in thumbnailContent={item =>
<img id={item.id} src={item.thumbnail} width={400} height={400} style={{cursor: 'zoom-in'}} />
} -
if gid is in url then call this function:
openGallery(gid) {
const image = document.getElementById(gid)
var evObj = document.createEvent('Events');
evObj.initEvent('click', true, false);
image.dispatchEvent(evObj);
}
if you have more than 1 picture per gallery then you can use pid instead and simulate click by pid