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,将 ...
随机推荐
- Oracle中的执行计划
使用autotrace sqlplus系统参数:SQL> set autotrace trace onSQL> select * from dual;DUM---XExecution Pl ...
- 在DOS行下设置静态IP
A.设置静态IP CMD netsh netsh>int interface>ip interface ip>set add "本地链接" static ...
- Lodash数组方法中文总结
LodashAPI总结 Lodash是一个特别特别好用的工具,感觉有了Lodash就没有解决不了的问题了~~~~ 使用初开始 官网 https://www.lodashjs.com/docs/4.17 ...
- c Xcode has incompatible definitions in different translations units
解决方案: build > setting enable module 改为No
- 浅谈JS之text/javascript和application/javascript
问题描述: JS在IE8以下浏览器运行异常 代码: <script>标签是这样子写的: <script type="application/javascript" ...
- 【C语言】控制台窗口图形界面编程(七):鼠标事件
目录 00. 目录 01. INPUT_RECORD结构 02. MOUSE_EVENT_RECORD结构 03. ReadConsoleInput函数 04. 示例程序 00. 目录 01. INP ...
- Python3中assert断言
一般的用法是: assert condition 用来让程序测试这个condition,如果condition为false,那么raise一个AssertionError.逻辑上等于: if not ...
- react入门(下)
react生命周期 1. 组件的三个生命周期状态: * Mount:插入真实 DOM * Update:被重新渲染 * Unmount:被移出真实 DOM2. React 为每个状态都提供了两种勾子( ...
- 通过JS判断联网类型和连接状态的实现代码
<!DOCTYPE HTML><html xmlns="http://www.w3.org/1999/xhtml" lang="en"> ...
- PC端样式重置
html{font-family:"Microsoft YaHei UI","Microsoft YaHei",sans-serif;-ms-text-size ...