spectacle
spectacle copied to clipboard
Avoid unnecessarily mounting the contents of slides that are not visible
Description
This improves performance by reducing the number of components responding to DeckContext updates. This is especially important when using Progress components in larger presentations- the current implementation results in rendering O(n^2) little circles (where n is the number of slides) despite only O(n) of them being visible.
The solution here is to have Deck keep track of the previous and next slide IDs, and pass them down through DeckContext. Slide reads these values from context and only renders its contents into the slidePortalNode if it's the active slide, the pending slide, or the previous slide.
Fixes # 1022
Type of Change
- [x] Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
Manual verification that behavior appears correct on example presentations.
Checklist: (Feel free to delete this section upon completion)
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] I have updated type definitions in
index.d.tsfor any breaking API changes - [x] My code follows the style guidelines of this project (I have run
yarn format) - [x] New and existing unit tests pass locally with my changes (I have run
yarn test) - [x] My changes generate no new warnings
- [x] Any dependent changes have been merged and published in downstream modules