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

feat(discoverability): add image cursor experience #1270

Merged
merged 30 commits into from
Oct 20, 2020

Conversation

ChenCodes
Copy link
Contributor

@ChenCodes ChenCodes commented Oct 5, 2020

Changes in this PR:

  • store FF in options in Preview.js
  • add FF into init method for AnnotationControls
  • add logic for turning button mode to be off when the the image overflows the viewport after zoom
  • add unit tests

Demo:
ezgif com-gif-maker (1)

@ChenCodes ChenCodes requested review from mxiao6, jstoffan and ConradJChan and removed request for mxiao6 and jstoffan October 5, 2020 17:49
src/lib/AnnotationControls.ts Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/__tests__/AnnotationControls-test.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageBaseViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/__tests__/ImageViewer-test.js Outdated Show resolved Hide resolved
src/lib/__tests__/AnnotationControls-test.js Outdated Show resolved Hide resolved
src/lib/__tests__/AnnotationControls-test.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageBaseViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageBaseViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Show resolved Hide resolved
@ChenCodes ChenCodes marked this pull request as ready for review October 6, 2020 19:29
@ChenCodes ChenCodes requested a review from a team as a code owner October 6, 2020 19:29
src/lib/viewers/image/ImageViewer.js Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/__tests__/ImageViewer-test.js Outdated Show resolved Hide resolved
src/lib/viewers/image/__tests__/ImageViewer-test.js Outdated Show resolved Hide resolved
src/lib/viewers/image/__tests__/ImageViewer-test.js Outdated Show resolved Hide resolved
@@ -17,12 +18,29 @@ class ImageViewer extends ImageBaseViewer {
this.updatePannability = this.updatePannability.bind(this);
this.handleImageDownloadError = this.handleImageDownloadError.bind(this);
this.handleAssetAndRepLoad = this.handleAssetAndRepLoad.bind(this);
this.handleZoomEvent = this.handleZoomEvent.bind(this);
this.annotationControlsFSM = new AnnotationControlsFSM(
Copy link
Contributor

Choose a reason for hiding this comment

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

AnnotationControlsFSM has already been created in BaseViewer constructor, right? Should we move the logic to BaseViewer? Or call something like this.annotationControlsFSM.setState here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think @ConradJChan and I discussed that we wanted ImageViewer to instantiate its own instance of AnnotationControlsFSM.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it need to re-instantiate when enableAnnotationsImageDiscoverability === false? How about:

if (this.options.enableAnnotationsImageDiscoverability) {
    this.annotationControlsFSM = new AnnotationControlsFSM(AnnotationState.REGION_TEMP);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also make sure that if enableAnnotationsImageDiscoverability === false, that we get the old ImageViewer experience, i.e. not the enableAnnotationsDiscoverability experience

Copy link
Contributor Author

@ChenCodes ChenCodes Oct 20, 2020

Choose a reason for hiding this comment

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

Could you elaborate a little on this? Do you mean that we should have a check like this:

if (enableAnnotationsImageDiscoverability) {
     this.annotationControlsFSM = new AnnotationControlsFSM(AnnotationState.REGION_TEMP);
}

src/lib/viewers/image/ImageViewer.js Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
jest.spyOn(image, 'processAnnotationModeChange');
});

test.each`
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this test may be combining too many things. Maybe split it out to a test based on type to make sure it doesn't get processed and the another test for the combinations of currentState and whether the image overflows

Copy link
Contributor

Choose a reason for hiding this comment

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

The should param is probably unnecessary. Maybe just update the test description to include the height and width, otherwise consider breaking out a separate test to test the currentState vs overflow conditions

@@ -17,12 +18,29 @@ class ImageViewer extends ImageBaseViewer {
this.updatePannability = this.updatePannability.bind(this);
this.handleImageDownloadError = this.handleImageDownloadError.bind(this);
this.handleAssetAndRepLoad = this.handleAssetAndRepLoad.bind(this);
this.handleZoomEvent = this.handleZoomEvent.bind(this);
this.annotationControlsFSM = new AnnotationControlsFSM(
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it need to re-instantiate when enableAnnotationsImageDiscoverability === false? How about:

if (this.options.enableAnnotationsImageDiscoverability) {
    this.annotationControlsFSM = new AnnotationControlsFSM(AnnotationState.REGION_TEMP);
}

src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/ImageViewer.js Show resolved Hide resolved
@ChenCodes ChenCodes force-pushed the add-image-discoverability-experience branch from 5af3073 to 3353da4 Compare October 20, 2020 19:55
src/lib/viewers/image/ImageViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/image/__tests__/ImageViewer-test.js Outdated Show resolved Hide resolved
src/lib/viewers/image/__tests__/ImageViewer-test.js Outdated Show resolved Hide resolved
jest.spyOn(image, 'processAnnotationModeChange');
});

test.each`
Copy link
Contributor

Choose a reason for hiding this comment

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

The should param is probably unnecessary. Maybe just update the test description to include the height and width, otherwise consider breaking out a separate test to test the currentState vs overflow conditions

ConradJChan
ConradJChan previously approved these changes Oct 20, 2020
src/lib/viewers/image/__tests__/ImageViewer-test.js Outdated Show resolved Hide resolved
@ChenCodes ChenCodes merged commit b42768a into box:master Oct 20, 2020
@ChenCodes ChenCodes deleted the add-image-discoverability-experience branch October 20, 2020 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants