Files
OfficialSite/assets/scripts/modules/Scroll.js
Quentin Hocdé 11b9fa7a7d Update assets/scripts/modules/Scroll.js
Co-authored-by: Chauncey McAskill <chauncey@locomotive.ca>
2021-03-05 09:23:45 -05:00

41 lines
971 B
JavaScript

import { module } from 'modujs';
import LocomotiveScroll from 'locomotive-scroll';
export default class extends module {
constructor(m) {
super(m);
}
init() {
this.scroll = new LocomotiveScroll({
el: this.el,
smooth: true
});
this.scroll.on('call', (func, way, obj, id) => {
// Using modularJS
this.call(func[0], { way, obj }, func[1], func[2]);
});
this.scroll.on('scroll', (args) => {
// console.log(args.scroll);
})
}
toggleLazy(args) {
let src = this.getData('lazy', args.obj.el)
if (src.length) {
if (args.obj.el.tagName === 'IMG') {
args.obj.el.src = src
} else {
args.obj.el.style.backgroundImage = `url('${src}')`
}
this.setData('lazy', '', args.obj.el)
}
}
destroy() {
this.scroll.destroy();
}
}