Skip to content

Commit 03b65cb

Browse files
vyaghWalter Bender
andauthored
fix: Clear animated GIFs when clear button is clicked (fixes #4907) (#4910)
* fix: Clear animated GIFs when clear button is clicked (fixes #4907) - Add gifAnimator.stopAll() call in _allClear() to stop all GIF animations - Clear overlay canvas to remove GIF pixels - Fix doClearMedia() early return checking wrong property (this._media → this.turtle.media) * prettier --------- Co-authored-by: Walter Bender <walter@sorceo.com>
1 parent 4274148 commit 03b65cb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

js/activity.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,16 @@ class Activity {
15131513
this.blocks.activeBlock = null;
15141514
hideDOMLabel();
15151515

1516+
// Stop all GIF animations and clear overlay canvas (Issue #4907)
1517+
if (this.gifAnimator) {
1518+
this.gifAnimator.stopAll();
1519+
const overlayCanvas = document.getElementById("overlayCanvas");
1520+
if (overlayCanvas) {
1521+
const ctx = overlayCanvas.getContext("2d");
1522+
ctx.clearRect(0, 0, overlayCanvas.width, overlayCanvas.height);
1523+
}
1524+
}
1525+
15161526
this.logo.boxes = {};
15171527
this.logo.time = 0;
15181528
this.hideMsgs();

js/turtle-painter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ class Painter {
11661166
* Clears the media layer
11671167
*/
11681168
doClearMedia() {
1169-
if (!this._media) {
1169+
if (!this.turtle.media || this.turtle.media.length === 0) {
11701170
return;
11711171
}
11721172
const gifAnimator = this.activity.gifAnimator;

0 commit comments

Comments
 (0)