iwato Posted February 12, 2018 Share Posted February 12, 2018 (edited) UNDERSTANDING THE PROBLEM: Probably the best way to understand the problem that the following piece of code produces is to observe the problem in action. Please do the following: Open to the Grammar Captive podcast_hostpage.php. Look for the following path in the navigation bar on your left: Podcast Archives/Concept/Podcast Index ... Click on the words Podcast Index ... Run your mouse over the list stopping at various places within the list until the following effect is produced. An unending back and forth opening and closing of the <li> elements of a particular <ul> element. Caution: only the first three <li> elements are active. The RELEVANT CODE $("#main").html(concept_var); $("#main").find('.cat_list').children().hide(); $("#main").find('.cat_list').each(function(){ $(this).hover(function(){ $(this).children().show(400); $(this).find('li').mouseenter(function(){ $(this).css('cursor','pointer'); }).click(function(){ ... }); }); }, function(){ $(this).children().hide(400); } ); }); QUESTION: How does one insure that one list is closed before another is open, and that no two lists or sublists is open at the same time" Roddy Edited February 12, 2018 by iwato Link to comment Share on other sites More sharing options...
justsomeguy Posted February 12, 2018 Share Posted February 12, 2018 That's a design problem. If you hover over the second bullet it's a fairly long list that pops up. Then if you move to hover over the third one, so that the second one collapses and the third one expands, the third one is smaller than the second one so once it's expanded the mouse is no longer over it, now the mouse is over the fourth or fifth item or something. So if you're just doing hover and mouseover stuff that's going to cause a problem when you move things around so that the mouse is now hovering over a different element. Maybe use click events instead of hover events. Link to comment Share on other sites More sharing options...
iwato Posted February 12, 2018 Author Share Posted February 12, 2018 Can you think of a different way? I purposely used hover to make possible to see what is available at a glance. Roddy Link to comment Share on other sites More sharing options...
Ingolme Posted February 13, 2018 Share Posted February 13, 2018 The main issue is the animation. If you eliminate the animation, you're eliminating the window of time in which the user can move the mouse over to a different element. It's a design flaw to have content that changes the location of elements on mouseover and mouseout events because it makes it difficult for the user to reach elements they want to get to. Whenever anything causes elements to shift around, it's always better to use click events for it so that any rearrangement that occurs was intended by the user. 1 Link to comment Share on other sites More sharing options...
justsomeguy Posted February 13, 2018 Share Posted February 13, 2018 My solution is to use click/touch instead of hover. Keep in mind also that hover doesn't work on mobile devices, the browser doesn't know when you're just pointing at something. 1 Link to comment Share on other sites More sharing options...
iwato Posted February 18, 2018 Author Share Posted February 18, 2018 OK, guys! I have made the switch. I have eliminated the multiple and simultaneous animations and switched to click. All that remains is getting the cursor to appear properly, but this should be much easier to achieve. Many thanks! Roddy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now