Привет всем. У меня есть холст, на котором есть 60 или более изображений, вид продукта, который вращается под углом 360 градусов. Я хочу добиться эффекта уменьшения масштаба при сжатии, в основном это должно происходить во вкладках для каждого отдельного изображения, а не толькопервое изображение.очистить вывод должен отображаться во вкладках им, используя Samsung Tab A между прочим.
Я пытался использовать jquery и css для достижения, но ничего не получалось.
<html>
<head>
<script src="https://d3js.org/d3.v4.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>360 product view with button</title>
<link rel="stylesheet" type="text/css" href="css/product_view_styles.css">
<link rel="stylesheet" type="text/css" href="css/product_view_theme.css">
<script src="js/jquery-2.1.1.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/rotation_view.js"></script>
<!-- zoom----------------functionality -->
<script src="https://code.jquery.com/jquery-3.4.0.min.js" 2
integrity="sha384-JUMjoW8OzDJw4oFpWIB2Bu/c6768ObEthBMVSiIx4ruBIEdyNSUQAjJNFqT5pnJ6" 3 crossorigin="anonymous">
</script>
<!-- <end Zoom functionality> -->
</head>
<body>
<!-- <zoom coding> -->
<script>
var canvas = document.getElementsByTagName('canvas')[0];
canvas.width = 800;
canvas.height = 600;
var gkhead = new Image;
window.onload = function(){
var ctx = canvas.getContext('2d');
trackTransforms(ctx);
function redraw(){
// Clear the entire canvas
var p1 = ctx.transformedPoint(0,0);
var p2 = ctx.transformedPoint(canvas.width,canvas.height);
ctx.clearRect(p1.x,p1.y,p2.x-p1.x,p2.y-p1.y);
ctx.save();
ctx.setTransform(1,0,0,1,0,0);
ctx.clearRect(0,0,canvas.width,canvas.height);
ctx.restore();
ctx.drawImage(gkhead,0,0);
}
redraw();
var lastX=canvas.width/2, lastY=canvas.height/2;
var dragStart,dragged;
canvas.addEventListener('mousedown',function(evt){
document.body.style.mozUserSelect = document.body.style.webkitUserSelect = document.body.style.userSelect = 'none';
lastX = evt.offsetX || (evt.pageX - canvas.offsetLeft);
lastY = evt.offsetY || (evt.pageY - canvas.offsetTop);
dragStart = ctx.transformedPoint(lastX,lastY);
dragged = false;
},false);
canvas.addEventListener('mousemove',function(evt){
lastX = evt.offsetX || (evt.pageX - canvas.offsetLeft);
lastY = evt.offsetY || (evt.pageY - canvas.offsetTop);
dragged = true;
if (dragStart){
var pt = ctx.transformedPoint(lastX,lastY);
ctx.translate(pt.x-dragStart.x,pt.y-dragStart.y);
redraw();
}
},false);
canvas.addEventListener('mouseup',function(evt){
dragStart = null;
if (!dragged) zoom(evt.shiftKey ? -1 : 1 );
},false);
var scaleFactor = 1.1;
var zoom = function(clicks){
var pt = ctx.transformedPoint(lastX,lastY);
ctx.translate(pt.x,pt.y);
var factor = Math.pow(scaleFactor,clicks);
ctx.scale(factor,factor);
ctx.translate(-pt.x,-pt.y);
redraw();
}
var handleScroll = function(evt){
var delta = evt.wheelDelta ? evt.wheelDelta/40 : evt.detail ? -evt.detail : 0;
if (delta) zoom(delta);
return evt.preventDefault() && false;
};
canvas.addEventListener('DOMMouseScroll',handleScroll,false);
canvas.addEventListener('mousewheel',handleScroll,false);
};
gkhead.src = 'http://phrogz.net/tmp/gkhead.jpg';
// Adds ctx.getTransform() - returns an SVGMatrix
// Adds ctx.transformedPoint(x,y) - returns an SVGPoint
function trackTransforms(ctx){
var svg = document.createElementNS("http://www.w3.org/2000/svg",'svg');
var xform = svg.createSVGMatrix();
ctx.getTransform = function(){ return xform; };
var savedTransforms = [];
var save = ctx.save;
ctx.save = function(){
savedTransforms.push(xform.translate(0,0));
return save.call(ctx);
};
var restore = ctx.restore;
ctx.restore = function(){
xform = savedTransforms.pop();
return restore.call(ctx);
};
var scale = ctx.scale;
ctx.scale = function(sx,sy){
xform = xform.scaleNonUniform(sx,sy);
return scale.call(ctx,sx,sy);
};
var rotate = ctx.rotate;
ctx.rotate = function(radians){
xform = xform.rotate(radians*180/Math.PI);
return rotate.call(ctx,radians);
};
var translate = ctx.translate;
ctx.translate = function(dx,dy){
xform = xform.translate(dx,dy);
return translate.call(ctx,dx,dy);
};
var transform = ctx.transform;
ctx.transform = function(a,b,c,d,e,f){
var m2 = svg.createSVGMatrix();
m2.a=a; m2.b=b; m2.c=c; m2.d=d; m2.e=e; m2.f=f;
xform = xform.multiply(m2);
return transform.call(ctx,a,b,c,d,e,f);
};
var setTransform = ctx.setTransform;
ctx.setTransform = function(a,b,c,d,e,f){
xform.a = a;
xform.b = b;
xform.c = c;
xform.d = d;
xform.e = e;
xform.f = f;
return setTransform.call(ctx,a,b,c,d,e,f);
};
var pt = svg.createSVGPoint();
ctx.transformedPoint = function(x,y){
pt.x=x; pt.y=y;
return pt.matrixTransform(xform.inverse());
}
}
</script>
<!--<end of zoom>-->
<div class="product_view">
<div id="topContainer">
<div id="imageContainer">
<img src="img/Apple-Watch-360-Product-Photography-90.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-89.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-88.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-87.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-86.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-85.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-84.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-83.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-82.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-81.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-80.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-79.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-78.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-77.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-76.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-75.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-74.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-73.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-72.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-71.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-70.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-69.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-68.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-67.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-66.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-65.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-64.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-63.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-62.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-61.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-60.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-59.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-58.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-57.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-56.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-55.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-54.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-53.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-52.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-51.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-50.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-49.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-48.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-47.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-46.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-45.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-44.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-43.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-42.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-41.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-40.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-39.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-38.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-37.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-36.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-35.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-34.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-33.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-32.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-31.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-30.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-29.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-28.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-27.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-26.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-25.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-24.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-23.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-22.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-21.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-20.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-19.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-18.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-17.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-16.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-15.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-14.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-13.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-12.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-11.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-09.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-08.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-07.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-06.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-05.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-04.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-03.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-02.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-01.jpeg" />
<img src="img/Apple-Watch-360-Product-Photography-001.jpeg" />
</div>
<canvas id="hotspotcanvas"></canvas>
<div id="zoomContainer">
<div id="draggableContainer">
</div>
</div>
<div id="controllerContainer">
<div id="play" class="play"></div>
<div id="prev"></div>
<div id="next"></div>
</div>
</div>
</div>
</body>
</html>
все изображения вращаются на 360 должным образом.но в крайнем случае я не получаю эффект уменьшения масштаба на вкладке.Я написал код эффекта пинча для холста, и на самом деле, пожалуйста, кто-нибудь, помогите мне бороться с этим с 8 часов.