Django打造大型企业官网(六)
4.9.根据轮播图个数修改小圆点数量
src/js/index.js
function Banner() {
this.bannerWidth = 798;
} Banner.prototype.initBanner = function () {
var self = this;
this.bannerUL.css({
"width":self.bannerWidth*self.bannerCount
})
}; Banner.prototype.initPageControl = function () {
var self = this;
var pageControl = $(".page-control");
for (var i=0;i<self.bannerCount;i++){
var circle = $("<li></li>");
pageControl.append(circle);
if (i === 0){
circle.addClass("active");
}
}
pageControl.css({"width":self.bannerCount*12+8*2+16*(self.bannerCount-1)});
}; Banner.prototype.run = function () {
this.initBanner();
this.initPageControl();
this.loop();
this.listenArrowClick();
};
4.10.小圆点点击事件和自动更新当前选中的小圆点
src/js/index.js
function Banner() {
this.pageControl = $(".page-control");
}; Banner.prototype.animate = function () {
var self = this;
self.bannerUL.animate({"left":-798*self.index},500);
// 通过index获取到当前的li标签,添加active样式,兄弟li标签移除active样式
self.pageControl.children('li').eq(self.index).addClass("active").siblings().removeClass("active");
}; Banner.prototype.listenPageControl = function () {
var self = this;
self.pageControl.children("li").each(function (index,obj) {
$(obj).click(function () {
self.index = index;
self.animate();
});
});
}; Banner.prototype.run = function () {
this.listenBannerHover();
};
src/css/scss.css
.header{
z-index:; .banner-group{ overflow:hidden;
z-index:;
4.11.实现自动循环无限轮播
src/js/index.js
function Banner() {
this.index = 1;
}; Banner.prototype.initBanner = function () {
var self = this;
//实现无限轮播,原理:123-->>31231,在首尾克隆一张
var firstBanner = self.liList.eq(0).clone();
var lastBanner = self.liList.eq(self.bannerCount-1).clone();
self.bannerUL.append(firstBanner);
self.bannerUL.prepend(lastBanner);
self.bannerUL.css({
"width":self.bannerWidth*(self.bannerCount+2),
"left":-self.bannerWidth,
});
}; Banner.prototype.animate = function () {
var self = this;
self.bannerUL.animate({"left":-798*self.index},500);
//小圆点的active
var index = self.index;
if(index === 0){
index = self.bannerCount-1;
}else if(index === self.bannerCount+1){
index = 0;
}else{
index = self.index - 1;
}
// 通过index获取到当前的li标签,添加active样式,兄弟li标签移除active样式
self.pageControl.children('li').eq(index).addClass("active").siblings().removeClass("active");
}; Banner.prototype.loop = function(){
var self = this;
this.timer = setInterval(function () {
if(self.index >= self.bannerCount+1){
self.bannerUL.css({
"left":-self.bannerWidth,
});
self.index = 2;
}else{
self.index++;
}
self.animate();
},2000);
};
4.12.左右牵头切换实现循环轮播
src/js/index.js
Banner.prototype.listenArrowClick = function () {
var self = this;
self.leftArrow.click(function () {
if(self.index === 0){
self.bannerUL.css({
"left":-self.bannerCount*self.bannerWidth,
});
self.index = self.bannerCount - 1;
}else{
self.index --;
}
self.animate();
}); self.rightArrow.click(function () {
if(self.index === self.bannerCount + 1){
self.bannerUL.css({
"left":-self.bannerWidth,
});
self.index = 2;
}else{
self.index ++;
}
self.animate();
});
};
Django打造大型企业官网(六)的更多相关文章
- 超细讲解Django打造大型企业官网
本文为知了课堂黄勇老师讲的<超细讲解Django打造大型企业官网>的笔记. 第一章 Django预热 1.创建virtualenv虚拟环境 2.URL组成部分详解 3.Django介绍 4 ...
- Django打造大型企业官网
第1章 Django预热 1-为什么需要虚拟环境 2-virtualenv创建虚拟环境 3-virtualenvwrapper使用 4-URL组成部分讲解 5-课程准备工作 6-Django介绍 第2 ...
- Django打造大型企业官网(二)
三.项目环境搭建 3.1.创建项目环境和安装包 创建django项目 mkvirtualenv DjangoProject workon DjangoProject pip install -i ht ...
- Django打造大型企业官网(八)
4.16.侧边栏标题和广告位布局完成 templates/news/index.html <div class="sidebar-wrapper"> <div c ...
- Django打造大型企业官网(七)
4.13.新闻列表tab栏布局完成 templates/news/index.html <div class="list-outer-group"> <ul cl ...
- Django打造大型企业官网(五)
4.6.切换轮播图的箭头样式以及显示和隐藏 templates/news/index.html <span class="arrow left-arrow">‹< ...
- Django打造大型企业官网(四)
4.3.轮播图布局和样式 templates/news/index.html <div class="news-wrapper"> <div class=&quo ...
- Django打造大型企业官网(三)
四.前端首页 4.1.导航条实现 (1)templates/new/index.html <!DOCTYPE html> <html lang="en"> ...
- Django打造大型企业官网(一)
一.nvm的安装 (1)下载:nvm1.16 (2)安装完成后添加环境变量 C:\Users\Administrator\AppData\Roaming\nvm (3)修改settings.txt,将 ...
随机推荐
- POJ数据的输入输出格式
POJ在评阅习题时需要向程序提供输入数据,并获取程序的输出结果.因此提交的程序需按照每个习题具体的输入输出格式要求处理输入输出.有的时候,测评系统给出程序的评判结果是“数据错误”或“结果错误”,有可能 ...
- ztree 样式修改 white-space: nowrap; 后 下划线要是跟上的话 宽度 width 要 auto 就自动更新了
width:auto; border-bottom:1px solid #ccc; height:30px; display: inline-block;white-space: nowrap;
- USB设备请求命令详解
USB设备请求命令 :bmRequestType + bRequest + wValue + wIndex + wLength 编号 值 名称 (0) 0 GET_STATUS:用来返回特定接收者 ...
- CAD绘制固定圆形标注(网页版)
js中实现代码说明: function DoFixCircleComment() { var ent = mxOcx.DrawCustomEntity("TestMxCustomEntity ...
- CAD参数绘制块引用对象(网页版)
主要用到函数说明: _DMxDrawX::DrawBlockReference 绘制块引用对象.详细说明如下: 参数 说明 DOUBLE dPosX 插入点的X坐标 DOUBLE dPosY 插入点的 ...
- android网络图片自动轮播 githhub地址
https://github.com/panxw/android-image-indicator
- 笔试算法题(06):最大连续子数组和 & 二叉树路径和值
出题:预先输入一个整型数组,数组中有正数也有负数:数组中连续一个或者多个整数组成一个子数组,每个子数组有一个和:求所有子数组中和的最大值,要求时间复杂度O(n): 分析: 时间复杂度为线性表明只允许一 ...
- Python 迭代器-生成器-面向过程编程
上节课复习:1. 函数的递归调用 在调用一个函数的过程中又直接或者间接地调用了函数本身称之为函数的递归 函数的递归调用有两个明确的阶段: 1. 回溯 一层一层地调用本身 注意: 1.每一次调用问题的规 ...
- Wireshark does not show SSL/TLS
why it doesn't show as "TLS/SSL"? Because it's not on the standard port for SSL/TLS. You c ...
- buf.compare()
buf.compare(otherBuffer) otherBuffer {Buffer} 返回:{Number} 比较两个 Buffer 实例,无论 buf 在排序上靠前.靠后甚至与 otherBu ...