Beispiel #1
0
/*

Events:

* ready: hero sprite is loaded

*/
function Hero(canvas){
  var hero = this

  hero.img = document.createElement('img')
  hero.img.src = '/images/hero.png'

  hero.speed = 256/1000 // pixels per second?

  hero.width = 32
  hero.height = 32

  // start in the middle
  hero.x = canvas.width/2 - hero.width/2
  hero.y = canvas.height/2 - hero.width/2

  hero.keys = {}

  EE.call(hero)

  loaded(hero.img, function(err){
    hero.emit('ready')
  })

  hero.attach(canvas)
}
Beispiel #2
0
      input.forEach(function (image) {
        // must reset image src to avoid imageLoaded callback firing
        // prematurly when there's a previous image set and loaded
        image.src = null

        // imageLoaded must be initialized first, to assure
        // that we're always running this asynchronous, even if we have a cached image
        imageLoaded(image, done)
        image.src = src
      })
Beispiel #3
0
require('domready')(function () {
  var img = document.querySelector('img')

  if (img) {
    imageLoaded(img, function () {
      forEach(document.querySelectorAll('.fadein'), function (elm) {
        elm.classList.add('run')
      })
    })
  } else {
    forEach(document.querySelectorAll('.fadein'), function (elm) {
      elm.classList.add('run')
    })
  }
})
Beispiel #4
0
 $parent.find('img').each(function () {
     imgLoaded(this, function () {
         $scrollWrap.css('height', $parent.height());
     });
 });