//var ShowLog = 1;
function O(target, opacityKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'opacity',
            'from': opacityKeyFrame[0],
            'to': opacityKeyFrame[1]
        }],
        'duration': duration,
        'delay': delay,
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}

function X(target, leftKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'left',
            'from': leftKeyFrame[0],
            'to': leftKeyFrame[1]
        }],
        'duration': duration,
        'delay': delay,
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}

function Y(target, topKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'top',
            'from': topKeyFrame[0],
            'to': topKeyFrame[1]
        }],
        'duration': duration,
        'delay': delay,
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}
function XO(target, leftKeyFrame, opacityKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'left',
            'from': leftKeyFrame[0],
            'to': leftKeyFrame[1]
        }, {
            'property': 'opacity',
            'from': opacityKeyFrame[0],
            'to': opacityKeyFrame[1]
        }],
        'duration': duration,
        'delay': delay,
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}

function YO(target, topKeyFrame, opacityKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'top',
            'from': topKeyFrame[0],
            'to': topKeyFrame[1]
        }, {
            'property': 'opacity',
            'from': opacityKeyFrame[0],
            'to': opacityKeyFrame[1]
        }],
        'duration': duration,
        'delay': delay,
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}
function XY(target, leftKeyFrame, topKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'left',
            'from': leftKeyFrame[0],
            'to': leftKeyFrame[1]
        }, {
            'property': 'top',
            'from': topKeyFrame[0],
            'to': topKeyFrame[1]
        }],
        'duration': duration,
        'delay': delay,
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}
function XYO(target, leftKeyFrame, topKeyFrame, opacityKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'left',
            'from': leftKeyFrame[0],
            'to': leftKeyFrame[1]
        }, {
            'property': 'top',
            'from': topKeyFrame[0],
            'to': topKeyFrame[1]
        }, {
            'property': 'opacity',
            'from': opacityKeyFrame[0],
            'to': opacityKeyFrame[1]
        }],
        'duration': duration,
        'delay': delay,
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}
function XYOZ(target, leftKeyFrame, topKeyFrame, opacityKeyFrame, zoomKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'left',
            'from': leftKeyFrame[0],
            'to': leftKeyFrame[1]
        }, {
            'property': 'top',
            'from': topKeyFrame[0],
            'to': topKeyFrame[1]
        }, {
            'property': 'opacity',
            'from': opacityKeyFrame[0],
            'to': opacityKeyFrame[1]
        }, {
            'property': 'zoom',
            'from': zoomKeyFrame[0],
            'to': zoomKeyFrame[1]
        }],
        'duration': duration,
        'delay': delay,
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}
function OZ(target, opacityKeyFrame, zoomKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'opacity',
            'from': opacityKeyFrame[0],
            'to': opacityKeyFrame[1]
        }, {
            'property': 'zoom',
            'from': zoomKeyFrame[0],
            'to': zoomKeyFrame[1]
        }],
        'duration': duration,
        'delay': delay,
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    })
}
/******************************/

function freeuse_1(target, KeyFrame, timeKeyFrame, timing_function, count, direction, callback, area) {
    /*//console.log(ShowLog);
    if (ShowLog)
    {
        //console.log(target + " will use " + KeyFrame[0] + " from " + KeyFrame[1] + " to " + KeyFrame[2] + ",keep " + timeKeyFrame[0] + "ms and delay " + timeKeyFrame[1] + "ms,by " +
            timing_function + " loop " + count + " times on " + direction + " direction,handle the " + callback + ".");
    }*/
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': KeyFrame[0],
            'from': KeyFrame[1],
            'to': KeyFrame[2]
        }],
        'duration': timeKeyFrame[0],
        'delay': timeKeyFrame[1],
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}
function freeuse_2(target, KeyFrame1, KeyFrame2, timeKeyFrame, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': KeyFrame1[0],
            'from': KeyFrame1[1],
            'to': KeyFrame1[2]
        }, {
            'property': KeyFrame2[0],
            'from': KeyFrame2[1],
            'to': KeyFrame2[2]
        }],
        'duration': timeKeyFrame[0],
        'delay': timeKeyFrame[1],
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}

function freeuse_3(target, KeyFrame1, KeyFrame2, KeyFrame3, timeKeyFrame, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': KeyFrame1[0],
            'from': KeyFrame1[1],
            'to': KeyFrame1[2]
        }, {
            'property': KeyFrame2[0],
            'from': KeyFrame2[1],
            'to': KeyFrame2[2]
        }, {
            'property': KeyFrame3[0],
            'from': KeyFrame3[1],
            'to': KeyFrame3[2]
        }],
        'duration': timeKeyFrame[0],
        'delay': timeKeyFrame[1],
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}
function freeuse_4(target, KeyFrame1, KeyFrame2, KeyFrame3, KeyFrame4, timeKeyFrame, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': KeyFrame1[0],
            'from': KeyFrame1[1],
            'to': KeyFrame1[2]
        }, {
            'property': KeyFrame2[0],
            'from': KeyFrame2[1],
            'to': KeyFrame2[2]
        }, {
            'property': KeyFrame3[0],
            'from': KeyFrame3[1],
            'to': KeyFrame3[2]
        }, {
            'property': KeyFrame4[0],
            'from': KeyFrame4[1],
            'to': KeyFrame4[2]
        }],
        'duration': timeKeyFrame[0],
        'delay': timeKeyFrame[1],
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}
/***************** breath *****************/
function breath(target, freq, area) {
    var breathTime = 60000 / freq;
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'opacity',
            'from': 158,
            'to': 255
        }],
        'duration': breathTime,
        'delay': 0,
        'timing-function': "linear",
        'iteration-count': "infinite",
        'direction': "alternate"
    });
}
function deepBreath(target, freq, area) {
    var breathTime = 60000 / freq;
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'opacity',
            'from': 97,
            'to': 255
        }],
        'duration': breathTime,
        'delay': 0,
        'timing-function': "linear",
        'iteration-count': "infinite",
        'direction': "alternate"
    });
}
function fullBreath(target, freq, area) {
    var breathTime = 60000 / freq;
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'opacity',
            'from': 0,
            'to': 255
        }],
        'duration': breathTime,
        'delay': 0,
        'timing-function': "linear",
        'iteration-count': "infinite",
        'direction': "alternate"
    });
}
function textMove(target, topKeyFrame, opacityKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
    area.$anime({
        'target': target,
        'keyframes': [{
            'property': 'top',
            'from': topKeyFrame[0],
            'to': topKeyFrame[1]
        }, {
            'property': 'left',
            'from': opacityKeyFrame[0],
            'to': opacityKeyFrame[1]
        }],
        'duration': duration,
        'delay': delay,
        'timing-function': timing_function,
        'iteration-count': count,
        'direction': direction,
        'end-callback': callback
    });
}
module.exports = {
    O: O,
    X: X,
    Y: Y,
    OZ: OZ,
    XO: XO,
    YO: YO,
    XY: XY,
    XYO: XYO,
    XYOZ: XYOZ,
    freeuse_1: freeuse_1,
    freeuse_2: freeuse_2,
    freeuse_3: freeuse_3,
    freeuse_4: freeuse_4,
    breath: breath,
    deepBreath: deepBreath,
    fullBeath: fullBreath,
    textMove: textMove,
}