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

#2391 - Multiple images in the viewer #2419

Merged
merged 13 commits into from
Nov 27, 2024

Conversation

SebinSong
Copy link
Collaborator

@SebinSong SebinSong commented Nov 11, 2024

closes #2391

[Desktop]
It also allows navigation via arrows in the keyboard too.

image

[Mobile]

@SebinSong SebinSong self-assigned this Nov 11, 2024
Copy link

cypress bot commented Nov 11, 2024

group-income    Run #3441

Run Properties:  status check passed Passed #3441  •  git commit 14dee47f77 ℹ️: Merge 1d121f85beef07854f4b91dd8c086a791550ccad into fac9a1b067cd5097ce2b15c85423...
Project group-income
Branch Review sebin/task/#2391-multiple-images-in-the-viewer
Run status status check passed Passed #3441
Run duration 09m 00s
Commit git commit 14dee47f77 ℹ️: Merge 1d121f85beef07854f4b91dd8c086a791550ccad into fac9a1b067cd5097ce2b15c85423...
Committer Sebin Song
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 10
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 111
View all changes introduced in this branch ↗︎

@@ -5,7 +5,7 @@
@mouseup='mouseUpHandler'
)
img.c-preview-image(ref='previewImg'
:class='{ "is-movable": isImageMovable }'
:class='{ "is-movable": isImageMovable, "is-hidden": !ephemeral.imgInitDone }'
Copy link
Collaborator Author

@SebinSong SebinSong Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discovered a bug where the image kind of flickers when it finishes the load/initialization steps(happens because image dimensions changes from it's natural size to the initial zoom value). So made a fix here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I noticed this behavior too but thought it was Android's fault.

ownerID: this.ownerID,
imgUrl: entry.url || this.objectURLList[index] || '',
createdAt: this.createdAt || new Date(),
id: randomHexString(12)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a random ID, wouldn't it be better to use a deterministic ID in this case? For example, I think the URLs would be both deterministic and unique (or it could be combined with the message ID).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid suggestion. But I think it's safe to use the random string here because the id here is merely used for differentiating multiple images rendered in the DOM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it's safe also as used here, but I'm partial to deterministic IDs because they're always safe and can also be used, e.g., in testing.

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review ready!

this.ephemeral.currentIndex = this.initialIndex
}

this.touchMatchMedia = window.matchMedia('(hover: none) and (pointer: coarse)')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the same issue as on the other PR with not having this in data ()...

)
}
})
const initialIndex = allImageAttachments.findIndex(attachment => attachment.imgUrl === objectURL) || 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findIndex returns -1 when an image isn't found, not falsy. This || 0 wouldn't get triggered on -1.

Copy link
Collaborator Author

@SebinSong SebinSong Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed.


const args = { changeFactor: changeFactorToUse, center }
if (changeFactorTooLarge) { return }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason Claude thinks line 128 below is an issue and says:

Failure to Update State on Large Change Factor

I'm not sure what to make of this comment. Feel free to ignore if nothing.

Copy link
Collaborator Author

@SebinSong SebinSong Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this line was added intentionally (to remove a sudden jump in zoom value when pinch action was performed quickly and stopped) and added a NOTE: comment for this as well in line L102

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@taoeffect taoeffect merged commit 4464fea into master Nov 27, 2024
4 checks passed
@taoeffect taoeffect deleted the sebin/task/#2391-multiple-images-in-the-viewer branch November 27, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement cycling between multiple images in the image viewer
3 participants