当前位置:网站首页>JS parabola motion packaging method

JS parabola motion packaging method

2022-04-23 14:17:00 Ruirui junior

// Method of parabola animation
function jump(dom, dx, dy, time) {
    //elx The position of the current element ,dx dy yes x ,y The offset
    // let elX = $(dom).css("left").split('px')[0]*1;
    // let elY = $(dom).css("top").split('px')[0]*1;
    // parseInt($(".drawItem").eq(orginindex).position().left)
    let elX = $(dom).attr("data-x") * 1;
    let elY = $(dom).attr("data-y") * 1
    
    let a = 0.003
    let b = (dy - a * dx * dx) / dx
    let timer = null;
    // Start time of execution
    var beginTime = new Date()
    // End time
    endTime = +beginTime + time

    // Timer , Perform parabolic animation
    timer = setInterval(() => {
        let now = new Date()
        let x, y;
        if (now > endTime) {
            // End of run
            x = dx;
            y =

版权声明
本文为[Ruirui junior]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231408339147.html