javascript - Limiting function to drawing only once when clicking -


i have click event needs run function once, have propagating each time click mouse. know it's because event looking each time images on canvas clicked, how make detect 1 click event run particular function? need make entirely separate click event?

$("#schematic_holder").on("click", function(ev){     var x = ev.pagex;     var y = ev.pagey;     for(var img in images){         var img_x = images[img].dest_x;         var img_y = images[img].dest_y;         var img_w = images[img].width;         var img_h = images[img].height;         if((x > img_x) && (x < img_x + img_w)){             if((y > img_y) && (y < img_y + img_h)){ 

this function want call once have created infinite loop, don't want.

                if(images[img].name == "landing gear handle"){                     drawimages(images[img].src, images[img].name, images[img].position_2.x, images[img].position_2.y, images[img].width, images[img].height, images[img].position_2.dest_x, images[img].position_2.dest_y, images[img].width, images[img].height, images[img].position_2.scale_x, images[img].position_2.scale_y);                 }             }         }     } }) 

one option add boolean false, check if boolean false in click handler. if false run function , set true. else return.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -