最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
使用ionic在首页新闻中应用到的跑马灯效果的实现方法
时间:2017-04-01 编辑:简简单单 来源:一聚教程网
在app中经常会有滚动的跑马灯效果的运用,如图所示为跑马灯效果:
代码如下:
html:
代码如下 | 复制代码 |
|
css:
代码如下 | 复制代码 |
.slideTopbox { width: 100%; z-index: 99; position: absolute; top: 0; color:#000; } .shouRight { width: 100%; z-index: 9999; position: absolute; top: 0; height: 30px; color:#000; overflow: hidden; line-height: 30px; } |
js:
代码如下 | 复制代码 |
angular.module('starter.services', []) .directive('slideScroll',function($window, $timeout) { return{ restrict:'AE', link:function(scope, element, attr) { varitsWatch = scope.$watch("its",function(newvalue, oldvalue) { itsWatch(); vari = 1;//element是ul varlength = element[0].children.length; varwidthwindow = $window.innerWidth - 20; varfirstwidth = element[0].children[0].children[0].offsetWidth; setInterval(function() { if(i == length) { i = 0;//初始位置 element[0].style.top ="0px"; } vartopscorll = -(i * 30); varwidthself = element[0].children[i].children[0].offsetWidth;//widthself:292 feeltoTop(topscorll) i++; }, 3000) //向上滚动 functionfeeltoTop(topscorll){//console.log(topscorll):topscorll是top值 varbuchang = -10; varfeelTimer = setInterval(function(){ element[0].style.top = parseInt(element[0].style.top) + buchang +"px"; if(parseInt(element[0].style.top) <= topscorll){ element[0].style.top = topscorll +"px"; window.clearInterval(feelTimer); } },100); } }) } } }) |
实现效果如图所示:
-
上一个: Canvas实现动态的雪花效果
-
下一个: jQuery实现大图轮播
相关文章
- HTML简单购物数量小程序代码展示 10-31
- html canvas实现弹幕功能 10-31
- HTML中空格表示的意义 10-31
- html area标签解读 10-31
- html使用表单标签实现注册页面代码展示 10-31
- 使用HTML截图并保存为本地图片的代码展示 10-31