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

@ -31,35 +31,36 @@
"tape": "~3.0.0"
},
"dependencies": {
"multiblob": "^1.5.0",
"multicb": "^1.1.0",
"muxrpc": "^6.1.1",
"pull-ipc": "0.0.1",
"pull-pushable": "^1.1.4",
"pull-stream": "^2.27.0",
"scuttlebot": "~7.3.0",
"ssb-config": "^1.0.3",
"ssb-keys": "^4.0.3",
"stream-to-pull-stream": "^1.6.1",
"blob-to-buffer": "^1.2.3",
"emoji-named-characters": "^1.0.1",
"hyperscript": "~1.4.6",
"mime-types": "^2.1.3",
"multiblob": "^1.5.0",
"multicb": "^1.1.0",
"muxrpc": "^6.1.1",
"nicedate": "~0.0.0",
"observable": "^2.1.3",
"once": "~1.3.1",
"pause-offscreen": "^1.0.0",
"phoenix-router": "~1.0.0",
"published-working-tree": "~0.0.0",
"pull-cat": "^1.1.7",
"pull-ipc": "0.0.1",
"pull-level": "~1.2.0",
"pull-merge": "~1.0.2",
"pull-notify": "0.0.0",
"pull-paramap": "^1.1.3",
"pull-pushable": "^1.1.4",
"pull-stream": "^2.27.0",
"pull-stream-to-stream": "~1.3.0",
"scuttlebot": "~7.3.0",
"ssb-config": "^1.0.3",
"ssb-keys": "^4.0.3",
"ssb-marked": "~0.5.0",
"ssb-msg-schemas": "~5.0.0",
"ssb-msgs": "~5.0.0",
"ssb-ref": "~2.2.0",
"suggest-box": "~1.1.6",
"pull-level": "~1.2.0",
"pull-notify": "0.0.0"
"stream-to-pull-stream": "^1.6.1",
"suggest-box": "~1.1.6"
}
}

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) {

View File

@ -72,7 +72,7 @@ renderer.image = function (href, title, text) {
href = href.replace(/^&/, '&')
if (ssbref.isLink(href)) {
if ((''+text).indexOf('.webm') >= 0) {
var out = '<video autoplay=1 loop=1 muted=1 src="http://localhost:7777/' + href + '?fallback=video" alt="' + text + '"'
var out = '<video loop=1 muted=1 src="http://localhost:7777/' + href + '?fallback=video" alt="' + text + '"'
if (title) {
out += ' title="' + title + '"'
}