Immediately draw and clear pause icon...

as you move the mouse over or away from a gif
This commit is contained in:
JC Brand 2021-07-29 21:19:48 +02:00
parent ebfda5c86e
commit ac36407d1d

View File

@ -1,11 +1,10 @@
/** /**
* @copyright Shachaf Ben-Kiki and the Converse.js contributors * @copyright Shachaf Ben-Kiki, JC Brand
* @description * @description
* Started as a fork of Shachaf Ben-Kiki's jsgif library * Started as a fork of Shachaf Ben-Kiki's jsgif library
* https://github.com/shachaf/jsgif * https://github.com/shachaf/jsgif
* @license MIT License * @license MIT License
*/ */
import Stream from './stream.js'; import Stream from './stream.js';
import { getOpenPromise } from '@converse/openpromise'; import { getOpenPromise } from '@converse/openpromise';
import { parseGIF } from './utils.js'; import { parseGIF } from './utils.js';
@ -146,6 +145,7 @@ export default class ConverseGif {
return; return;
} }
if ((timestamp - previous_timestamp) < frame_delay) { if ((timestamp - previous_timestamp) < frame_delay) {
this.hovering ? this.drawPauseIcon() : this.putFrame(this.frame_idx);
// We need to wait longer // We need to wait longer
requestAnimationFrame(ts => this.onAnimationFrame(ts, previous_timestamp, frame_delay)); requestAnimationFrame(ts => this.onAnimationFrame(ts, previous_timestamp, frame_delay));
return; return;
@ -404,8 +404,8 @@ export default class ConverseGif {
this.ctx.globalCompositeOperation = 'copy'; this.ctx.globalCompositeOperation = 'copy';
this.ctx.drawImage(this.offscreenCanvas, 0, 0); this.ctx.drawImage(this.offscreenCanvas, 0, 0);
if (show_pause_on_hover) { if (show_pause_on_hover && this.hovering) {
this.hovering && this.drawPauseIcon(); this.drawPauseIcon();
} }
} }