fix: gifs and videos on the message feed now pause when offscreen, conserving cpu usage

This commit is contained in:
Paul Frazee
2015-09-30 12:39:39 -05:00
parent dfddc05330
commit f929c75311
3 changed files with 21 additions and 14 deletions

View File

@@ -3,10 +3,12 @@ var h = require('hyperscript')
var mlib = require('ssb-msgs')
var pull = require('pull-stream')
var multicb = require('multicb')
var pauser = require('pause-offscreen')
var app = require('../app')
var com = require('../com')
var u = require('../util')
module.exports = function (opts) {
opts = opts || {}
var botcursor
@@ -36,6 +38,10 @@ module.exports = function (opts) {
fetchBottom(function (n) {
if (opts.onempty && n === 0)
opts.onempty(feedEl)
// add offscreen pausing
var unlistenPauser = pauser(containerEl)
ui.onTeardown(unlistenPauser)
})
function fetchBottom (cb) {