javascript - mouseover event propagation issue - Manually propagate -
i implementing user interface project i'm working on , can found here : toobrok
each time mouse of user enters div, class added div highlight it, utilize stoppropagation()
method restrict highlighting div z-index higher (the top div in z axis). however, sometimes, user needs select element hidden one, when dimensions of 2 elements different, , if bottom div larger, can find points of bottom div not hidden top one, when dimensions same, user able press key alter depth (on z-axis) of selection.
the relevant code given below (in coffeescript), javascript solution help me:
ui.bind = (elements, index) -> ids = ui.getidselector(elements) $(ids).attr("centroid", index) $(ids).mouseover (event) -> event.stoppropagation() ui.highlight $(ids) $(ids).mouseout (event) -> event.stoppropagation() ui.resethighlight $(ids)
i hope question clear , looking forwards answer.
this illustration of html consider :
<!doctype html> <html> <head> <title> sample page </title> </head> <body> <div id="container"> <div id="child1">some text...</div> </div> </body </html>
and related css :
#container { height: 200px; width: 500px; } #child1 { height: 90%; width: 90%; }
when mouse enters child1 element, element highlighted, want container element highlight when user press specific key.
i utilize jquery parent() function select element on example, not sure solution, sometimes, parent can have size of 0px , and mouseover on element not consistent. want select element selected javascript if not utilize stoppropagation() event.
i found might help : how undo event.stoppropagation in jquery?
but cannot utilize in case... because status user action, , cannot synchronously wait user something.
i started writing code decided leave implementation you. here text explanation:
at point of time (probably when user press button cycle through hovered elements) have find candidates highlighting. there no other way rather manually loop through elements , check if mouse position within bound rect. can mouse coordinates argument in mouseover callback. save these hovered elements in array.
next, have manually take element highlight. highlight first element in saved array , move element end of array. may want increment element z-index , add together callback mouseout element.
hope helps, sense free inquire if need more details.
javascript jquery css arrays coffeescript
No comments:
Post a Comment