html万花筒相册旋转效果,jquery css3 3D万花筒图片相册展示特效
特效描述:jquery css3 3D萬(wàn)花筒 圖片相冊(cè)展示特效。3D圖片相冊(cè)(只支持Firefox瀏覽器演示)
代碼結(jié)構(gòu)
1. 引入JS
2. HTML代碼
$(function(){
var imgL=$(".pic img").size();
var deg=360/imgL;
var roY=0,roX=-10;
var xN=0,yN=0;
var play=null;
$(".pic img").each(function(i){
$(this).css({
$(this).attr('ondragstart','return false');
});
$(document).mousedown(function(ev){
var x_=ev.clientX;
var y_=ev.clientY;
clearInterval(play);
console.log('我按下了');
$(this).bind('mousemove',function(ev){
/*獲取當(dāng)前鼠標(biāo)的坐標(biāo)*/
var x=ev.clientX;
var y=ev.clientY;
/*兩次坐標(biāo)之間的距離*/
xN=x-x_;
yN=y-y_;
roY+=xN*0.2;
roX-=yN*0.1;
console.log('移動(dòng)');
//$('body').append('
$('.pic').css({
transform:'perspective(800px) rotateX('+roX+'deg) rotateY('+roY+'deg)'
});
/*之前的鼠標(biāo)坐標(biāo)*/
x_=ev.clientX;
y_=ev.clientY;
});
}).mouseup(function(){
$(this).unbind('mousemove');
var play=setInterval(function(){
xN*=0.95;
yN*=0.95
if(Math.abs(xN)<1 && Math.abs(yN)<1){
clearInterval(play);
}
roY+=xN*0.2;
roX-=yN*0.1;
$('.pic').css({
transform:'perspective(800px) rotateX('+roX+'deg) rotateY('+roY+'deg)'
});
},30);
});
});
總結(jié)
以上是生活随笔為你收集整理的html万花筒相册旋转效果,jquery css3 3D万花筒图片相册展示特效的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 《买土豆的故事》——经典职场故事
- 下一篇: VB使用DDE与组态王进行数据交换