How can I modify Appbar to expand the menu items on hover, rather than on click?
Would be great if there was an option for this in admin/settings/appbar. I think the default should be to expand on hover which reduces clicks and increases usability.
Best regards,
.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | appbar.js_.txt | 2.97 KB | icecreamyou |
| #4 | appbar_hover_blocks_923672-1.patch | 3.78 KB | icecreamyou |
| #2 | appbar-expand-on-hover-923672.patch | 6.11 KB | haagendazs |
Comments
Comment #1
icecreamyou commentedI've been thinking about adding this option for awhile. It'll get in sooner or later.
Comment #2
haagendazs commentedIceCreamYou and d0t101101:
I provided a patch that adds this functionality for menu items and any other blocks except for the "Alerts" block. The patch adds an additional setting to the Appbar settings page (admin/settings/appbar). I left the default at "open on click", so you need to change this setting to "Open appbar blocks on hover" to see the changes. The patch needs to be applied from the appbar module directory itself.
I haven't changed the functionality for the "Alerts" block yet, as this block functions differently. It's the only block in the appbar that has an icon in the appbar to open and close instead of the "minimize" link at the top of the opened window.
IceCreamYou: What do you think about creating a standard way for closing appbar blocks instead of having two different feature sets?
Looking forward to your feedback!
Comment #3
d0t101101 commentedYou rock haagendazs!
Tested your patch, and it does work. My appbar has about 9 blocks implemented through a custom module, and a custom appbar theme. If I quick scroll across the bar, I can sometimes make multiple blocks stay expanded. Theres no consistency with this though, making it hard to diagnose.
If I scroll over them slowly, however, everything works correctly. Wondering if it might be something with my CSS. Any thoughts?
Best regards,
.
Comment #4
icecreamyou commentedAttached is a patch that implements this feature more cleanly.
The differences from a functional perspective include:
From a code perspective, the implementations are substantially different.
@haagendazs: Since you submitted this patch by my request as part of your effort to become a co-maintainer, I will respond to it via email.
@d0t101101: Please test this patch. If it works, set this issue to RTBC and I will commit it as soon as I can.
Comment #5
d0t101101 commentedTested, and it works well.
The jquery slide up effect is a bit 'heavy', and can be distracting if all of the blocks are set to expand on hover. With 9 hover over blocks on my sites appbar, a quick swipe makes them all animate up/down and system CPU hits 100%. I suggest adding an admin option to select the animation (ie slideup slow/slideup fast/fade/none). Personally I would prefer no animation at all. This way, those that have other hover over menus can make the new feature match their sites existing navigation. Another useful option might be a delay before expansion... Just a thought.
Otherwise, this is great, thanks for adding this feature! Waiting for your feedback before marking this patch as RTBC.
.
Comment #6
d0t101101 commentedI've noticed that if you quickly scroll up/down over one item in the appbar many times with hover enabled, the delay in the jquery effect causes the window to continue to open/close repeatedly.
Maybe the default should be no animation...
.
Comment #7
icecreamyou commentedI have 4 Core i7 processors @ 2.67GHz and I'm using FF3.6.10, so I wouldn't notice any performance hit -- but that animation is only 200ms and it's pretty standard and fast. I wouldn't expect any slowdown unless you're running IE6 on WinXP on old hardware.
When you quickly move your mouse over/off any hover item anywhere on the internet that has an animation, it will open and close repeatedly for awhile. This is how it's supposed to behave. It executes the open/close code every time you hover on/off, so if you hover on/off lots of times, it will execute that code lots of times.
There is a jQuery plugin called hoverIntent that basically adds a pause before executing hover actions. If you want you can override the JS in Appbar to use that instead. Actually, I will add support for it before I commit the patch but I won't add it as a dependency. (You will need the plugin loaded on your site for this to work -- there is a module that is supposed to do that.)
Adding an option to select the animation is overkill. 99.9% of people will never use it, and more people will be confused by it than will find it useful. Having no animation looks crappy, and it's surprising when stuff suddenly appears; animation makes it clear what happened and why. And the current animation can be overridden just as easily as no animation.
Honestly, IMHO the hover thing is pretty obnoxious, and you should expect all of the usual minor problems if you choose to use it (the two main ones being performance in older browsers and weird behavior when you move the mouse around quickly). If you expect your users to be moving their mouse quickly across the bottom of the screen and you don't like it that a bunch of stuff pops open when that happens, you might want to think harder about why you're really using the hover state. And 9 hover blocks might be a little excessive.
Comment #8
d0t101101 commentedActually dual core 1.8ghz and Chrome/Firefox on Ubuntu. Dated but not antiquated, at the moment :) I can mod our sites JS for our particular requirements, but still wanted to share my suggestions for other potential use cases. From a theme-ability perspective this option creates a way to more easily implement other effects. Personally I prefer no animation and maximum speed when navigating a website, or even an application, that this feature would provide. The other consideration is mobile platforms, that have major CPU limitations.
I'll definitely share my custom JS override when time permits. I'm building a website around your API and module for the navigation, and will do my best to contribute however possible..
Appbar rocks ICY ;)
Best regards,
.
Comment #9
icecreamyou commentedHmm, very strange that you would have performance problems then. Interesting. Will have to investigate that further at some point then.
Interesting that you point out mobile as well -- AFAIK the hover state doesn't exist on most mobile browsers.
I'm sure others will appreciate sharing your overrides. :-)
Comment #10
d0t101101 commentedInteresting you mentioned the mobile hover state issue, too :) Android renders appbar just fine, but iPhone is picky. It renders the appbar with a static location, and judging by what you mentioned most others do too. Since the latest DEV update/hover effect changes, i've managed to crash the safari browser while browsing my site... Just an FYI, will see if I can narrow down a pattern.
Comment #11
geerlingguy commentedMarking this issue for testing - I'd be interested in this, as long as it's a configurable option :)
Comment #12
icecreamyou commentedCommitted to dev. Let me know if you have any serious problems. Thanks for the help
Comment #13
btopro commentedI'm seeing a huge performance hit on some pages post upgrade from Sep dev to latest dev. MBP like a year old. Performance issue seems to occur on long pages and only on the animation of the menu sliding open or closed.
Comment #14
icecreamyou commentedI mean, if you switched your blocks to hovering it's going to seem a little slower because the show/hide behavior is going to happen more often. This is the only relevant JS difference. You can try using the older version and see if it makes any difference, but the sliding motion was actually using the same effect; the only difference was that the "hover" setting wasn't supported. I've also attached a version that uses toggle() instead of slideToggle() and hide() instead of slideDown(). IMO that's a usability sacrifice but it might be marginally faster.
Also, browser and browser version are important for things like this...
Comment #15
btopro commentedwasn't using Hover.
To help with page load somewhat I was able to do the following though --
If you kill off this function --
$('.appbar-block-popup,.appbar-block-hover').each(function(index) {
//The -1 is a cheap hack to make this look better when the border is 1px.
var leftPos = $(this).offset().left - 1;
$(this).find('.appbar-block-content').css('left', leftPos);
});
and instead do absolute positioning in place of fixed, the click to pop-up blocks will still display in the correct location and will work correctly when resizing the browser window after page-load
here's my css for my appbar-block-content
.appbar-block-popup .appbar-block-content {
background-color: #FFFFFF;
border: 1px #B5B5B5 solid;
bottom: 25px;
display: none;
margin-bottom: 0px !important;
margin-left: -1px;
max-height: 450px !important;
min-height: 25px !important;
overflow-x: hidden;
overflow-y: auto;
position: absolute;
margin-right:0px;
padding:0px;
width:135px !important;
z-index: 51;
}
Comment #16
icecreamyou commentedThat code runs once. It would not be slowing your page down.
Comment #17
btopro commentedwell, it loads faster on initial render