【发布时间】:2015-11-19 19:05:34
【问题描述】:
我一直在努力让我的角度 flexslider 按我想要的方式工作。现在它正在动态填充,但图像需要一秒钟才能加载。它看起来不太好。我希望它在一切都满载时淡入。我怎样才能做到这一点?我无法获得ngAnimate 或回调工作。我也尝试过一个指令。我什至尝试过$timeout 并在控制器中的函数末尾将变量设置为 true 和 false。没有任何效果。
到目前为止,这是我的代码:
HTML:
<flex-slider hide-till-load ng-show="showImages" class="animate-if" slider-id="slider" flex-slide="image in imagePaths track by $index" animation="fade" animation-loop="false" sync="#carousel" slideshow="false" control-nav="false" prev-text="" next-text="" init-delay="100" start="loaded()">
<li>
<img ng-src="{{image.custom}}" alt="Luxury Resort Rental Image"/>
</li>
</flex-slider>
注意:hide-till-load 是我尝试使用 $timeout 和 scope.$last 的指令。都没有奏效。 showImages 是我在某些函数结束时在控制器中设置的变量。但是,它不会等到图像完全加载,所以它不能按我想要的方式工作。
Javascript:
//works but does not wait until images are fully loaded. Not what I want
$scope.loaded= function(){
console.log("this is after");
$timeout(function() {
$scope.showImages= true;
$scope.iconHide= true;
});
}
//doesn't work at all
resortModule.directive('hideTillLoad', function (){
return{
scope:false, //don't need a new scope
restrict: 'A', //Attribute type
link: function (scope, elements, arguments){
console.log(scope.$last);
if (scope.$last) {
console.log('page Is Ready!');
}
}
}
})
【问题讨论】:
标签: javascript angularjs flexslider