确定 GIF 动画状态?

问题描述:

有没有办法通过javascript检测GIF图片的动画是否完成?

Is there any way to detect via javascript whether a GIF image's animation is completed or not?

现在可以了.有一些包可用于从字节缓冲区中提取信息.像 gif-info.

By now it's possible. There are packages available to extract information from byte buffer. Like gif-info.

结合 HTMLImage.onload 当动画应该已经结束时,可以完全延迟开始超时.

Combining that with HTMLImage.onload it's possible to start timeout exactly with delay when animation should already ended.

或者有持续时间值,我们可以在目标图像上设置 CSS 动画,以更稳定的方式工作.

Or having duration value we can set up CSS animation on target image that would work in more stable way.

虽然技术上可行,但看起来还是有点矫枉过正.

But although it's technically possible it still looks as overkill.