const anime = require('animejs').default;

const { TIMES } = require('../../constants');

function sourceCast(id, direction, idle) {
    const { x, y } = direction;
    return anime({
        targets: [document.getElementById(id)],
        translateX: x * window.screen.width * 0.1,
        translateY: y * window.screen.height * 0.1,
        easing: 'easeInOutElastic',
        direction: 'alternate',
        duration: TIMES.SOURCE_DURATION_MS,
        begin: idle.pause,
        complete: idle.play,
    });
}

module.exports = sourceCast;
