Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Only fire STACK_NEW_IMAGE event after we are certain this image … #72

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions packages/core/src/RenderingEngine/StackViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,13 @@ class StackViewport extends Viewport implements IStackViewport {
imageIdIndex: number,
imageId: string
) {
// Perform this check after the image has finished loading
// in case the user has already scrolled away to another image.
// In that case, do not render this image.
if (this.currentImageIdIndex !== imageIdIndex) {
return;
}

const eventDetail: EventTypes.StackNewImageEventDetail = {
image,
imageId,
Expand Down Expand Up @@ -1274,13 +1281,6 @@ class StackViewport extends Viewport implements IStackViewport {
// Todo: trigger an event to allow applications to hook into END of loading state
// Currently we use loadHandlerManagers for this

// Perform this check after the image has finished loading
// in case the user has already scrolled away to another image.
// In that case, do not render this image.
if (this.currentImageIdIndex !== imageIdIndex) {
return;
}

// Trigger the image to be drawn on the next animation frame
this.render();

Expand Down Expand Up @@ -1364,6 +1364,16 @@ class StackViewport extends Viewport implements IStackViewport {
return new Promise((resolve, reject) => {
// 1. Load the image using the Image Loader
function successCallback(image, imageIdIndex, imageId) {
// Todo: trigger an event to allow applications to hook into END of loading state
// Currently we use loadHandlerManagers for this

// Perform this check after the image has finished loading
// in case the user has already scrolled away to another image.
// In that case, do not render this image.
if (this.currentImageIdIndex !== imageIdIndex) {
return;
}

const eventDetail: EventTypes.StackNewImageEventDetail = {
image,
imageId,
Expand All @@ -1375,16 +1385,6 @@ class StackViewport extends Viewport implements IStackViewport {

this._updateActorToDisplayImageId(image);

// Todo: trigger an event to allow applications to hook into END of loading state
// Currently we use loadHandlerManagers for this

// Perform this check after the image has finished loading
// in case the user has already scrolled away to another image.
// In that case, do not render this image.
if (this.currentImageIdIndex !== imageIdIndex) {
return;
}

// Trigger the image to be drawn on the next animation frame
this.render();

Expand Down