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(images): Show UI earlier for large multi-page images #1061

Merged
merged 6 commits into from
Aug 29, 2019

Conversation

mickr
Copy link
Contributor

@mickr mickr commented Aug 29, 2019

No description provided.

@mickr mickr requested a review from a team as a code owner August 29, 2019 05:05
@boxcla
Copy link

boxcla commented Aug 29, 2019

Verified that @mickr has signed the CLA. Thanks for the pull request!

Copy link
Contributor

@ConradJChan ConradJChan left a comment

Choose a reason for hiding this comment

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

Should we also see if the workaround in setOriginalImageSize for IE11 is still needed?

@@ -30,6 +30,7 @@ class ImageBaseViewer extends BaseViewer {
this.handleMouseUp = this.handleMouseUp.bind(this);
this.cancelDragEvent = this.cancelDragEvent.bind(this);
this.finishLoading = this.finishLoading.bind(this);
this.showUi = this.showUi.bind(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

showUI?


handleFirstImageLoad() {
if (this.singleImageEls.length > MULTI_PAGE_LOAD_LIMIT) {
super.setOriginalImageSize(this.imageEl).then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this.imageEl be this.singleImageEls[0] instead?

});
}

this.finishLoading();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be in an else block since if there are more than 10 images we already call showUI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I don't believe so since there is more work for finishLoading to do with regards to resizing the images. We are just showing the UI earlier in this flow.

* @return {void}
*/
showUi() {
if (!this.isLoaded()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make this a guard clause to avoid the nested logic?

this.imageEl.classList.remove(CLASS_INVISIBLE);
this.loaded = true;
this.emit(VIEWER_EVENT.load);
this.showUi();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this need to be a separate method? It doesn't seem like the logical flow has changed and we don't have a showUI method in any other viewer. If so, can we simplify this to:

this.setOriginalImageSize(this.imageEl).then(this.showUI);

*/

handleFirstImageLoad() {
if (this.singleImageEls.length > MULTI_PAGE_LOAD_LIMIT) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this limit needed or can we always load the first page as soon as it's ready? Is there a penalty to doing so? If not, it seems like we can remove this entire block and call finishLoading directly.

jstoffan
jstoffan previously approved these changes Aug 29, 2019
Copy link
Collaborator

@jstoffan jstoffan left a comment

Choose a reason for hiding this comment

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

Clean.

* @protected
* @return {Promise} A promise that is resolved if the original image dimensions were set.
*/
setOriginalImageSizes() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any tests needed?

/**
* Handles the load event for the first image.
*
* @return {Promise} Promise to load bunch of images
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this accurate?

@@ -232,7 +232,7 @@ describe('lib/viewers/image/MultiImageViewer', () => {
});
});

describe('setOriginalImageSize()', () => {
describe('setOriginalImageSizes()', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the child tests now invoke multiImage.setOriginalImageSizes(), instead?

@mickr mickr merged commit a41eba7 into box:master Aug 29, 2019
@mickr mickr deleted the improve-tiff-loading branch August 29, 2019 23:22
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.

4 participants