开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 261|回复: 1
收起左侧

[分享] 我不会AE,但是我会Code

[复制链接]
结帖率:100% (4/4)
发表于 2025-8-23 20:41:01 | 显示全部楼层 |阅读模式   福建省福州市
本帖最后由 阿珏 于 2025-8-23 20:58 编辑

《别当欧尼酱了!》绪山真寻 CSS Animation




精美动画展示
我的私房照
好听的音乐
日常生活的小片段



项目地址:https://github.com/iAJue/Mahiro


[JavaScript] 纯文本查看 复制代码
/**
 * 动画序列管理器
 * 用于管理多个动画组件的顺序执行
 */
export class AnimationManager {
  constructor(options = {}) {
    this.sequence = options.sequence || []
    this.currentIndex = -1
    this.isPlaying = false
    this.isPaused = false
    this.callbacks = {
      onStart: options.onStart || (() => {}),
      onComplete: options.onComplete || (() => {}),
      onAnimationStart: options.onAnimationStart || (() => {}),
      onAnimationComplete: options.onAnimationComplete || (() => {}),
      onPause: options.onPause || (() => {}),
      onResume: options.onResume || (() => {})
    }
    this.autoStart = options.autoStart || false
  }


  /**
   * 设置动画序列
   */
  setSequence(sequence) {
    this.sequence = sequence
    return this
  }


  /**
   * 添加动画到序列
   */
  addAnimation(animationName) {
    this.sequence.push(animationName)
    return this
  }


  /**
   * 开始动画序列
   */
  start() {
    if (this.isPlaying && !this.isPaused) return this
    
    console.log('动画序列开始')
    this.isPlaying = true
    this.isPaused = false
    this.currentIndex = -1
    this.callbacks.onStart()
    this.next()
    return this
  }


  /**
   * 播放下一个动画
   */
  next() {
    if (this.isPaused) return this


    if (this.currentIndex < this.sequence.length - 1) {
      this.currentIndex++
      const animationName = this.sequence[this.currentIndex]
      console.log(`准备播放动画: ${animationName}`)
      if (!this.isPaused) {
        this.callbacks.onAnimationStart(animationName, this.currentIndex)
      }
    } else {
      this.complete()
    }
    return this
  }


  /**
   * 动画完成回调
   */
  onAnimationComplete(animationName) {
    if (!this.isPlaying) return
    
    console.log(`动画 ${animationName} 完成`)
    this.callbacks.onAnimationComplete(animationName, this.currentIndex)
    
    // 继续下一个动画
    this.next()
  }


  /**
   * 完成所有动画
   */
  complete() {
    console.log('所有动画播放完成')
    this.isPlaying = false
    this.isPaused = false
    this.callbacks.onComplete()
  }


  /**
   * 暂停动画序列
   */
  pause() {
    if (!this.isPlaying || this.isPaused) return this
    
    console.log('动画序列暂停')
    this.isPaused = true
    this.callbacks.onPause()
    return this
  }


  /**
   * 恢复动画序列
   */
  resume() {
    if (!this.isPlaying || !this.isPaused) return this
    
    console.log('动画序列恢复')
    this.isPaused = false
    this.callbacks.onResume()
    return this
  }


  /**
   * 停止动画序列
   */
  stop() {
    console.log('动画序列停止')
    this.isPlaying = false
    this.isPaused = false
    this.currentIndex = -1
    return this
  }


  /**
   * 重置动画序列
   */
  reset() {
    this.stop()
    console.log('动画序列重置')
    return this
  }


  /**
   * 跳转到指定动画
   */
  jumpTo(animationName) {
    const index = this.sequence.indexOf(animationName)
    if (index !== -1) {
      this.currentIndex = index - 1
      this.next()
    }
    return this
  }


  /**
   * 获取当前动画名称
   */
  getCurrentAnimation() {
    return this.currentIndex >= 0 ? this.sequence[this.currentIndex] : null
  }


  /**
   * 获取当前进度
   */
  getProgress() {
    return {
      current: this.currentIndex + 1,
      total: this.sequence.length,
      percentage: this.sequence.length > 0 ? ((this.currentIndex + 1) / this.sequence.length) * 100 : 0
    }
  }


  /**
   * 是否正在播放
   */
  isRunning() {
    return this.isPlaying && !this.isPaused
  }
}


/**
 * 创建动画管理器实例的工厂函数
 */
export function createAnimationManager(options) {
  return new AnimationManager(options)
}





截图


结帖率:100% (4/4)
 楼主| 发表于 2025-8-23 21:14:34 | 显示全部楼层   福建省福州市
8.png 5.png 7.png 4.png 1.png 3.png 2.png
6.png
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

关闭

精易论坛 - 有你更精彩上一条 /2 下一条

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报QQ: 793400750,邮箱:wp@125.la
网站简介:精易论坛成立于2009年,是一个程序设计学习交流技术论坛,隶属于揭阳市揭东区精易科技有限公司所有。
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备2025452707号) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表