Make animated image playback speed match browser (Firefox and Chrome) behaviour (#3506)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
Co-authored-by: Paweł <zneix@zneix.eu>
This commit is contained in:
Patrick Geneva
2022-01-15 14:23:08 -05:00
committed by GitHub
parent 499d06fcd1
commit e742860af7
2 changed files with 10 additions and 2 deletions
+9 -2
View File
@@ -152,8 +152,15 @@ namespace detail {
if (reader.read(&image))
{
QPixmap::fromImage(image);
int duration = std::max(20, reader.nextImageDelay());
// It seems that browsers have special logic for fast animations.
// This implements Chrome and Firefox's behavior which uses
// a duration of 100 ms for any frames that specify a duration of <= 10 ms.
// See http://webkit.org/b/36082 for more information.
// https://github.com/SevenTV/chatterino7/issues/46#issuecomment-1010595231
int duration = reader.nextImageDelay();
if (duration <= 10)
duration = 100;
duration = std::max(20, duration);
frames.push_back(Frame<QImage>{image, duration});
}
}