How to bind an event to appended element in jQuery?

Why are touch events slow in the Android browser?

  • I'm trying to write a simple html based drawing application (standalone simplified code attached bellow).  I've tested this on the following devices: iPad 1 and 2: Works great ASUS T101 running Windows: Works great Samsung Galaxy Tab: Extremely slow and patchy -- unusable. Lenovo IdeaPad K1: Extremely slow and patchy -- unusable. Asus Transformer Prime: Noticeable lag compare with the iPad -- close to usable. The Asus tablet is running ICS, the other android tablets are running  3.1 and 3.2.  I tested using the stock Android browser.  I also tried the Android Chrome Beta, but that was even worse. My questions is why are the Android tablets so slow?  Am I doing something wrong or is it an inherit problem with Android OS or browser, or is there anything I can do about it in my code? multi.html: <html> <body> <style media="screen">   canvas { border: 1px solid #CCC; } </style> <canvas style="" id="draw" height="450" width="922"></canvas> <script class="jsbin" src="jquery.js"></script> <script src="multi.js"></script> </body> </html> multi.js:     var CanvasDrawr = function(options) {       // grab canvas element       var canvas = document.getElementById(http://options.id),       ctxt = canvas.getContext("2d");   canvas.style.width = '100%'   canvas.width = canvas.offsetWidth;   canvas.style.width = '';   // set props from options, but the defaults are for the cool kids   ctxt.lineWidth = options.size || Math.ceil(Math.random() * 35);   ctxt.lineCap = options.lineCap || "round";   ctxt.pX = undefined;   http://ctxt.pY = undefined;   var lines = [,,];   var offset = $(canvas).offset();   var eventCount = 0;   var self = {     // Bind click events     init: function() {       // Set pX and pY from first click       canvas.addEventListener('touchstart', self.preDraw, false);       canvas.addEventListener('touchmove', self.draw, false);     },     preDraw: function(event) {       $.each(event.touches, function(i, touch) {         var id = touch.identifier;         lines[id] = { x     : this.pageX - offset.left,                       y     : this.pageY - offset.top,                       color : 'black'                     };       });

  • Answer:

    I would advice you to try out the new Native Android UI Firefox (codename: Fennec) ! EDIT: Which is now released, and in Google Play It's so vastly improved you will see the performance benefits right away. Maxthon Mobile Brower I tested and compared to other mobile browsers and the touch events seems much more, also things like AJAX loads are much faster .. At least what I tried on Gingerbread 2.3.5 Galaxy S2.

Christoffer Aasted at Quora Visit the source

Was this solution helpful to you?

Other answers

I own an iPad 2 and I own (or have owned) devices running Android 2.2 through 4.0.3... In all cases Android 3.x was slower (in everything) IMO.  I don't know why (which is at the heart of your question), but I can confirm it's the case.  Lots of Javascript that I did was drastically slower on Android devices. As an example I had some code that kept the footer at the bottom of the browser.  On PCs the code kept the footer at the bottom.  On the Android devices the footer would scroll up the page and shoot back to the bottom only after the scrolling stopped.

Shawn Cummings

I am not sure but i think this a issue of Android versions excluding ICS, for not having Hardware Accleration. We see a iOS like smoothness in ICS because ICS uses Hardware Acceleration.

Oğuz Özgül

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.