export function scrollFun(ele,prop,target) {
    //console.log('进入',ele,prop,target)
    clearInterval(ele.timer);
    let  suspenTime = 0;
    ele.timer = setInterval(() => {
        let step = 1
        suspenTime = suspenTime + 50;
        // console.log(ele.offsetTop,target)
        if(ele.offsetTop === target) {
          //  console.log('停了')
            ele.style[prop] = 0;
            suspenTime = 0;
        }
        //console.log(step)
        if(suspenTime >5000){
            step = 1
        }else{
            step = 0
        }
        ele.style.top = +ele.offsetTop -   step + 'px'


    },50)
}
export function rescrollFun(ele,prop) {
    //console.log('进入',ele,prop)
    clearInterval(ele.timer)
    ele.style[prop] = 0
}
export function stopScroll(timer){
    clearInterval(timer)
}

export function continueScroll(ele,prop,target) {
    //console.log('进入',ele,prop,target)
    clearInterval(ele.timer);
    let  suspenTime = 0;
    ele.timer = setInterval(() => {
        let step = 1
        suspenTime = suspenTime + 50;
        // console.log(ele.offsetTop,target)
        if(ele.offsetTop === target) {
            //  console.log('停了')
            ele.style[prop] = 0;
            suspenTime = 0;
        }
        //console.log(step)
        // if(suspenTime >5000){
        //     step = 1
        // }else{
        //     step = 0
        // }
        ele.style.top = +ele.offsetTop -   step + 'px'


    },50)
}




export function scrollWidthFun(ele,prop,target) {
    //console.log('进入',ele,prop,target)
    clearInterval(ele.timer);
    let  suspenTime = 0;
    ele.timer = setInterval(() => {
        let step = 1
        suspenTime = suspenTime + 50;
        // console.log(ele.offsetTop,target)
        if(ele.offsetLeft=== target) {
            //  console.log('停了')
            ele.style[prop] = 0;
            suspenTime = 0;
        }
        //console.log(step)
        if(suspenTime >5000){
            step = 1
        }else{
            step = 0
        }
        ele.style.left = +ele.offsetLeft -   step + 'px'


    },50)
}

export function continueScrollWidth(ele,prop,target) {
    //console.log('进入',ele,prop,target)
    clearInterval(ele.timer);
    let  suspenTime = 0;
    ele.timer = setInterval(() => {
        let step = 1
        suspenTime = suspenTime + 50;
        // console.log(ele.offsetTop,target)
        if(ele.offsetLeft === target) {
            //  console.log('停了')
            ele.style[prop] = 0;
            suspenTime = 0;
        }
        //console.log(step)
        // if(suspenTime >5000){
        //     step = 1
        // }else{
        //     step = 0
        // }
        ele.style.left = +ele.offsetLeft -   step + 'px'


    },50)
}
