当前位置:   article > 正文

html5实现翻书效果,基于javascript html5实现3D翻书特效

电子相册翻页js翻书效果html5移动端网页前端模板h5div css源码

var prefixes = ['Webkit','Moz','ms','O',''],book = document.querySelectorAll('.book')[0],page = document.querySelectorAll('.front-cover')[0],dino = document.querySelectorAll('.dino')[0],shadow = document.querySelectorAll('.shadow')[0],hold = false,centerPoint = window.innerWidth / 2,pageSize = 300,clamp = function (val,min,max) {

return Math.max(min,Math.min(val,max));

};

page.onmousedown = function () {

hold = true;

};

window.onmouseup = function () {

if (hold) {

hold = false;

}

};

window.onresize = function () {

centerPoint = window.innerWidth / 2;

};

window.onmousemove = function (evt) {

if (!hold) {

return;

}

var angle = clamp((centerPoint - evt.pageX + pageSize) / pageSize * -90,-180,0),i,j;

for (i = 0,j = prefixes.length; i < j; i++) {

book.style[prefixes[i] + 'Transform'] = 'rotateX(' + (60 + angle / 8) + 'deg)';

page.style[prefixes[i] + 'Transform'] = 'rotateY(' + angle + 'deg)';

dino.style[prefixes[i] + 'Transform'] = 'rotateX(' + (angle / 2) + 'deg)';

shadow.style[prefixes[i] + 'Transform'] = 'translateZ(1px) skewX(' + (angle / 8) + 'deg)';

}

};

})(window,document);

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/117140
推荐阅读
相关标签
  

闽ICP备14008679号