I have written some test code, which does what it's meant to do, but I
think it isn't in the right place..
 
I have added this code to the default options block of superfish.js:
 
   autofitX    : true,
   autofitY    : true,

And this code instead of the original showSuperfishUl part:
 
   showSuperfishUl : function(o){
    return this
     .addClass(o.hoverClass)
     .find('>ul:hidden')
      .css('visibility','visible')
      .animate(o.animation,o.speed,function(){
       o.onshow.call(this);
       if (o.autofitY) {
        var menuHeight = $ul.height();
        var expandUp = ($ul.offset().top + menuHeight >
$(window).height());
        if (expandUp) $ul.css("margin-top",($(window).height() -
menuHeight - $ul.offset().top) + "px");
       }
      })
      .each(function(){
       $ul = $(this);
       if (o.autofitX) {
        var menuWidth = $ul.width();
        var parentWidth = $ul.parents('ul').width();
        var expandLeft = ($ul.offset().left + menuWidth >
$(window).width());
        if (expandLeft) $ul.css("margin-left","-" + (menuWidth +
parentWidth) + "px");
       }
      })
     .end();
   },

This works, however, I don't think it's the correct place to perform
these actions. Any opinions?

________________________________

From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Jesse Klaasse
Sent: Wednesday, January 02, 2008 4:25 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Superfish feature request
Importance: Low


I am thoroughly enjoying the Superfish menu.. However, I would love to
see the following option: when a submenu falls outside of the window,
it's position should be adapted in order to fit. Just like most
operating systems handle menus when they don't fit.. Would this be
possible? It could be called something like 'forceFit' or so.. Thanks in
advance!
 
(The simplest approach would probably be to check if a <ul>'s offset
left plus it's width exceeds the window width, and adjust x position
accordingly.. Likewise, this could be done for the vertical position)

Reply via email to