1.ui-smooth-scroll.js文件内容

angular.module('app')
.directive('uiSmoothScroll', ['$location', '$anchorScroll', function($location, $anchorScroll) {
return {
restrict: 'AC',
scope: {
data:"="
},
template: '<div class="smooth-scroll-container">'+
'<ul class="smooth-scroll">'+
'<li ng-repeat="item in data">'+
'<a href="{{item.url}}" ><img ng-src="{{item.image}}" alt="" class="img-responsive" /></a>'+
'</li>'+
'</ul>'+
'</div>',
link: function(scope, element, attrs) {
setTimeout(function(){
var c = $(element).find('.smooth-scroll-container')[0];
var ul = $(c).find('.smooth-scroll')[0];
var lis = ul.getElementsByTagName('li');
var itemCount = lis.length,
width = lis[0].offsetWidth,
marquee = function() {
c.scrollLeft += 2;
if (c.scrollLeft > width) {
ul.appendChild(ul.getElementsByTagName('li')[0]);
c.scrollLeft = 0;
};
},
speed = 30;
ul.style.width = (width+13) * itemCount + 40 + 'px' ;
var timer = setInterval(marquee, speed);
c.onmouseover = function() {
clearInterval(timer);
};
c.onmouseout = function() {
timer = setInterval(marquee, speed);
};
},100); }
};
}]);

  HTML 使用方法

 <div ui-smooth-scroll data="slides">

  Controller 中对 数据的绑定

 $scope.slides = [{ image: 'img/qy_lunbo_01.png' },{ image: 'img/qy_lunbo_02.png' },{ image: 'img/qy_lunbo_03.png' },{ image: 'img/qy_lunbo_04.png' }];

  

搞定!

最新文章

  1. TFS二次开发系列:七、TFS二次开发的数据统计以PBI、Bug、Sprint等为例(一)
  2. 【HDU1257】最少拦截系统(贪心)
  3. 检查点(Checkpoint)过程如何处理未提交的事务
  4. OSIC Performance Bot
  5. Apache MINA 框架之Handler介绍
  6. python time模块函数
  7. Hibernate 多对多映射
  8. HDU 4125 Moles 段树+KMP
  9. Linux c 内存高速访问
  10. zabbix使用mysql数据库 对表分区
  11. CouchBase数据库-一个较新的、发展迅速的nosql数据库技术
  12. 《JavaScript高级程序设计》笔记:基本概念(三)
  13. 5-24 css内容的补充
  14. Oracle(二)在 Mysql 的基础上学习 Oracle
  15. NutzWk 开发框架
  16. partition
  17. 软件工程-XP方法十二个最佳实践
  18. FutureTask 源码解析
  19. 【LOJ】#2292. 「THUSC 2016」成绩单
  20. [转]【Delphi】 Thread.Queue与Synchronize的区别

热门文章

  1. Java反射在Android中的使用
  2. python通过swig调用静态库
  3. 某gov的逻辑漏洞
  4. hdu 4531 bfs(略难)
  5. Problem H: 深入浅出学算法009-韩信点兵
  6. Elasticsearch快速入门案例
  7. [转]Android使用Application总结
  8. RTSP交互过程
  9. Content portal for Pocketables Tasker articles
  10. TPS70345 (ACTIVE) 双路输出低压降 (LDO) 稳压器