Knowls - avoid flash of content when revealing#2845
Closed
ascholerChemeketa wants to merge 2 commits into
Closed
Conversation
Collaborator
|
Really nice. And done quickly! Merged as-is. Thanks! |
Collaborator
|
Just for the record, it was @jjrsylvestre who first posted about this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Knowls currently can briefly flash the content before trying to shrink and then reveal it. This is most noticeable when the knowl contains complex content (e.g. MathJax) and has not been rendered yet.
This removes that flash of content and smooths the reveal process by better calculating the final height and padding of the element being revealed. There is still a brief hiccup as complex content is revealed as the content is loaded and rendered.
For issue identified by @siefkenj here: https://groups.google.com/g/pretext-dev/c/XgiX8KhH2Dw/m/eW9srLM8AQAJ?utm_medium=email&utm_source=footer
This pull request enhances the animation logic for revealing and hiding "knowl" content, focusing on smoother transitions and improved style management. The main improvements are the preservation and restoration of inline styles during animations, more accurate and visually consistent expand/collapse animations, and better handling of animation state to prevent conflicts.
Key changes include:
Animation and Style Management Improvements:
SlideRevealerto store and restore the inline styles (overflow,height,paddingTop,paddingBottom) of the animated element before and after animations, ensuring that original styles are not lost or corrupted during transitions. (js/knowl.js[1] [2]paddingTopandpaddingBottomindependently. The animation now uses theease-outeasing for a smoother effect. (js/knowl.js[1] [2]Animation State and Event Handling:
isBusy()method inSlideRevealerto prevent overlapping animations or state conflicts, and updated event handlers inLinkKnowlto check this state before triggering actions. (js/knowl.js[1] [2]Code Structure and Consistency:
LinkKnowlto store theSlideRevealerinstance as a member variable (slideHandler), ensuring consistent access and preventing duplicate handlers. (js/knowl.js[1] [2]LinkKnowlto use the new member variable, ensuring correct behavior throughout the component. (js/knowl.jsjs/knowl.jsL294-R366)These changes collectively result in more robust, visually consistent, and user-friendly knowl reveal/hide animations.