import anime from 'animejs';

class TrailImage {
    constructor(el) {
        this.DOM = {el: el};
        // image deafult styles
        this.defaultStyle = {
            scale: 1,
            translateX: 0,
            translateY: 0,
            opacity: 0
        };
        // get sizes/position
        this.getRect();
        // init/bind events
        this.initEvents();
    }
    initEvents() {
        // on resize get updated sizes/position
        window.addEventListener('resize', () => this.resize());
    }
    resize() {
        // reset styles
        anime.set(this.DOM.el, this.defaultStyle);
        // get sizes/position
        this.getRect();
    }
    getRect() {
        this.rect = this.DOM.el.getBoundingClientRect();
    }
    isActive() {
        // check if image is animating or if it's visible
        // return TweenMax.isTweening(this.DOM.el) || this.DOM.el.style.opacity != 0;
        return this.DOM.el.style.opacity != 0;
    }
}

export default TrailImage;