我试图找到angularjs是否可以像下面这样做:
angular.element(document.querySelector('.content-here').find('div.offsetTop=8');有人能帮我吗? 你可以在这里看到我的傻瓜 。
I tried to find if angularjs can do like below:
angular.element(document.querySelector('.content-here').find('div.offsetTop=8');Can someone help me? You can see my plunker here.
最满意答案
编辑: 如果您不希望逐个指定,可以制定指令。 另外,删除控制器中不必要的代码。 在这里偷窃
.directive('animateFromLeft', function($compile) { return { restrict: 'AE', link: function(scope, elem, attr) { var children = elem.children(); children.addClass('animated fadeInLeft'); var animationDelay = 0; for(var i = 0; i < children.length; i++) { children[i].style.animationDelay = animationDelay.toString() + 's'; animationDelay += 1; } $compile(elem)(scope); } }; });================================================== ======================
我认为你正在以艰难的方式做到这一点。 我假设您不会使用ng-repeat,并且根据您的场景,您可以逐个具体说明动画延迟。
在这里偷窃
<div class="content-here"> <div class="animated fadeInLeft" style="animation-delay: 0s">1</div> <div class="animated fadeInLeft" style="animation-delay: 1s">2</div> <img class="animated fadeInLeft" style="animation-delay: 2s" width="100px" src="https://staticdelivery.nexusmods.com/mods/110/images/74627-0-1459502036.jpg" /> <div class="animated fadeInLeft" style="animation-delay: 3s">3</div> <div class="animated fadeInLeft" style="animation-delay: 4s">4</div> </div>Edited: You could make a directive if you do not wish to specify one by one. Also, remove the unecessary code in the controller. Plunker here
.directive('animateFromLeft', function($compile) { return { restrict: 'AE', link: function(scope, elem, attr) { var children = elem.children(); children.addClass('animated fadeInLeft'); var animationDelay = 0; for(var i = 0; i < children.length; i++) { children[i].style.animationDelay = animationDelay.toString() + 's'; animationDelay += 1; } $compile(elem)(scope); } }; });========================================================================
I think you are doing it in hard way. I assume that you will not be using ng-repeat and based on your scenario you can specific the animation delay one by one.
Plunker here
<div class="content-here"> <div class="animated fadeInLeft" style="animation-delay: 0s">1</div> <div class="animated fadeInLeft" style="animation-delay: 1s">2</div> <img class="animated fadeInLeft" style="animation-delay: 2s" width="100px" src="https://staticdelivery.nexusmods.com/mods/110/images/74627-0-1459502036.jpg" /> <div class="animated fadeInLeft" style="animation-delay: 3s">3</div> <div class="animated fadeInLeft" style="animation-delay: 4s">4</div> </div>更多推荐
发布评论