Skip to content

On web pages, hide gifs and pause videos when they're scrolled offscreen, to save CPU cycles

Notifications You must be signed in to change notification settings

pfrazee/pause-offscreen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

pause offscreen

On web pages, hide gifs and pause videos when they're scrolled offscreen, to save CPU cycles.

var pauser = require('pause-offscreen')
var unlistenPauser = pauser(containerEl)
ui.onTeardown(unlistenPauser)

Notes

  • Only bothers checking vertical scroll position
  • Does not check if the page is visible (just checks if the element is in the viewport)
  • Shows/hides on initial call, then on scroll
  • Hides all images when they go out of viewport (visibility=hidden) because my usecase couldnt use the filename's extension to differentiate gifs from other images.

About

On web pages, hide gifs and pause videos when they're scrolled offscreen, to save CPU cycles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published