From e742860af7467ba8f4f5aac304ad9e8af0b789b7 Mon Sep 17 00:00:00 2001 From: Patrick Geneva Date: Sat, 15 Jan 2022 14:23:08 -0500 Subject: [PATCH] Make animated image playback speed match browser (Firefox and Chrome) behaviour (#3506) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pajlada Co-authored-by: Paweł --- CHANGELOG.md | 1 + src/messages/Image.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 466554212..718318dfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unversioned - Major: Added customizable shortcuts. (#2340) +- Minor: Make animated emote playback speed match browser (Firefox and Chrome) behaviour. (#3506) - Minor: Added middle click split to open in browser (#3356) - Minor: Added new search predicate to filter for messages matching a regex (#3282) - Minor: Add `{channel.name}`, `{channel.id}`, `{stream.game}`, `{stream.title}`, `{my.id}`, `{my.name}` placeholders for commands (#3155) diff --git a/src/messages/Image.cpp b/src/messages/Image.cpp index 1b4f11645..89e382fc3 100644 --- a/src/messages/Image.cpp +++ b/src/messages/Image.cpp @@ -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{image, duration}); } }