how do I access the this
keyword in ES6 Modules/Classes? For example in the below, $(this)
points to WaypointController
whereas with the old style code it would have referred to the selected element.
I tried using arguments but it doesn't help.
export default class WaypointContoller {
constructor() {
this.WAYPOINT_CLASS = 'main .webzone-wrapper:not(.no-csstransitions) > div';
this.ANIMATION_CLASS = isIE9() ? 'fadeInUpNoAnimation' : 'fadeInUp';
this.OFFSET = '90%';
this.doAnimations(this.WAYPOINT_CLASS, this.ANIMATION_CLASS);
}
doAnimations(waypointClass, animationClass) {
let delayTime;
const waypoint = new Waypoint({ // eslint-disable-line no-undef
element: document.querySelector(waypointClass),
handler: () => {
delayTime += 100;
$(this).delay(delayTime).queue((next) => {
$(this).toggleClass('animated');
$(this).toggleClass(animationClass);
delayTime = 0;
next();
});
},
offset: this.OFFSET,
triggerOnce: true,
});
console.log(waypoint);
}
static init() {
$(document).ready(() => {
new WaypointContoller(); // eslint-disable-line no-new
});
}
}