V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
yuang
V2EX  ›  浏览器

哪位大佬这个网站 https://www.dragonfly.xyz/ 的的这个文本滚动效果是什么实现的?用的什么编码技术

  •  
  •   yuang · Apr 11, 2024 · 2901 views
    This topic created in 751 days ago, the information mentioned may be changed or developed.

    Dragonfly

    PORTFOLIO 这一节下面

    aliyun2017
        2
    aliyun2017  
       Apr 11, 2024
    @aliyun2017 看错题了
    aliyun2017
        3
    aliyun2017  
       Apr 11, 2024   ❤️ 1
    yohane3016
        4
    yohane3016  
       Apr 11, 2024   ❤️ 1
    整站 react 写的,不过这里的文字动效和用什么框架无关,打了下断点简单看了下实现思路:
    把 ASCII 中的可显示字符集当做随机字符池子 chars ,然后根据你要显示的字符串划分进度,例如 10 个字符就每个字符 10%的进度,假设动画长度 1s ,则:
    0-0.1s: 将所有字符替换成 chars 中的随机字符
    0.1s-0.2s: 固定第一个字符,将剩余字符随机替换
    0.2s-0.3s: 固定第一二个字符,将剩余字符随机替换
    以此类推
    直到动画结束显示你要显示的字符
    yohane3016
        5
    yohane3016  
       Apr 11, 2024   ❤️ 1
    字符替换成随机字符这个操作要每帧执行或者你自己控制帧率
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2345 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 10:52 · PVG 18:52 · LAX 03:52 · JFK 06:52
    ♥ Do have faith in what you're doing.