✨ feat(decrypted-text): add click/toggle mode & fix inViewHover re-trigger bug#895
✨ feat(decrypted-text): add click/toggle mode & fix inViewHover re-trigger bug#895angelarreolagg wants to merge 5 commits intoDavidHDev:mainfrom
Conversation
…e to "InViewHover" mode
|
That's good, but your code does not do what the issue requested. The click mode should have the text start out as encrypted, and only decrypted after the first click. Please read the issue again and update your implementation. |
…ions into feat/decrypted-text-on-click
…th click mode and refactor for improved functionality
|
Hey David, thanks for the feedback! English isn't my first language so I just saw "click" and assumed that was the solution — my bad 😅. I re-read the issue and worked on a proper implementation. While doing so, I noticed that inViewHover (formerly both) had a bug present since the original version, so I fixed that as well — it was actually solved indirectly by the refactor needed to handle the new click mode correctly. This new version addresses the issue as requested and also ships a clickMode prop with once and toggle support as a small bonus. The PR description has been updated to reflect all the changes. Second time's the charm! 🤞 |
Fixes #891
Summary
This PR adds a
clickmode to theDecryptedTextcomponent (part of the TextAnimations collection), allowing the animation to trigger when the user clicks on the element. AclickModeprop is also introduced, supportingonce(decrypt on first click, stays decrypted) andtoggle(alternates between encrypted/decrypted on each click). Since we now have a third animation mode, thebothoption has been renamed toinViewHover.Important
A pre-existing bug was also fixed in this pass: when using
animateOn="both", the hover animation would silently fail after the in-view animation completed. The root cause was both triggers sharing the sameisHoveringboolean — once the view animation set it totrue, subsequent hover events produced no state change and the effect never re-fired. This was resolved by splitting animation control into dedicated, independent functions (triggerDecrypt,triggerReverse) backed by more granular state (isAnimating,isDecrypted,direction).Important
Screen.Recording.2026-03-01.at.19.03.09.mov
Changes
animateOn="click"starts the text in an encrypted state and decrypts on click.clickModeprop added:once(default) decrypts once and stays;togglere-encrypts on the next click.bothrenamed toinViewHover: with a third mode now available, the rename better reflects the actual behavior.src/constants/code/TextAnimations/decryptedTextCode.jsnow includes an example usinganimateOn="click"withclickMode="toggle".Applied changes in:
src/content/TextAnimations/DecryptedText/DecryptedText.jsxsrc/tailwind/TextAnimations/DecryptedText/DecryptedText.jsxsrc/ts-default/TextAnimations/DecryptedText/DecryptedText.tsxsrc/ts-tailwind/TextAnimations/DecryptedText/DecryptedText.tsxsrc/constants/code/TextAnimations/decryptedTextCode.jsComponent Demo —
animateOnprop updated andclickModecontrol addedclickmode added.bothrenamed toView & Hoverwith value changed toinViewHover.clickModepreview control addedApplied changes in:
src/demo/TextAnimations/DecryptedText.jsxRegistry artifacts regenerated
public/r/DecryptedText-JS-CSS.jsonpublic/r/DecryptedText-JS-TW.jsonpublic/r/DecryptedText-TS-CSS.jsonpublic/r/DecryptedText-TS-TW.jsonDemo
Screen.Recording.2026-03-01.at.19.27.13.mov
Verification
npm run build: passed