一陀牛屎 2016-01-02 11:15 采纳率: 0%
浏览 1841

js加css3实现动画问题。。

第一个::::
function slideList(){
var downY = 0;
var step = 1/4;
var nowIndex = 0;
var nextorprevIndex = 0;
$li.on('touchstart',function(ev){
var touch = ev.originalEvent.changedTouches[0];
downY = touch.pageY;
nowIndex = $(this).index();

        $li.on('touchmove',function(ev){
            var touch = ev.originalEvent.changedTouches[0];

            $(this).siblings().hide();

            if( touch.pageY < downY ){  //↑
                nextorprevIndex = nowIndex == $li.length-1 ? 0 : nowIndex + 1;
                $li.eq(nextorprevIndex).css('transform','translate(0,'+(viewHeight + touch.pageY - downY)+'px)');
            }
            else if( touch.pageY > downY ){  
                nextorprevIndex = nowIndex == 0 ? $li.length-1 : nowIndex - 1;
                $li.eq(nextorprevIndex).css('transform','translate(0,'+(-viewHeight + touch.pageY - downY)+'px)');
            }

            $li.eq(nextorprevIndex).show().addClass('zIndex');
            $(this).css('transform','translate(0,'+(touch.pageY - downY)*step+'px) scale('+(1-Math.abs(touch.pageY - downY)/viewHeight*step)+')');

        });

        $li.on('touchend',function(ev){
            var touch = ev.originalEvent.changedTouches[0];
            if( touch.pageY < downY ){  
                $(this).css('transform','translate(0,'+(-viewHeight * step)+'px) scale('+(1-step)+')');
            }
            else if( touch.pageY > downY ){  
                $(this).css('transform','translate(0,'+(viewHeight * step)+'px) scale('+(1-step)+')');
            }
            $(this).css('transition','.3s');
            $li.eq(nextorprevIndex).css('transform','translate(0,0)');
            $li.eq(nextorprevIndex).css('transition','.3s');
        });

    });

    $li.on('transitionEnd webkitTransitionEnd',function(ev){
        resetFn();

    });

    function resetFn(){
        $li.css('transition','');
        $li.eq(nextorprevIndex).removeClass('zIndex').siblings().hide();
    }

}
第二个;;::
function slideList(){
    var downY=0;
    var step=1/4;
    var nowIndex=0;
    var nextIndex=0;

    $li.on('touchstart',function(ev){
        var touch = ev.originalEvent.changedTouches[0];
        nowIndex=$(this).index();
        downY=touch.pageY;
        $li.on('touchmove',function(ev){
            var touch = ev.originalEvent.changedTouches[0];
                $(this).siblings().hide();
                if(downY>touch.pageY){
                    nextIndex= nowIndex == $li.length-1 ? 0 : nowIndex+1;
                    $li.eq(nextIndex).css('transform','translate(0,'+(viewHeight + touch.pageY - downY)+'px');
                }else if(downY<touch.pageY){
                    nextIndex=nowIndex==0 ? $li.length-1 : nowIndex-1;
                    $li.eq(nextIndex).css('transform','translate(0,'+(-viewHeight+touch.pageY-downY)+'px');
                }
                $li.eq(nextIndex).show().addClass("zIndex");
                $(this).css('transform','translate(0,'+(touch.pageY-downY)*step+'px) scale('+(1-Math.abs(touch.pageY-downY)/viewHeight*step)+')');
        })

        $li.on('touchend',function(ev){
            var touch = ev.originalEvent.changedTouches[0];
                if(downY>touch.pageY){
                    $(this).css('transform','translate(0,'+(-viewHeight*step)+'px) scale('+(1-step)+')');
                }else if(downY<touch.pageY){
                    $(this).css('transform','translate(0,'+(viewHeight*step)+'px) scale('+(1-step)+')');
                }
                $(this).css('transition','0.3s');
                $li.eq(nextIndex).css('transform','translate(0,0)');
                $li.eq(nextIndex).css('transition','0.3s');
        })
    })
    $li.on('transitionEnd webkitTransitionEnd',function(ev){
            reswtFn();
        })
    function reswtFn(){
        $li.css('transition','');
        $li.eq(nextIndex).removeClass('zIndex').siblings().hide();
    }

}
效果为什么第二个不行????????第一个可以???????、
  • 写回答

1条回答 默认 最新

  • 一陀牛屎 2016-01-02 11:16
    关注

    大神在那里啊?????????
    求救啊

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘