Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image gif 类型切换bug #175

Closed
Blizzard-liu opened this issue May 17, 2023 · 12 comments
Closed

image gif 类型切换bug #175

Blizzard-liu opened this issue May 17, 2023 · 12 comments

Comments

@Blizzard-liu
Copy link

666
test (2).zip
bf07ec547abfd836ea06722fe306170

@ananzhusen
Copy link
Contributor

你这代码逻辑有问题

@Blizzard-liu
Copy link
Author

哪里有问题 还请明示

@ananzhusen
Copy link
Contributor

这是在你代码基础上改的示例代码
image

@Blizzard-liu
Copy link
Author

还是没看懂我的逻辑错哪了 按照你这个写法 多个图片判断怎么写呢

@ananzhusen
Copy link
Contributor

你不能在遍历的时候去改数据,又用这个数据去做判断处理

@Blizzard-liu
Copy link
Author

image

确实不太对 tag应该改成id

时间改小一点 问题还是一样的 gif图片没有remove

@Blizzard-liu
Copy link
Author

@ananzhusen
image
你这个写法 时间改小点 就可以复现了

@Alsmile
Copy link
Member

Alsmile commented Jun 2, 2023

#166 可能是同一个问题,这里先关联

@SignDawn
Copy link
Contributor

看了下源码,当按如下流程执行时

  1. 切换成 gif 图片,开始加载 gif 图片,目前加载未完成,未插入 dom 树
  2. gif 未加载完成,切换成 image 图片,会去销毁 dom 树中的 gif ,但 gif 还未加载完成,未插入 dom 树,所以没有销毁
  3. gif 终于加载完成,插入到 dom 树,该 gif 成为一个没有引用(指针)指向到它的 dom ,且后续都不会被销毁了
    按照这个流程执行,就会出现问题,所以 定时器 时间越短,越容易出现问题。

@SignDawn
Copy link
Contributor

#184

@SignDawn
Copy link
Contributor

可查看这个 pr ,可以解决这个问题,思路在于
gif onload 回调执行时,若当前 pen 对应的 gif 与本次回调加载的 img 不是同一个,那么就不插入到 dom 中

@Alsmile Alsmile closed this as completed Jun 10, 2023
@Blizzard-liu
Copy link
Author

666 大佬就是牛逼

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

No branches or pull requests

4 participants