Cloud Carousel
<div class="carousel1" id="carousel1" >
<a href="#"><img class="cloudcarousel" src="data:images/p1.png" /></a>
<a href="#"><img class="cloudcarousel" src="data:images/p1.png" /></a>
<a href="#"><img class="cloudcarousel" src="data:images/p1.png" /></a>
<a href="#"><img class="cloudcarousel" src="data:images/p1.png" /></a>
<a href="#"><img class="cloudcarousel" src="data:images/p1.png" /></a>
<a href="#"><img class="cloudcarousel" src="data:images/p1.png" /></a>
<a href="#"><img class="cloudcarousel" src="data:images/p1.png" /></a>
<a href="#"><img class="cloudcarousel" src="data:images/p1.png" /></a>
<a href="#"><img class="cloudcarousel" src="data:images/p1.png" /></a>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#carousel1").CloudCarousel(
{
reflHeight:,
reflOpacity: 0.5,
reflGap: ,
yRadius:,
xPos: ,
yPos: ,
autoRotate: 'right',
speed:0.2 }
);
}); </script>
效果:

reflHeight:0, //倒影的高度,单位是像素
reflGap:0, //图片与倒影之间的间隙,单位是像素
minScale:0.5, //缩放比例
xPos:0, //X轴偏移,一般设置成外框的一半,也就是实例中“#carousel1”的宽度的一半
yPos:0, //Y轴偏移,这个可以自己调试看看,很直观的
xRadius:0, //旋转幅度的水平半径,这个是猜的
yRadius:0, //旋转幅度的垂直半径,这个是猜的,因为旋转的路径是个椭圆,你明白的
altBox:null, //显示图片alt属性的样式名称
titleBox:null, //显示图片title属性的样式名称
FPS: 30, //我猜是旋转运动的步长
autoRotate: ‘no’, //是否自动播放,设置“left”或者“right”即可自动播放
autoRotateDelay: 1500, //播放延时
speed:0.2, //播放速度(0.1 ~ 0.3之间)
mouseWheel: false, //是否支持滑轮,需要加在jQuery滑轮插件,官方的地址不见了,可以用百度“jquery.mousewheel”即可
bringToFront: false, //这个参数设置为true,就是表示点击相应的图片,滚动到当前展示,一般是不打开自动播放时
buttonLeft: ”, //控制向左的按钮
buttonRight: ” //控制向右的按钮
//////////////////////////////////////////////////////////////////////////////////
// CloudCarousel V1.0.5
// (c) 2011 by R Cecco. <http://www.professorcloud.com>
// MIT License
//
// Reflection code based on plugin by Christophe Beyls <http://www.digitalia.be>
//
// Please retain this copyright header in all versions of the software
////////////////////////////////////////////////////////////////////////////////// (function ($) { // START Reflection object.
// Creates a reflection for underneath an image.
// IE uses an image with IE specific filter properties, other browsers use the Canvas tag.
// The position and size of the reflection gets updated by updateAll() in Controller.
function Reflection(img, reflHeight, opacity) { var reflection, cntx, imageWidth = img.width, imageHeight = img.width, gradient, parent; parent = $(img.parentNode);
this.element = reflection = parent.append("<canvas class='reflection' style='position:absolute'/>").find(':last')[];
if (!reflection.getContext && $.browser.msie) {
this.element = reflection = parent.append("<img class='reflection' style='position:absolute'/>").find(':last')[];
reflection.src = img.src;
reflection.style.filter = "flipv progid:DXImageTransform.Microsoft.Alpha(opacity=" + (opacity * ) + ", style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy=" + (reflHeight / imageHeight * ) + ")"; } else {
cntx = reflection.getContext("2d");
try { $(reflection).attr({ width: imageWidth, height: reflHeight });
cntx.save();
cntx.translate(, imageHeight - );
cntx.scale(, -);
cntx.drawImage(img, , , imageWidth, imageHeight);
cntx.restore();
cntx.globalCompositeOperation = "destination-out";
gradient = cntx.createLinearGradient(, , , reflHeight);
gradient.addColorStop(, "rgba(255, 255, 255, " + ( - opacity) + ")");
gradient.addColorStop(, "rgba(255, 255, 255, 1.0)");
cntx.fillStyle = gradient;
cntx.fillRect(, , imageWidth, reflHeight);
} catch (e) {
return;
}
}
// Store a copy of the alt and title attrs into the reflection
$(reflection).attr({ 'alt': $(img).attr('alt'), title: $(img).attr('title') }); } //END Reflection object // START Item object.
// A wrapper object for items within the carousel.
var Item = function (imgIn, options) {
this.orgWidth = imgIn.width;
this.orgHeight = imgIn.height;
this.image = imgIn;
this.reflection = null;
this.alt = imgIn.alt;
this.title = imgIn.title;
this.imageOK = false;
this.options = options; this.imageOK = true; if (this.options.reflHeight > ) {
this.reflection = new Reflection(this.image, this.options.reflHeight, this.options.reflOpacity);
}
$(this.image).css('position', 'absolute'); // Bizarre. This seems to reset image width to 0 on webkit!
};// END Item object // Controller object.
// This handles moving all the items, dealing with mouse clicks etc.
var Controller = function (container, images, options) {
var items = [], funcSin = Math.sin, funcCos = Math.cos, ctx = this;
this.controlTimer = ;
this.stopped = false;
//this.imagesLoaded = 0;
this.container = container;
this.xRadius = options.xRadius;
this.yRadius = options.yRadius;
this.showFrontTextTimer = ;
this.autoRotateTimer = ;
if (options.xRadius === ) {
this.xRadius = ($(container).width() / 2.3);
}
if (options.yRadius === ) {
this.yRadius = ($(container).height() / );
} this.xCentre = options.xPos;
this.yCentre = options.yPos;
this.frontIndex = ; // Index of the item at the front // Start with the first item at the front.
this.rotation = this.destRotation = Math.PI / ;
this.timeDelay = / options.FPS; // Turn on the infoBox
if (options.altBox !== null) {
$(options.altBox).css('display', 'block');
$(options.titleBox).css('display', 'block');
}
// Turn on relative position for container to allow absolutely positioned elements
// within it to work.
$(container).css({ position: 'relative', overflow: 'hidden' }); $(options.buttonLeft).css('display', 'inline');
$(options.buttonRight).css('display', 'inline'); // Setup the buttons.
$(options.buttonLeft).bind('mouseup', this, function (event) {
event.data.rotate(-);
return false;
});
$(options.buttonRight).bind('mouseup', this, function (event) {
event.data.rotate();
return false;
}); // You will need this plugin for the mousewheel to work: http://plugins.jquery.com/project/mousewheel
if (options.mouseWheel) {
$(container).bind('mousewheel', this, function (event, delta) {
event.data.rotate(delta);
return false;
});
}
$(container).bind('mouseover click', this, function (event) { clearInterval(event.data.autoRotateTimer); // Stop auto rotation if mouse over.
var text = $(event.target).attr('alt');
// If we have moved over a carousel item, then show the alt and title text. if (text !== undefined && text !== null) { clearTimeout(event.data.showFrontTextTimer);
$(options.altBox).html(($(event.target).attr('alt')));
$(options.titleBox).html(($(event.target).attr('title')));
if (options.bringToFront && event.type == 'click') { var idx = $(event.target).data('itemIndex');
var frontIndex = event.data.frontIndex;
//var diff = idx - frontIndex;
var diff = (idx - frontIndex) % images.length;
if (Math.abs(diff) > images.length / ) {
diff += (diff > ? -images.length : images.length);
} event.data.rotate(-diff);
}
}
});
// If we have moved out of a carousel item (or the container itself),
// restore the text of the front item in 1 second.
$(container).bind('mouseout', this, function (event) {
var context = event.data;
clearTimeout(context.showFrontTextTimer);
context.showFrontTextTimer = setTimeout(function () { context.showFrontText(); }, );
context.autoRotate(); // Start auto rotation.
}); // Prevent items from being selected as mouse is moved and clicked in the container.
$(container).bind('mousedown', this, function (event) { event.data.container.focus();
return false;
});
container.onselectstart = function () { return false; }; // For IE. this.innerWrapper = $(container).wrapInner('<div style="position:absolute;width:100%;height:100%;"/>').children()[]; // Shows the text from the front most item.
this.showFrontText = function () {
if (items[this.frontIndex] === undefined) { return; } // Images might not have loaded yet.
$(options.titleBox).html($(items[this.frontIndex].image).attr('title'));
$(options.altBox).html($(items[this.frontIndex].image).attr('alt'));
}; this.go = function () {
if (this.controlTimer !== ) { return; }
var context = this;
this.controlTimer = setTimeout(function () { context.updateAll(); }, this.timeDelay);
}; this.stop = function () {
clearTimeout(this.controlTimer);
this.controlTimer = ;
}; // Starts the rotation of the carousel. Direction is the number (+-) of carousel items to rotate by.
this.rotate = function (direction) {
this.frontIndex -= direction;
this.frontIndex %= items.length;
this.destRotation += (Math.PI / items.length) * ( * direction);
this.showFrontText();
this.go();
}; this.autoRotate = function () {
if (options.autoRotate !== 'no') {
var dir = (options.autoRotate === 'right') ? : -;
this.autoRotateTimer = setInterval(function () { ctx.rotate(dir); }, options.autoRotateDelay);
}
}; // This is the main loop function that moves everything.
this.updateAll = function () {
var minScale = options.minScale; // This is the smallest scale applied to the furthest item.
var smallRange = ( - minScale) * 0.5;
var w, h, x, y, scale, item, sinVal; var change = (this.destRotation - this.rotation);
var absChange = Math.abs(change); this.rotation += change * options.speed;
if (absChange < 0.001) { this.rotation = this.destRotation; }
var itemsLen = items.length;
var spacing = (Math.PI / itemsLen) * ;
//var wrapStyle = null;
var radians = this.rotation;
var isMSIE = $.browser.msie; // Turn off display. This can reduce repaints/reflows when making style and position changes in the loop.
// See http://dev.opera.com/articles/view/efficient-javascript/?page=3
this.innerWrapper.style.display = 'none'; var style;
var px = 'px', reflHeight;
var context = this;
for (var i = ; i < itemsLen ; i++) {
item = items[i]; sinVal = funcSin(radians); scale = ((sinVal + ) * smallRange) + minScale; x = this.xCentre + (((funcCos(radians) * this.xRadius) - (item.orgWidth * 0.5)) * scale);
y = this.yCentre + (((sinVal * this.yRadius)) * scale); if (item.imageOK) {
var img = item.image;
w = img.width = item.orgWidth * scale;
h = img.height = item.orgHeight * scale;
img.style.left = x + px;
img.style.top = y + px;
img.style.zIndex = "" + (scale * ) >> ; // >>0 = Math.foor(). Firefox doesn't like fractional decimals in z-index.
if (item.reflection !== null) {
reflHeight = options.reflHeight * scale;
style = item.reflection.element.style;
style.left = x + px;
style.top = y + h + options.reflGap * scale + px;
style.width = w + px;
if (isMSIE) {
style.filter.finishy = (reflHeight / h * );
} else {
style.height = reflHeight + px;
}
}
}
radians += spacing;
}
// Turn display back on.
this.innerWrapper.style.display = 'block'; // If we have a preceptable change in rotation then loop again next frame.
if (absChange >= 0.001) {
this.controlTimer = setTimeout(function () { context.updateAll(); }, this.timeDelay);
} else {
// Otherwise just stop completely.
this.stop();
}
}; // END updateAll // Create an Item object for each image
// func = function(){return;ctx.updateAll();} ; // Check if images have loaded. We need valid widths and heights for the reflections.
this.checkImagesLoaded = function () {
var i;
for (i = ; i < images.length; i++) {
if ((images[i].width === undefined) || ((images[i].complete !== undefined) && (!images[i].complete))) {
return;
}
}
for (i = ; i < images.length; i++) {
items.push(new Item(images[i], options));
$(images[i]).data('itemIndex', i);
}
// If all images have valid widths and heights, we can stop checking.
clearInterval(this.tt);
this.showFrontText();
this.autoRotate();
this.updateAll(); }; this.tt = setInterval(function () { ctx.checkImagesLoaded(); }, );
}; // END Controller object // The jQuery plugin part. Iterates through items specified in selector and inits a Controller class for each one.
$.fn.CloudCarousel = function (options) { this.each(function () { options = $.extend({}, {
reflHeight: ,
reflOpacity: 0.5,
reflGap: ,
minScale: 0.5,
xPos: ,
yPos: ,
xRadius: ,
yRadius: ,
altBox: null,
titleBox: null,
FPS: ,
autoRotate: 'no',
autoRotateDelay: ,
speed: 0.2,
mouseWheel: false,
bringToFront: false
}, options);
// Create a Controller for each carousel.
$(this).data('cloudcarousel', new Controller(this, $('.cloudcarousel', $(this)), options));
});
return this;
}; })(jQuery);
Cloud Carousel的更多相关文章
- jQuery 3D canvas 旋转木马(跑马灯)效果插件 - cloud carousel
插件名称-cloud carousel 最新版本-1.0.5 支持ie6-ie9,firefox,chrome,opera,safari等 1.引入jquery1.4.2.js 和CloudCarou ...
- 一款超炫的jquery图片播放插件[Cloud Carousel]
今天给大家介绍一个jquery图片播放插件,也可以说是一款幻灯片放映插件,它叫Cloud Carousel,支持自动播放.图片预览.鼠标滚轮滚动,非常酷,下图是效果预览. 该jquery图片播放项目演 ...
- jQuery 幻灯片 ----摘录
Cloud Carousel (演示 | 下载) ShineTime (演示 | 下载) Nivo Slider (演示 | 下载) Interactive Photo Desk (演示 | 下载) ...
- 60款很酷的 jQuery 幻灯片演示和下载【转】
jQuery 是一个非常优秀的 JavaScript 框架,使用简单灵活,同时还有许多成熟的插件可供选择,它可以帮助你在项目中加入漂亮的效果,其中之一就是幻灯片效果的实现,这是一种在有限的网页空间内展 ...
- 33个好用的图片轮显 jquery图片轮显
原文发布时间为:2011-05-28 -- 来源于本人的百度文章 [由搬家工具导入] 我个人还是喜欢 jquery.recycle,比较通用。因为由美工设计好的轮显结构,如果套用下面,就感觉不是很方便 ...
- 利用bootstrap的carousel.js实现轮播图动画
前期准备: 1.jquery.js. 2.bootstrap的carousel.js. 3.bootstrap.css. 如果大家不知道在哪下载,可以联系小颖,小颖把这些js和css可以发送给你. 一 ...
- Carousel 旋转画廊特效的疑难杂症
疑难杂症 该画廊特效的特点就是前后元素有层级关系. 我想很多人应该看过或者用过这个插件carousel.js,网上也有相关的教程.不知道这个插件的原型是哪个,有知道的朋友可以告诉我. 该插件相对完美, ...
- On cloud, be cloud native
本来不想起一个英文名,但是想来想去都没能想出一个简洁地表述该意思的中文释义,所以就用了一个英文名称,望见谅. Cloud Native是一个刚刚由VMware所提出一年左右的名词.其表示在设计并实现一 ...
- 学会用bootstrap的modal和carousel
bootstrap框架提供了很多好用的javascript组件,可以很方便的实现常用的js效果,比如点击弹出一个div(modal).下拉菜单.旋转木马(carousel或slider),非常适合前端 ...
随机推荐
- 让 Google Test 出错时断点
Google Test 缺省是出错退出. 如果最后的出错行在系统库中,那就没什么帮助. 如果是调试运行,直接退出根本就不知道哪里出错了. 后来添加了一个运行参数: --gtest_break_on_f ...
- StarUML中InteractionOperation的画法
StarUML画InteractionOperation的方法:http://stackoverflow.com/questions/16152278/using-alt-in-sequence-di ...
- C# 运行时序列化
一. 序列化与反序列的作用 为什么要有序列化呢,考虑下面这种情况,在WINFORM或者更为方便的WPF工程中,当我们进行UI设计时,可以随意的将一个控件剪切/张贴到另外一个地方.操作方便的背后是什么在 ...
- protobuf代码生成
windows : 1,两个文件:proto.exe, protobuf-java-2.4.1.jar 2,建立一个工程TestPb,在下面建立一个proto文件件,用来存放[.proto]文件 3, ...
- jenkin插件整理
分类 plugin名称 wiki地址 源码地址 plugin作用范围 备注 Build Reports构建报告(此类插件用来分析构建结果,比果代码检查,测试CASE分析,并将这些结果以报表,趋势图等形 ...
- html案例详解(一)
一.入门. <html> <!-- 头信息的作用 1. 可以设置网页的标题. 2. 可以通知浏览使用指定的码表解释html页面. 3. --> <head> < ...
- Python进阶 函数式编程和面向对象编程等
函数式编程 函数:function 函数式:functional,一种编程范式.函数式编程是一种抽象计算机的编程模式. 函数!= 函数式(如计算!=计算机) 如下是不同语言的抽象 层次不同 高阶函数: ...
- 理解WebKit和Chromium:Chromium资源磁盘缓存
转载请注明原文地址:http://blog.csdn.net/milado_nju ## 概述 想象一下,如果没有磁盘缓存的世界.当用户访问网页的时候,每次浏览器都需要从网站下载网页,图片,JS等资源 ...
- 22_Android中的本地音乐播放器和网络音乐播放器的编写,本地视频播放器和网络视频播放器,照相机案例,偷拍案例实现
1 编写以下案例: 当点击了"播放"之后,在手机上的/mnt/sdcard2/natural.mp3就会播放. 2 编写布局文件activity_main.xml <Line ...
- 2015/12/24:嵌入式C语言的位操作随笔
今晚是平安夜,首先祝大家平安夜快乐,明天是圣诞,祝大家圣诞快乐!! 好了,这周都特别有空,上班也非常轻松,基本就是看看内核驱动,学学安卓,没什么正事的开发活干.今晚,我们来总结一例在现实 ...