atlas-viewer / atlas

Main repository for Atlas viewer
https://atlas-viewer-storybook.netlify.app/
MIT License
5 stars 3 forks source link

add imageIdsLoaded array for deduping #50

Closed danieltbrennan closed 4 months ago

danieltbrennan commented 4 months ago

This adds the image ids to an array imageIdsLoaded which is then evaluated inschedulePaintToCanvas before incrementing imagesLoaded to avoid a scenario where a repeated calls to the method for the same image can result in a negative value for the latter, leaving the atlas canvas in a state where the opacity style never updates to 1 as observed in https://github.com/atlas-viewer/atlas/issues/49.

codesandbox-ci[bot] commented 4 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

stephenwf commented 4 months ago

Looks good @danieltbrennan. Is it worth also changing assignment to:

this.imagesPending = Math.min(0, this.imagesPending - this.imagesLoaded)

Just so the opacity condition is always met, even if there is another cause.

abrin commented 4 months ago

do we ever need to worry about the CanvasRenderer being reused? ie, do we need to worry abotu emptying the processed array?

stephenwf commented 4 months ago

We don't cancel the images (at the moment) so if it was reused, it would just continue loading and keeping the imagesPending up to date.. in theory!

abrin commented 4 months ago

cool! thanks

abrin commented 4 months ago

Stephen, is it possible to get a release in CanvasPanel with this too?

stephenwf commented 4 months ago

Sorry, yes! Just had some other things. Kicked off the release for Atlas (v2.2.3) should be available soon. Will update canvas panel after