javascript - Counting how many layers exist at a specific position on the screen -


my page running touchmove event captures position of user's finger on screen via:

xpos = e.originalevent.touches[0].pagex; ypos = e.originalevent.touches[0].pagey; 

the page has many layers (created position:absolute divs) , @ point, want calculte how many such layers exist below user's current position on screen.

the method can think of have array of layers' positions , loop through that. seems rather processor intensive when there may hundreds of layers on screen @ once.

is there simple way in js or jquery count items exist in position, or better practise way array suggestion.

as far know, there no such way. approach give layers class, select them , iterate through them. depending on trying achieve , how you'll have perform calculation, may possible use caching , approximation (e.g. not checking pixel area of x^2 pixels , caching result, etc) make things run faster.

that being said, encourage first try solution you've thought of , see how fast runs. browsers pretty fast such standard operations (think layer drag & drop boundary checks), i'm pretty confident won't slow think :)


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -