【angularjs】使用angularjs模拟淘宝首页-淘宝头条滚动效果
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>仿淘宝首页-淘汰头条滚动效果</title>
<script src="https://cdn.bootcss.com/angular.js/1.6.7/angular.min.js"></script>
<style type="text/css">
.box{
margin:100px auto;
border:1px solid #ccc;
width:170px;
height:42px;
line-height:20px;
overflow:hidden;
}
.box .content{
list-style-type:none;
margin:0;padding:0;
margin-left:6px;
}
/*系统支持ie8就选line-height:16px;,但不支持opera 否则选line-height:20px;*/
.box .content a{
font-size:12px;
line-height:16px;
}
</style>
</head>
<body ng-app="myApp">
<div class="box" ng-controller="ezCtrl">
<div id="transverseRoll">
<div class="content" ng-repeat="item in msgArr track by $index">
<span ng-bind="item"></span>
</div>
</div>
<script language="javascript">
var app = angular.module("myApp", []);
app.controller("ezCtrl", function ($scope, $http,$timeout,$interval) {
$scope.items = [
{
con:[
'身高多少',
'体重多少',
] },
{
con: [
'身高多少1',
'体重多少1',
]
},
{
con: [
'身高多少2',
'体重多少2',
]
}
]
/**
* des 仿淘宝首页-淘汰头条滚动效果
* @param {[type]} timer [定时器]
* @param {[type]} _timer [定时器]
* @param {[type]} temp [临时变量用来存储当前显示的内容]
* @param {[type]} max []
* @param {[type]} index [当前显示内容的索引]
* @param {[type]} obj [获取滚动元素]
* @param {[type]} $scope.msgArr [当前显示内容]
* @param {[type]} lh [高度]
* @param {[type]} speed [时间]
*/
var startmarquee = function(lh, speed, delay) {
var timer = null,_timer = null,temp = [];
var max = $scope.items.length-1,index = 0;
var obj = document.getElementById("transverseRoll");
obj.style.marginTop = 0;
temp = $scope.items[index].con;
$scope.msgArr = temp.concat(temp);
var start = function() {
$scope.msgArr = [];//初始化
index++;//0,1,2
if (index > max) {
index = 0;
}
//更新显示内容
temp = $scope.items[index].con;
setTimeout(() => {
$scope.$apply(function(){
$scope.msgArr = temp.concat(temp);
});
}, 100);
clearInterval(timer);
timer = setInterval(scrolling, speed);
obj.style.marginTop = parseInt(obj.style.marginTop) - 4 + "px";
}
var scrolling = function() {
if (parseInt(obj.style.marginTop) % lh != 0) {
obj.style.marginTop = parseInt(obj.style.marginTop) - 4 + "px";
if (Math.abs(parseInt(obj.style.marginTop)) >= obj.scrollHeight / 2) obj.style.marginTop = 0;
} else {
clearInterval(timer);
clearTimeout(_timer);
setTimeout(start, delay);
}
}
clearTimeout(_timer);
setTimeout(start, delay);
}
startmarquee(2000, 20, 1500);
}) </script>
</body>
</html>
作者:smile.轉角
QQ:493177502
【angularjs】使用angularjs模拟淘宝首页-淘宝头条滚动效果的更多相关文章
- 3.使用Selenium模拟浏览器抓取淘宝商品美食信息
# 使用selenium+phantomJS模拟浏览器爬取淘宝商品信息 # 思路: # 第一步:利用selenium驱动浏览器,搜索商品信息,得到商品列表 # 第二步:分析商品页数,驱动浏览器翻页,并 ...
- Android中仿淘宝首页顶部滚动自定义HorizontalScrollView定时水平自动切换图片
Android中仿淘宝首页顶部滚动自定义HorizontalScrollView定时水平自动切换图片 自定义ADPager 自定义水平滚动的ScrollView效仿ViewPager 当遇到要在Vie ...
- 淘宝首页源码藏美女彩蛋(下)(UED新作2013egg)
我们已经知道,执行美女会得到"彩蛋",而正是彩蛋做到了taobaoUED展现给大家的神奇的前端魅力.今天我们来看看FP.egg&&FP.egg("%cjo ...
- js实现淘宝首页图片轮播效果
原文:http://ce.sysu.edu.cn/hope2008/Education/ShowArticle.asp?ArticleID=10585 <!DOCTYPE html> &l ...
- Selenium+Chrome/phantomJS模拟浏览器爬取淘宝商品信息
#使用selenium+Carome/phantomJS模拟浏览器爬取淘宝商品信息 # 思路: # 第一步:利用selenium驱动浏览器,搜索商品信息,得到商品列表 # 第二步:分析商品页数,驱动浏 ...
- Selenium模拟浏览器抓取淘宝美食信息
前言: 无意中在网上发现了静觅大神(崔老师),又无意中发现自己硬盘里有静觅大神录制的视频,于是乎看了其中一个,可以说是非常牛逼了,让我这个用urllib,requests用了那么久的小白,体会到sel ...
- 模仿淘宝首页写的高仿页面,脚本全用的原生JS,菜鸟一枚高手看了勿喷哈
自己仿照淘宝首页写的页面,仿真度自己感觉可以.JS脚本全是用原生JavaScript写得,没用框架.高手看了勿喷,请多多指正哈!先上网页截图看看效果,然后上源码: 上源码,先JavaScript : ...
- 使用selenium模拟浏览器抓取淘宝信息
通过Selenium模拟浏览器抓取淘宝商品美食信息,并存储到MongoDB数据库中. from selenium import webdriver from selenium.common.excep ...
- angularJs中怎么模拟jQuery中的this?
最近自己正在学习angularJs,在学到ng-click时,由于想获取当前点击元素的自身,开始想到了用$index来获取当前元素的索引同样能实现我想要的效果,但是在有些特殊的情况下,使用$index ...
随机推荐
- js调用摄像头
详情源码请参见下方的 GitHub !!! <div> <b>调用移动端摄像头</b><br> <label>照相机: <input ...
- Android为TV端助力 自定义动画
android自定义动画注意是继承Animation,重写里面的initialize和applyTransformation,在initialize方法做一些初始化的工作,在applyTransfor ...
- Visualization of Detail Point Set by Local Algebraic Sphere Fitting
Refers to Dynamic Sampling and Rendering of Algebraic Point Set Surfaces Growing Least Squares for t ...
- 布局优化之ViewStub源码分析
源码分析 @RemoteView public final class ViewStub extends View { private int mInflatedId; private int mLa ...
- View体系之属性动画
(内容省略了valueAnimator和PropertyValueHolder使用) 属性动画的使用的主要方式是AnimatorSet和ObjectAnimator配合使用.ObjectAnimato ...
- (网页)HTML中INPUT type="date"标签如何赋值注意问题(转)
现在的html5 input标签支持type="date" 显示有日期的日历控件,一行简单的代码就能显示出一个日历控件,但是有的时候需要给它一个默认的日期值,这个时候可能就要用到v ...
- Vue组件的使用
前面的话 组件(component)是Vue最强大的功能之一.组件可以扩展HTML元素,封装可重用的代码,根据项目需求,抽象出一些组件,每个组件里包含了展现.功能和样式.每个页面,根据自己的需要,使用 ...
- 学习用Node.js和Elasticsearch构建搜索引擎(5):mac本机部署canal
1.背景介绍 最近做的一个项目需要快速检索数据,经过商讨后采用了ElasticSearch作为快速检索数据引擎,但是数据如何同步到ES中是个问题,我们最开始计划了定时任务.mysql trigger等 ...
- Vue.js 2.x:组件的定义和注册(详细的图文教程)
本文最初发表于博客园,并在GitHub上持续更新前端的系列文章.欢迎在GitHub上关注我,一起入门和进阶前端. 以下是正文. 前言 什么是组件 组件: 组件的出现,就是为了拆分Vue实例的代码量的, ...
- python3接收、解析邮件
邮件接收 python3可以使用poplib.POP3进行邮件接收,具体如下: import poplib from email.parser import Parser def get_email( ...