deblan.io-murph/assets/js/app/quick-post.js
2021-06-15 14:26:38 +02:00

26 lines
583 B
JavaScript

const QuickPost = function (w) {
this.window = w
}
QuickPost.prototype.init = function () {
const doc = this.window.document
const images = doc.querySelectorAll('.quick-image 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