{"size": 2788, "ext": "js", "max_stars_repo_path": "plugins/easemove.js", "max_stars_repo_name": "hktr92/phaser3-rex-notes", "max_stars_repo_stars_event_min_datetime": "2021-01-12T19:01:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-18T20:50:27.000Z", "max_issues_repo_path": "plugins/easemove.js", "max_issues_repo_name": "simandebvu/phaser3-rex-notes", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "plugins/easemove.js", "max_forks_repo_name": "simandebvu/phaser3-rex-notes", "max_forks_repo_forks_event_min_datetime": "2021-01-15T11:07:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-15T11:07:15.000Z"}
{"max_stars_count": 6, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 29.9784946237, "max_line_length": 97, "alphanum_fraction": 0.618723099}
import EaseMove from './behaviors/easemove/EaseMove.js';

var EaseMoveTo = function (gameObject, duration, endX, endY, ease, destroyMode, easeMove) {
    if (destroyMode instanceof EaseMove) {
        easeMove = destroyMode;
        destroyMode = undefined;
    }

    if (destroyMode === undefined) {
        destroyMode = false;
    }

    var config = {};
    config.mode = (destroyMode) ? 1 : 0;
    if (endX !== undefined) {
        config.startX = gameObject.x;
        config.endX = ParseValue(endX, gameObject.x);
    }
    if (endY !== undefined) {
        config.startY = gameObject.y;
        config.endY = ParseValue(endY, gameObject.y);
    }
    config.duration = duration;
    config.ease = (ease === undefined) ? 'Linear' : ease;

    if (easeMove === undefined) {
        easeMove = new EaseMove(gameObject, config);
    } else {
        easeMove.resetFromJSON(config);
    }
    easeMove.restart();

    return easeMove;
};

var EaseMoveToDestroy = function (gameObject, duration, startX, startY, ease, easeMove) {
    return EaseMoveTo(gameObject, duration, startX, startY, ease, true, easeMove);
}

var EaseMoveFrom = function (gameObject, duration, startX, startY, ease, destroyMode, easeMove) {
    if (destroyMode instanceof EaseMove) {
        easeMove = destroyMode;
        destroyMode = undefined;
    }

    if (destroyMode === undefined) {
        destroyMode = false;
    }

    var config = {};
    config.mode = (destroyMode) ? 1 : 0;
    if (startX !== undefined) {
        config.startX = ParseValue(startX, gameObject.x);
        config.endX = gameObject.x;
    }
    if (startY !== undefined) {
        config.startY = ParseValue(startY, gameObject.y);
        config.endY = gameObject.y;
    }
    config.duration = duration;
    config.ease = (ease === undefined) ? 'Linear' : ease;

    if (easeMove === undefined) {
        easeMove = new EaseMove(gameObject, config);
    } else {
        easeMove.resetFromJSON(config);
    }
    easeMove.restart();

    return easeMove;
}

var EaseMoveFromDestroy = function (gameObject, duration, startX, startY, ease, easeMove) {
    return EaseMoveFrom(gameObject, duration, startX, startY, ease, true, easeMove);
}

var ParseValue = function (propertyValue, startValue) {
    // propertyValue : number or string
    if (typeof (propertyValue) === 'number') {
        return propertyValue;
    } else {
        var op = propertyValue[0];
        var num = parseFloat(propertyValue.substr(2));
        switch (op) {
            case '+': return startValue + num;
            case '-': return startValue - num;
            case '*': return startValue * num;
            case '/': return startValue / num;
        }
    }
}

export { EaseMove, EaseMoveTo, EaseMoveToDestroy, EaseMoveFrom, EaseMoveFromDestroy };