Loading spinner for videos

Only worked for audio before
This commit is contained in:
DC
2016-03-29 00:26:16 -07:00
parent c8da083526
commit cc273e7312
4 changed files with 64 additions and 37 deletions

View File

@@ -4,6 +4,7 @@ function LocationHistory () {
if (!new.target) return new LocationHistory()
this._history = []
this._forward = []
this._pending = null
}
LocationHistory.prototype.go = function (page) {
@@ -13,9 +14,12 @@ LocationHistory.prototype.go = function (page) {
}
LocationHistory.prototype._go = function (page) {
if (this._pending) return
if (page.onbeforeload) {
this._pending = page
page.onbeforeload((err) => {
if (err) return
this._pending = null
this._history.push(page)
})
} else {
@@ -59,3 +63,7 @@ LocationHistory.prototype.hasBack = function () {
LocationHistory.prototype.hasForward = function () {
return this._forward.length > 0
}
LocationHistory.prototype.pending = function () {
return this._pending
}