5 Scroller在annie2x里,如何运用?

请先 登录 后评论

1 个回答

大北兔
main.scroller = new Scroller(function (left, top, zoom) {
            //scrollPro = left > top ? left : top;
            if (window.innerWidth > window.innerHeight) {
                if (Math.abs(left) > 10) {
                    main.leftNum -= left * 0.4;
                    main.dir = left > 0 ? 1 : -1; //往前1,往后-1
                }
            } else {
                //trace(top);
                if (Math.abs(top) > 10) {
                    main.leftNum -= top * 0.4;
                    main.dir = top > 0 ? 1 : -1; //往前1,往后-1
                }
            }
            //设置滚动场景的范围 0--30800;
            if (main.leftNum > 0) {
                main.leftNum = 0;
            }
            if (main.leftNum < -31400) {
                main.leftNum = -31400;
            }

            //中间有一段停顿(-10760的位置)
            if( main.leftNum>-10700){
                main.root.x = main.leftNum;
            }
            //-10700 ~ -12700 这段时间停止移动main.root.x
            if( main.leftNum<-11700){
                main.root.x = main.leftNum+1000; //停顿2000个移动时间位置,相对为200帧
            }
        })
        main.mousedown = false;
        document.addEventListener("touchstart", function (e) {
            main.scroller.doTouchStart(e.touches, e.timeStamp);
            main.mousedown = true;
        }, false);

        document.addEventListener("touchmove", function (e) {
            if (!main.mousedown) {
                return;
            }
            main.scroller.doTouchMove(e.touches, e.timeStamp);
            main.mousedown = true;
        }, false);

        document.addEventListener("touchend", function (e) {
            if (!main.mousedown) {
                return;
            }
            main.scroller.doTouchEnd(e.timeStamp);
            main.mousedown = false;
        }, false);
    };
请先 登录 后评论
  • 1 关注
  • 0 收藏,116 浏览
  • shimily 提出于 2019-08-13 12:42

相似问题