28 lines
708 B
JavaScript
28 lines
708 B
JavaScript
class QuickPost {
|
|
constructor(w) {
|
|
this.window = w
|
|
}
|
|
|
|
init() {
|
|
const doc = this.window.document
|
|
|
|
const images = doc.querySelectorAll('.quick-image img, .mesh-preview img')
|
|
|
|
for (let i = 0, len = images.length; i < len; i++) {
|
|
(function(image) {
|
|
const source = image.getAttribute('data-src')
|
|
const loader = new Image()
|
|
|
|
loader.onload = function() {
|
|
image.style.backgroundImage = 'url(' + source + ')'
|
|
image.style.backgroundSize = 'cover'
|
|
}
|
|
|
|
loader.src = source
|
|
})(images[i])
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = QuickPost
|