js鼠标拖动图片360度平面旋转
Posted 天 天 向 上
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js鼠标拖动图片360度平面旋转相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js图片查看器(可缩放、旋转、翻转)</title>
<script type="text/javascript" src="http://www.17sucai.com/preview/63238/2013-11-23/tujs/CJL.0.1.min.js"></script>
<script type="text/javascript" src="http://www.17sucai.com/preview/63238/2013-11-23/tujs/ImageTrans.js"></script>
</head>
<body>
<style type="text/css">
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
body{font:12px/180% Arial, Helvetica, sans-serif, "新宋体";}
.demo{width:600px;margin:0 auto;}
.demo p{height:30px;margin:20px 0 0 0;}
#idContainer{border:1px solid #000;width:600px;height:500px; background:#FFF center no-repeat;}
</style>
<div class="demo">
<p style="font-size:16px;">ps:鼠标拖动图片旋转,鼠标滚动滚轮缩放。</p>
<div id="idContainer"></div>
<p>
<input id="idLeft" type="button" value="向左旋转" />
<input id="idRight" type="button" value="向右旋转" />
<input id="idVertical" type="button" value="垂直翻转" />
<input id="idHorizontal" type="button" value="水平翻转" />
<input id="idReset" type="button" value="重置" />
</p>
</div>
<script type="text/javascript">
(function(){
var container = $$("idContainer"), src = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503030648809&di=8dbacaef5e16d6857d9cea0c4b9108ea&imgtype=0&src=http%3A%2F%2Fimg.130158.com%2Fuploads%2Fi_3_5136495x3945925686_23.jpg",
options = {
onPreLoad: function(){ container.style.backgroundImage = "url(‘loading.gif‘)"; },
onLoad: function(){ container.style.backgroundImage = ""; }
},
it = new ImageTrans( container, options );
it.load(src);
//垂直翻转
$$("idVertical").onclick = function(){
it.vertical();
}
//水平翻转
$$("idHorizontal").onclick = function(){
it.horizontal();
}
//左旋转
$$("idLeft").onclick = function(){
it.left();
}
//右旋转
$$("idRight").onclick = function(){
it.right();
}
//重置
$$("idReset").onclick = function(){
it.reset();
}
})()
</script>
</body>
</html>
以上是关于js鼠标拖动图片360度平面旋转的主要内容,如果未能解决你的问题,请参考以下文章