Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery, Kinetic.js, and MSPointer events (how to addEventListener, or will on() work?)
    primarykey
    data
    text
    <p>I'm having a heck of a time troubleshooting a little canvas element for touch events on Win8 (specifically the Surface tablet). Apparently it works with the mouse or the stylus, but not with touch. I don't have access to a Win8 touch device to test with, so I'm trying to research this and not coming up with anything definitive.</p> <p>This is the actual page (using a temporary URL so the site doesn't live on in infamy in the Stack Overflow archives, lol): <a href="http://www.urlgone.com/e8e1c2/" rel="nofollow">http://www.urlgone.com/e8e1c2/</a></p> <p>The easiest fix appeared to be adding "MSPointerDown" into the jQuery on() function, but the client indicated no change in behavior.</p> <p>I guess my question is, does jQuery recognize "MSPointerDown" as an event? If it does, then my problem is probably not the function trigger, but something else... </p> <p>Or could it be in targeting a canvas object? I'm using the Kinetic.js library, and this is my first time working with canvas animations. </p> <p>EDIT: I think I was posting the wrong code in here, so this is where I'm at with it now. </p> <p>So, the object that is getting the touch/click/pointer events is this:</p> <pre><code> var triangle = new Kinetic.Image({ image: images[key], x: tri.x, y: tri.y, detectionType: "pixel" }); </code></pre> <p>And this is how I'm trying to trigger it. For normal "click" events, I'm seeing that using jQuery's .on() to bind it works fine, but I get <em>"Uncaught TypeError: Object # has no method 'addEventListener'"</em> when I try to use addEventListener on the triangle for normal clicks. </p> <pre><code> triangle.on("mousedown touchstart click", activateTriangle); /* // I popped this in here to see if it would work, assuming that if it // doesn't work for clicks, it won't work for pointer events. // This gives me the error, // Uncaught TypeError: Object #&lt;Object&gt; has no method 'addEventListener' triangle.addEventListener('click',function(){ window.console &amp;&amp; console.log('click event'); }); // And here's what I get for trying to iterate through it // Uncaught TypeError: Object #&lt;Object&gt; has no method 'addEventListener' wealth-management.php:305 // (anonymous function) wealth-management.php:305 // e.extend.each jquery-1.7.2.min.js:2 // e.fn.e.each jquery-1.7.2.min.js:2 // (anonymous function) wealth-management.php:304 // initStage wealth-management.php:318 // images.(anonymous function).onload $(triangle).each(function(){ this.addEventListener('click',function(){ window.console &amp;&amp; console.log('hi'); }); }); */ /* Try for IE10 Touch */ if (window.navigator.msPointerEnabled) { window.console &amp;&amp; console.log('msPointerEnabled'); // click to correct info window //triangle.on("MSPointerDown",activateTriangle); triangle.addEventListener("MSPointerDown", activateTriangle, false); } </code></pre> <p>If I can get addEventListener to work with "click," which I can test without a Win8 touch device, I'm assuming that the addEventListener with "MSPointerDown" will also work. Does that sound about right? How can I attach an eventListener to a Kinetic.js object?</p> <p><em><strong>EDIT</em></strong></p> <p>I couldn't get it working, so instead I have an imagemap of the canvas element that is substituted after a browser check for IE8 or "MSPointerDown." So, ironically, the canvas element will work in IE9 but not IE10. Oh well.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload