Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // IMPROVE WORDPRESS DROPDOWN MAIN MENU WITH SOME DELAY, USING superfish.js JQUERY PLUGIN
- // MAIN MENU FINETUNING
- var maxWidth = $('#header').width() + $('#header').offset().left;
- var menu, menuWidth, delta, menuLeft = 0;
- $('#menu-main-menu').superfish({
- autoArrows: false,
- speed: 'fast',
- hoverClass: 'selected-menu',
- onInit: function() {
- // Make sure the rightmost dropdown does not overflow the interface
- $('#menu-main-menu ul.sub-menu').each(function(){
- menu = $(this);
- menuWidth = menu.width();
- menu.show(); // offset() does not work if element is hidden, so we show(), measure, then hide() it immediatly.
- menuLeft = menu.offset().left;
- menu.hide();
- delta = maxWidth - (menuLeft + menuWidth);
- if (delta < 0) {
- menuLeft = delta;
- } else {
- menuLeft = 0;
- }
- menu.css({
- left: menuLeft
- });
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement