3

I have tried the following code in order to implement gesture control over individual images placed inside the canvas.But this works only for the whole canvas not for the individual elements

        var can = document.getElementById("canvas");

        for (var i = 0; i < 10; i++) {
            onjarray[i] = document.getElementById("Img" + i);
            can.appendChild(onjarray[i]);
        }


            can.originalTransform = can.style.transform;
            gObj1 = new MSGesture();
            // Defining gesture object for Pen, mouse and touch
            gObj1.target = can;
            can.gesture = gObj1;
            can.gesture.pointerType = null;

            can.addEventListener("MSPointerDown", onPointerDown, false);
            can.addEventListener("MSGestureTap", onTap, false);
            can.addEventListener("MSGestureHold", onHold, false);
            can.addEventListener("MSGestureChange", onGestureChange, false);
            can.addEventListener("wheel", onMouseWheel, false);
            // Mouse Wheel does not generate onPointerUp
            can.addEventListener("MSGestureEnd", onGestureEnd, false);

can some one point me towards the rightway to have gesture control over individual elemnts place in the canvas

4

1 回答 1

1

不可能。一旦你将一个元素“喷洒”到画布上,你对它的控制就永远失去了。您不能对其进行更改、删除或捕获事件。它本质上不再是一个元素——它只是画布上的像素。您可以在画布上覆盖 SVG 形状并捕获应用于 SVG 对象的用户事件。这对你有用吗?

于 2013-02-08T16:00:38.647 回答