1

我一直在尝试使用 Kineticjs 4.3.3。创建图形图像并可以拖过父 div,但如果父 div 在其样式属性下设置了缩放,它将不起作用(提供的示例http://jsfiddle.net/kreavie/MZSE9/)。有没有人知道如何在之前设置缩放时拖动工作?

谢谢, krlib

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=9">
    <script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.3.0-beta2.js"></script>
    <script type="text/javascript">


 window.onload = function () {

        var par = document.getElementById('frame');
        var canvas = document.createElement('div');
        canvas.id = "canvas1";
        par.appendChild(canvas);


        var stage = new Kinetic.Stage({
            container: 'canvas1',
            width: 500,
            height: 500
        });

        var layer = new Kinetic.Layer();
        var triangle = new Kinetic.Polygon({
            stroke: "red",
            strokeWidth: 4,
            points: [60, 100, 90, 100, 90, 140],
            draggable: true
        });

        layer.add(triangle);
        stage.add(layer);


    }
    </script>

</head>
<body >

     <div id="frame" style="width: 200px; height: 200px; -ms-transform: scale(0.420091);">
                  </div>

</body>
</html>
4

1 回答 1

0

见:http: //jsfiddle.net/MZSE9/2/

您的对象是 canvas 元素的本地对象,而不是您应用缩放的另一个 div。

如果您想缩放对象、图层或整个舞台,只需执行以下操作:

 shape.setScale(xAmount, yAmount);
 stage.setScale(xAmount, yAmount);
 layer.setScale(xAmount, yAmount);
于 2013-02-28T16:19:38.843 回答