html仿微信朋友圈图片浏览,模仿微信朋友圈 图片浏览 h5 html5 js

啥也不说了直接上代码

Document

body{margin:0;}

img{height:100px;width:100px;position:relative;display:block;margin:0 auto;}

preView.init('.img');

preview.js

(function(doc,win){

var preview = function(){

this.win_w=doc.body.offsetWidth; //屏幕宽度

this.win_h=doc.documentElement.clientHeight; //屏幕高度

this.index=1;

}

preview.prototype.init = function(selector){

this.el=doc.querySelectorAll(selector);

var pre=this;

function large(){

var trans="0.7s cubic-bezier(0.42, 0, 0.46, 1)";

this.style.webkitTransition=trans;

if(this.className.indexOf('iamlarge')==-1){

this.className+=' iamlarge';

var scroll_top=doc.body.scrollTop; //滚动条上卷高度

this.style.transition=trans;

(function(){

var scale=pre.win_w/this.width;

var imgeh=this.height*scale;

var move_y=((pre.win_h-this.height)/2-this.offsetTop+scroll_top)/scale;

var move_x=((pre.win_w-this.width)/2-this.offsetLeft)/scale;

var tran="scale("+scale+","+scale+") translate3d("+move_x+"px,"+move_y+"px,0)";

document.body.style.backgroundColor="#000";

this.style.zIndex=pre.index;

this.style.transform=tran;

this.style.webkitTransform=tran;

pre.index++;

}.call(this))

}else{

this.className=this.className.replace(' iamlarge','');

var tran="scale(1,1) translate3d(0,0,0)";

this.style.transform=tran;

this.style.webkitTransform=tran;

document.body.style.backgroundColor="transparent";

setTimeout(function(){

this.style.zIndex='auto';

}.bind(this),700);

}

}

for(var i=0;i

this.el[i].addEventListener('click',large);

}

}

return preView = new preview();

})(document,window)

demo下载地址

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值