mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-21 13:25:17 +02:00
Added Timeout error message when the screen takes more than 1 second to load.
This commit is contained in:
@@ -412,6 +412,7 @@ function FastImageRender(canvasElement, options) {
|
||||
var that = this
|
||||
this.options = options || {}
|
||||
this.canvasElement = canvasElement
|
||||
this.timeoutId = null
|
||||
|
||||
if (that.options.raf) {
|
||||
that.animLoop = function() {
|
||||
@@ -425,11 +426,17 @@ function FastImageRender(canvasElement, options) {
|
||||
if (true) {
|
||||
this.loader = new Image()
|
||||
this.loader.onload = function () {
|
||||
if (that.options.timeout) {
|
||||
clearTimeout(that.timeoutId)
|
||||
}
|
||||
if (typeof(that.onLoad) === 'function') {
|
||||
that.onLoad(this)
|
||||
}
|
||||
}
|
||||
this.loader.onerror = function () {
|
||||
if (that.options.timeout) {
|
||||
clearTimeout(that.timeoutId)
|
||||
}
|
||||
if (typeof(that.onError) === 'function') {
|
||||
that.onError(this)
|
||||
}
|
||||
@@ -455,6 +462,14 @@ FastImageRender.prototype.destroy = function () {
|
||||
FastImageRender.prototype.load = function (url, type) {
|
||||
var that = this
|
||||
|
||||
if (that.options.timeout) {
|
||||
that.timeoutId = setTimeout(function () {
|
||||
if (typeof(that.onError) === 'function') {
|
||||
that.onError('timeout')
|
||||
}
|
||||
}, that.options.timeout)
|
||||
}
|
||||
|
||||
if (this.options.textureLoader) {
|
||||
if (!this.textureLoader) {
|
||||
this.textureLoader = new TextureUtil.TextureLoader(this.render.ctx)
|
||||
|
||||
Reference in New Issue
Block a user