Skip to content

Commit

Permalink
Make animated image playback speed match browser (Firefox and Chrome)…
Browse files Browse the repository at this point in the history
… behaviour (#3506)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
Co-authored-by: Paweł <zneix@zneix.eu>
  • Loading branch information
3 people authored Jan 15, 2022
1 parent 499d06f commit e742860
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions src/messages/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
}
Expand Down

0 comments on commit e742860

Please sign in to comment.