原文摘自我的前端博客,欢迎大家来访问
http://hacke2.github.io/
起因
豪哥的JS练习又一波来袭~今天又写了个百度爱玩的东西,暂且叫他带层次感的图片轮播吧
![home](https://i-blog.csdnimg.cn/blog_migrate/9b28425a16fcc079ba264c1b7bcfa368.png)
思路
主要思路有二
图片大小、位置的计算
我的思路是这样的:
因为首尾切换,我想到的就是自己封装一个循环队列
//封装一个循环队列
function CircularQueue(arr) {
this.arr = arr || [];
}
//移除前一个,追加到最后
CircularQueue.prototype.shift = function() {
var temp = this.arr.shift();
this.arr.push(temp);
}
//移除最后一个,追加到头部
CircularQueue.prototype.unshift = function() {
var temp = this.arr.pop();
this.