MCPcopy Create free account
hub / github.com/codecombat/codecombat / loadRasterImage

Method loadRasterImage

app/models/ThangType.js:118–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116 }
117
118 loadRasterImage () {
119 let raster
120 if (this.loadingRaster || this.loadedRaster) { return }
121 if (!(raster = this.get('raster'))) { return }
122 this.rasterImage = $(`<img crossOrigin='Anonymous' src='/file/${raster}' />`)
123 this.loadingRaster = true
124 this.rasterImage.one('load', () => {
125 this.loadingRaster = false
126 this.loadedRaster = true
127 this.trigger('raster-image-loaded', this)
128 return this.rasterImage.off('error')
129 })
130 return this.rasterImage.one('error', error => {
131 if (error) {
132 console.log('Raster image error', error)
133 }
134 this.loadingRaster = false
135 console.log('Raster image error', this)
136 this.trigger('raster-image-load-errored', this)
137 return this.rasterImage.off('load')
138 })
139 }
140
141 getActions () {
142 if (!this.isFullyLoaded()) { return {} }

Callers 1

Calls 2

logMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected