加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angularjs ng-animate用于滑动效果的css过渡

发布时间:2020-12-17 07:52:24 所属栏目:安全 来源:网络整理
导读:我正在尝试使用Angular的新ng-animate功能实现滑动效果.我从演示站点获取了一些代码并准备了 fiddle. 问题是,当从数组交换项目时,滑动DIV下方的元素会不断上下移动.我尝试使用line-height但没有成功. 是否有可能解决上述问题?或者只有角度和CSS才能实现它?
我正在尝试使用Angular的新ng-animate功能实现滑动效果.我从演示站点获取了一些代码并准备了 fiddle.

问题是,当从数组交换项目时,滑动DIV下方的元素会不断上下移动.我尝试使用line-height但没有成功.

是否有可能解决上述问题?或者只有角度和CSS才能实现它?

您可以将输入和按钮包装在div中,并将其置于绝对位置.

这是一个demo

HTML

<div ng-app="">    
<div ng-controller='anim' >
    <div ng-repeat="item in lst"  ng-animate=" 'wave' ">
    {{item}}
    </div>
    <div class="wrapperInput">
        <input ng-model="cmt"> 
    <button ng-click="clk()"> Slide </button>
        </div>
    </div>  

</div>

CSS

</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ --> 
<script src="http://code.angularjs.org/1.1.4/angular.min.js"></script>
<style>

/**/
.wrapperInput{position:absolute;top:30px;}
/**/

.wave-enter-setup,.wave-leave-setup {
  -webkit-transition:all cubic-bezier(0.250,0.460,0.450,0.940) .5s;
  -moz-transition:all cubic-bezier(0.250,0.940) 0.5s;
  -o-transition:all cubic-bezier(0.250,0.940) 0.5s;
  transition:all cubic-bezier(0.250,0.940) .5s;
    line-height:100%;
}

.wave-enter-setup {
  position:relative;
  left:100%;
 line-height:100%;
}


.wave-enter-start {
  left:0;
line-height:100%;
}

.wave-leave-setup {
  position:absolute;
  left:0;
line-height: 100%;
}

.wave-leave-start {
  left:-100%;
  line-height: 10%;
}

JS

function anim($scope,$timeout){
    $scope.lst = [];
    $scope.master = ['[1] John who is 25 years old.','[2] Jessie who is 30 years old.','[3] Johanna who is 28 years old.','[4] Joy who is 15 years old.','[5] Mary who is 28 years old.','[6] Peter who is 95 years old.','[7] Sebastian who is 50 years old.','[8] Erika who is 27 years old.','[9] Patrick who is 40 years old.','[10] Samantha who is 60 years old.'];

$scope.lst.unshift($scope.master[Math.floor((Math.random()*10)+1)]);

    $scope.clk = function() { clik();}

    function clik() {
    //alert('here');
         $scope.lst.unshift($scope.master[Math.floor((Math.random()*10)+1)]);         
         $scope.lst.pop();  
        $timeout(function(){ clik();},2000);
    }

    clik();

};

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读