blob: 5a6162107c4e30a9ed352083d2d54f8c8d3750f1 [file] [log] [blame]
import Vue from 'vue';
// function doLazyLoad(el) {
// el.querySelectorAll('iframe').forEach($iframe => {
// let dataSrc = $iframe.getAttribute('data-src');
// if (dataSrc && !$iframe.getAttribute('src')) {
// $iframe.setAttribute('src', dataSrc);
// }
// });
// }
import LazyLoad from 'vanilla-lazyload';
Vue.directive('lazyload', {
inserted(el) {
el._lazyload = new LazyLoad({
container: el,
elements_selector: 'iframe',
load_delay: 300
});
// doLazyLoad(el);
},
update(el) {
el._lazyload.update();
// doLazyLoad(el);
},
unbind(el) {
el._lazyload.destroy();
}
});