Issue with toggling between galleries on same page
See original GitHub issueIf a page has more than one gallery when toggling between them currentIndex
still points to the previous one. In example below this causes second gallery to appear without any image. Because it has only one item and index 1
does not exist.
I have fixed it in componentDidUpdate
adding this:
if (itemsChanged) {
this._handleResize();
this.setState({ currentIndex: this.props.startIndex });
}
But its not ideal as newly mounted gallery will still inherit currentIndex
from previous one when items.length
is same.
I assume it’s a flaw or is it expected behaviour and I’m doing something fundamentally wrong here?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Toggling Between 2 Images Not Working, Using setInterval
New to JS. I am trying to toggle between showing two images, dragon.svg , and dragon1.svg , every 1 second starting on page...
Read more >Multiple galleries same page and pagination issues
When 2 galleries appear on the same page, they are always different galleries, never the same one twice.
Read more >Gallery sections
Add gallery sections to your pages to display sets of images in striking layouts instead of adding multiple image blocks to a block...
Read more >How to Fix Common Image Issues in WordPress
Beginner's guide to fix common image issues in WordPress such as how to create image gallery, align images, add captions in WordPress, ...
Read more >Why Are Web Page Images Not Showing?
One way to diagnose this problem is to see if the image is being hosted on an alternate server. If it is, try...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
fixed in commit
52c0cc7
Thank you, looks to be a bug as new currentIndex prop is not respected.