MCPcopy
hub / github.com/philc/vimium / fade

Method fade

content_scripts/hud.js:240–262  ·  view source on GitHub ↗
(toAlpha, duration, onComplete)

Source from the content-addressed store, hash-verified

238 }
239
240 fade(toAlpha, duration, onComplete) {
241 clearInterval(this.intervalId);
242 const startTime = (new Date()).getTime();
243 const fromAlpha = this.opacity;
244 const alphaStep = toAlpha - fromAlpha;
245
246 const performStep = () => {
247 const elapsed = (new Date()).getTime() - startTime;
248 if (elapsed >= duration) {
249 clearInterval(this.intervalId);
250 this.updateStyle(toAlpha);
251 if (onComplete) {
252 onComplete();
253 }
254 } else {
255 const value = ((elapsed / duration) * alphaStep) + fromAlpha;
256 this.updateStyle(value);
257 }
258 };
259
260 this.updateStyle(this.opacity);
261 this.intervalId = setInterval(performStep, 50);
262 }
263
264 stop() {
265 clearInterval(this.intervalId);

Callers 4

showFunction · 0.80
showFindModeFunction · 0.80
hideFunction · 0.80
pasteFromClipboardFunction · 0.80

Calls 1

updateStyleMethod · 0.95

Tested by

no test coverage detected