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

Remove zoomable animation on Math #696

Merged
merged 4 commits into from
Aug 28, 2023

Conversation

nixterrimus
Copy link
Contributor

@nixterrimus nixterrimus commented Aug 27, 2023

Summary:

Having math animate with mathjax seems to be causing extra flickering. The math is fine after is "lands" and is holding still. This change adds a flag to the zoomable component so that we can disable animations.

zoomable-fix-demo.mov

Issue: https://khanacademy.atlassian.net/browse/LC-933

Test plan:

  • Test the storybook, I've added controls
    (Or check out the screencast)

@nixterrimus nixterrimus self-assigned this Aug 27, 2023
@changeset-bot
Copy link

changeset-bot bot commented Aug 27, 2023

🦋 Changeset detected

Latest commit: a561503

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@khanacademy/perseus Minor
@khanacademy/perseus-editor Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Aug 27, 2023

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/dull-bobcats-perform.md, packages/perseus/src/components/zoomable-tex.tsx, packages/perseus/src/components/zoomable.tsx, packages/perseus/src/__tests__/__snapshots__/renderer.test.tsx.snap, packages/perseus/src/components/__stories__/zoomable.stories.tsx, packages/perseus/src/widgets/__tests__/__snapshots__/categorizer.test.ts.snap, packages/perseus/src/widgets/__tests__/__snapshots__/matrix.test.ts.snap, packages/perseus/src/widgets/__tests__/__snapshots__/number-line.test.ts.snap

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@khan-actions-bot khan-actions-bot requested a review from a team August 27, 2023 18:04
@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2023

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (99f27d3) and published it to npm. You
can install it using the tag PR696.

Example:

yarn add @khanacademy/perseus@PR696

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2023

Size Change: +55 B (0%)

Total Size: 847 kB

Filename Size Change
packages/perseus/dist/es/index.js 396 kB +55 B (0%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 38 kB
packages/kmath/dist/es/index.js 4.12 kB
packages/math-input/dist/es/index.js 103 kB
packages/perseus-core/dist/es/index.js 55 B
packages/perseus-editor/dist/es/index.js 268 kB
packages/perseus-error/dist/es/index.js 705 B
packages/perseus-linter/dist/es/index.js 21.2 kB
packages/pure-markdown/dist/es/index.js 3.64 kB
packages/simple-markdown/dist/es/index.js 12.6 kB

compressed-size-action

Copy link
Contributor

@handeyeco handeyeco left a comment

Choose a reason for hiding this comment

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

Looks good to me! I'd ask about tests, but this seems like something that would be near impossible to test.

packages/perseus/src/components/zoomable.tsx Outdated Show resolved Hide resolved
Co-authored-by: Matthew <matthewcurtis@khanacademy.org>
@@ -230,7 +230,7 @@ exports[`renderer rendering should render block math on mobile 1`] = `
style="overflow-x: auto; overflow-y: hidden; margin-top: -10px; margin-bottom: -10px; transform: translate3d(0,0,0); padding: 10px 16px 10px 16px;"
>
<span
style="display: block; width: 100%; transform: scale(1, 1) translate(0, 8px); transform-origin: 0 0; opacity: 0;"
style="display: block; width: 100%; transform: scale(1, 1); transform-origin: 0 0; opacity: 1;"
Copy link
Member

Choose a reason for hiding this comment

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

As long as we're changing this line, could we get rid the transform and transform-origin properties? Do they have any effect now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are still used- in two places. Non math content uses it and also it's used for the zoom-in, zoom-out effect.

const shouldSlide = !disableEntranceAnimation && !visible;
const translateOffset = shouldSlide ? " translate(0, 8px)" : "";
const opacity = shouldSlide ? 0 : 1;

Copy link
Member

Choose a reason for hiding this comment

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

suggestion: I find this (and lines 272-275) a little hard to follow with all the boolean logic and ternaries. It might be nice to pull this code out into a function that could be tested. IMO everything between lines 252 and 275 could go into that function. Calling it would look something like this:

const transitionStyle = computeTransitionStyle({
  visible,
  zoomed,
  scale,
  animateHeight,
  disableEntranceAnimation,
});

I think I'd find reading the tests for that function easier than trying to work through all the possibilities in my head.

@nixterrimus nixterrimus merged commit 3078825 into main Aug 28, 2023
9 checks passed
@nixterrimus nixterrimus deleted the new/remove-zoomable-tex-animation branch August 28, 2023 20:21
disableEntranceAnimation: {
control: {type: "boolean"},
},
},
Copy link
Member

Choose a reason for hiding this comment

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

Nice! TIL how to add controls to storybook.

Copy link
Member

@benchristel benchristel left a comment

Choose a reason for hiding this comment

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

Thanks for digging into this! I think it's going to make a big difference for mobile users. I left a suggestion inline, but it's non-blocking. LGTM!

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