mirror of
https://github.com/openstf/stf
synced 2025-10-04 18:29:17 +02:00
- Introducing requestAnimationFrame
This commit is contained in:
parent
180bc42f38
commit
defda72fc1
3 changed files with 24 additions and 2 deletions
|
@ -1,6 +1,11 @@
|
||||||
require('angular')
|
require('angular')
|
||||||
require('angular-route')
|
require('angular-route')
|
||||||
|
|
||||||
|
//require('se7en-bootstrap-3/build/stylesheets/bootstrap.min.css')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
angular.module('app', [
|
angular.module('app', [
|
||||||
'ngRoute',
|
'ngRoute',
|
||||||
require('./device-list').name,
|
require('./device-list').name,
|
||||||
|
|
|
@ -391,6 +391,15 @@ function FastImageRender(canvasElement, options) {
|
||||||
this.options = options || {}
|
this.options = options || {}
|
||||||
this.canvasElement = canvasElement
|
this.canvasElement = canvasElement
|
||||||
|
|
||||||
|
if (that.options.raf) {
|
||||||
|
that.animLoop = function() {
|
||||||
|
that.raf = that.animLoop)
|
||||||
|
|
||||||
|
// separate render from drawing
|
||||||
|
// render
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
this.loader = new Image()
|
this.loader = new Image()
|
||||||
this.loader.onload = function () {
|
this.loader.onload = function () {
|
||||||
|
@ -414,6 +423,13 @@ function FastImageRender(canvasElement, options) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FastImageRender.prototype.destroy = function () {
|
||||||
|
|
||||||
|
cancelAnimationFrame(this.raf)
|
||||||
|
|
||||||
|
// delete onLoad & onError
|
||||||
|
}
|
||||||
|
|
||||||
FastImageRender.prototype.load = function (url, type) {
|
FastImageRender.prototype.load = function (url, type) {
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
|
@ -438,6 +454,7 @@ FastImageRender.prototype.load = function (url, type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
this.loader.src = url
|
this.loader.src = url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ var frameNumberElement = document.querySelector('#frame-number')
|
||||||
var totalTimeElement = document.querySelector('#total-time')
|
var totalTimeElement = document.querySelector('#total-time')
|
||||||
|
|
||||||
var frame = {
|
var frame = {
|
||||||
total: 50,
|
total: 100,
|
||||||
current: 0
|
current: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ function loadNext() {
|
||||||
// var height = 300
|
// var height = 300
|
||||||
// loader.src = 'http://placehold.it/' + width + 'x' + height + '?' + Date.now()
|
// loader.src = 'http://placehold.it/' + width + 'x' + height + '?' + Date.now()
|
||||||
// loader.src = 'http://lorempixel.com/' + width + '/' + height + '/abstract/Frame-' + frames.current + '/?' + Date.now()
|
// loader.src = 'http://lorempixel.com/' + width + '/' + height + '/abstract/Frame-' + frames.current + '/?' + Date.now()
|
||||||
imageRender.load('images/screen.webp?' + Date.now())
|
imageRender.load('images/screen.jpg?' + Date.now())
|
||||||
// imageRender.load('images/screen.jpg')
|
// imageRender.load('images/screen.jpg')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue