初级-图片轮播
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>原型模式-焦点图</title>
</head>
<body>
<script>
var LoopImages = function(imgArr, container) {
this.imagesArray = imgArr;
this.container = container;
this.createImage = function() {
};
this.changeImage = function() {
};
}
var SlideLoopImg = function(imgArr, container) {
LoopImages.call(this, imgArr, container);
this.changeImage = function() {
console.log('SlideLoopImg changeImage function');
}
}
var FadeLoopImg = function(imgArr, container, arrow) {
LoopImages.call(this, imgArr, container);
this.arrow = arrow;
this.changeImage = function() {
console.log('FadeLoopImg changeImage function');
}
}
window.onload = function() {
var fadeImg = new FadeLoopImg([
'01.jpg',
'2.jpg',
'3.jpg',
'4.jpg'
],
'slide',
[
'left.jpg',
'right.jpg'
]);
fadeImg.changeImage();
}
</script>
</body>
</html>
最优-图片轮播
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>原型模式-图片轮播</title>
</head>
<body>
<script>
var LoopImages = function(imgArr, container) {
this.imagesArray = imgArr;
this.container = container;
}
LoopImages.prototype = {
createImage: function() {
console.log('LoopImages createImage function');
},
changeImage: function() {
console.log('LoopImages changeImage function');
}
}
var SlideLoopImg = function(imgArr, container) {
LoopImages.call(this, imgArr, container);
}
SlideLoopImg.prototype = new LoopImages();
SlideLoopImg.prototype.changeImage = function() {
console.log('SlideLoopImg changeImage function');
}
var FadeLoopImg = function(imgArr, container, arrow) {
LoopImages.call(this, imgArr, container);
this.arrow = arrow;
}
FadeLoopImg.prototype = new LoopImages();
FadeLoopImg.prototype.changeImage = function() {
console.log('FadeLoopImg changeImage function');
}
var fadeImg = new FadeLoopImg([
'01.jpg',
'2.jpg',
'3.jpg',
'4.jpg'
],
'slide',
[
'left.jpg',
'right.jpg'
]);
console.log(fadeImg.container);
fadeImg.changeImage();
</script>
</body>
</html>