Skip to content

Add rise and fadeAndRise paragraph animation styles - #152

Draft
Jun Yan (junyan72) wants to merge 1 commit into
mainfrom
paragraph-rise-animation
Draft

Add rise and fadeAndRise paragraph animation styles#152
Jun Yan (junyan72) wants to merge 1 commit into
mainfrom
paragraph-rise-animation

Conversation

@junyan72

Copy link
Copy Markdown
Contributor

Summary

Adds vertical-offset ("rise") streaming animations alongside the existing fade, by generalizing the paragraph animation engine so its per-frame mutation is pluggable. This is a step toward character-level streaming animation.

  • Add ParagraphAnimationStyle enum (.fade, .rise, .fadeAndRise) plus rise/wave constants in ParagraphAnimation.swift.
  • Expose paragraphAnimationStyle on MarkdownRenderConfig with a withParagraphAnimationStyle(value:) builder (defaults to .fade, so existing behavior is unchanged).
  • Generalize updateTextViewWithCurrentAnimations() in ParagraphUIView and ParagraphNSView to apply foreground-color alpha (fade) and/or .baselineOffset (rise) per range.
  • Animate rise per composed-character sequence with a continuous, capped stagger (delayBetweenCharacters, maxWaveLead) so glyphs ripple in instead of whole words moving as rigid blocks. Added splitIntoCharacters(withIn:).
  • Thread the style through both SwiftUI wrappers and demo .fadeAndRise in the sample app.

Note: intrinsic size is kept cached during animation, so surrounding blocks don't reflow; a negative baselineOffset can slightly clip descenders (tunable via riseDistance). Pure .fade still uses the original per-word path.

This does not yet implement the buffered "release one grapheme at a time" sequential mode described in the issue.

Refs #149

Validation

  • swift build — succeeds (only pre-existing deprecation warnings).
  • swiftlint --strict on the changed files — clean.
  • make generate-sample-project — regenerates the sample app project.
  • Manual verification in the sample app with .fadeAndRise.

OSS readiness

  • No secrets, internal URLs, private identifiers, or product-only service names were added.
  • Public docs, fixtures, or notices were updated if behavior or dependencies changed. (new public API is documented inline; default behavior unchanged)
  • Third-party dependency changes (adds, removes, version bumps) are intentional and reviewed. (no dependency changes)
  • Streaming/incomplete markdown behavior remains covered by fixtures or tests. (no automated tests added yet for the new styles)

Introduce a pluggable per-word/per-character animation engine for streamed
paragraphs, reusing the existing CADisplayLink pipeline.

- Add ParagraphAnimationStyle enum (.fade, .rise, .fadeAndRise) and rise/wave
  constants in ParagraphAnimation.swift
- Add paragraphAnimationStyle to MarkdownRenderConfig with a builder
- Generalize per-frame mutation in ParagraphUIView/ParagraphNSView to apply
  alpha (fade) and/or .baselineOffset (rise)
- Animate rise per composed-character sequence with a continuous, capped
  stagger so glyphs ripple in instead of moving as rigid word blocks
- Wire the style through the SwiftUI wrappers and demo it in the sample app

Refs #149

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ef6fbb1d-45ac-44b9-9430-86a8f6163326
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.

1 participant