IPad Safari Javascript Incrementor Hanging

I use javascript to allow the user to increase or decrease the form field.

$("#dash_up_arrow").bind('touchstart', function(e){
   $num++
   $field.html($num);
});

It seems to hang when I quickly press the arrow. It receives the correct number of touchstart events, but if I click it too quickly, it skips numbers.

The strange thing is about 1/3 of the time when I load a page that works flawlessly - no matter how fast I click the arrow, the number increases when I synchronize with clicking on it. Then I, when I reload the page, will return to hanging.

I made sure applications are not running in the background

Any question what causes this?

+3
source share
2 answers

. ,

 background-image: url('../images/header_background.png'),
                   url('../images/swirly_pattern_light.png'); 

, CSS, javascript. javascript, , . .

- CSS. CSS , .

2 . -, html. .

, .

+2

, , , "", , , .

? ( , 100%)

var touched = false; // add a global var to save 
                     // whether a touch is being processed
$("#dash_up_arrow").bind('touchstart', function(e){
   if( !touched ) {
     touched = true;
     $num++;
     $field.html($num);
     touched = false;
   }
});

, :

$("#dash_up_arrow").bind('touchstart', function(e){
   var currentNum = $field.html();
   $field.html(++currentNum);
});

, ?

, 1/3 , , . , , , iPad, -)

+1

Source: https://habr.com/ru/post/1789672/


All Articles