2010-04-23 7 views
1

Ceci est le code jquery pour le plugin menu superfish (après quelques révisions de la mienne). Je cherche à ajouter un effet (via superfish ou accidentellement) qui ferait glisser les sous-menus vers le haut au passage du curseur de la souris (tout comme ils glissent vers le bas lorsque vous survolez un menu-dessus).Menu Jquery Superfish - Comment glisser vers le haut?

jQuery("ul.sf-menu").supersubs({ 
     minWidth: 12,        // minimum width of sub-menus in em units 
     maxWidth: 27,        // maximum width of sub-menus in em units 
     extraWidth: 1         // extra width can ensure lines don't sometimes turn over 
                 // due to slight rounding differences and font-family 
    }).superfish({ 
     delay:  700,        // delay on mouseout 
     animation: {opacity:'show',height:'show'}, // fade-in and slide-down animation 
     speed:  'fast',       // faster animation speed 
     autoArrows: true,        // disable generation of arrow mark-up 
     dropShadows: false        // disable drop shadows 
    }); 

Répondre

2

Vous ne pouvez pas, actuellement. Droit du code:

hideSuperfishUl : function(){ 
    var o = sf.op, 
    not = (o.retainPath===true) ? o.$path : ''; 
    o.retainPath = false; 
    var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass) 
     .find('>ul').hide().css('visibility','hidden'); 
    o.onHide.call($ul); 
    return this; 
}, 
showSuperfishUl : function(){ 
    var o = sf.op, 
    sh = sf.c.shadowClass+'-off', 
    $ul = this.addClass(o.hoverClass) 
     .find('>ul:hidden').css('visibility','visible'); 
    sf.IE7fix.call($ul); 
    o.onBeforeShow.call($ul); 
    $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); }); 
    return this; 
} 

Vous pouvez voir que la fonction appelle spectacle Animer(), alors que la fonction cache appelle simplement cacher().

0

Toutefois, vous pouvez le faire fonctionner en piratant le code. Je soumettrais un correctif mais le développement de code n'est pas hébergé publiquement.

hideSuperfishUl : function(){ 
      var o = sf.op, 
       not = (o.retainPath===true) ? o.$path : ''; 
      o.retainPath = false; 
      var $ul = $(['li.',o.hoverClass].join(''),this) 
       .add(this) 
       .not(not) 
       // .removeClass(o.hoverClass) 
       .find('>ul').animate({opacity: 'hide', height: 'hide'}, o.speed, function(){ sf.IE7fix.call($ul); o.onShow.call($ul); }); 
      o.onHide.call($ul); 
      return this; 
     }, 
-1

bonne façon de réaliser la tâche de cacher superfish même que montrant:

hideSuperfishUl : function(){ 
     var o = sf.op, 
     not = (o.retainPath===true) ? o.$path : ''; 
     o.retainPath = false; 
     //hacked code by Farhan Wazir (Seejee) 
    var $ul_p1 = $(['li.',o.hoverClass].join(''),this).add(this).not(not); 
    var $ul_p2 = $ul_p1.find('>ul'); 
    var $ul = $ul_p2.animate({opacity: 'hide', height: 'hide'}, o.speed, 
     function(){ return $ul_p1.removeClass(o.hoverClass).find('>ul').css({top: '-99999em'}).addClass('sf-hidden');}); 
     o.onHide.call($ul); 
     return this; 
}, 
1

Je ne sais pas sur les anciennes versions de superfish mais cela est maintenant facilement accompli (slideDown et slideUp) - comme si

$('...').superfish({ 
    hoverClass: 'sfhover',   // the class applied to hovered list items 
    animation:  {height: "show", marginTop: "show", marginBottom: "show", paddingTop: "show", paddingBottom: "show"}, // an object equivalent to first parameter of jQuery’s .animate() method. Used to animate the submenu open 
    animationOut: {height: "hide", marginTop: "hide", marginBottom: "hide", paddingTop: "hide", paddingBottom: "hide"}, // an object equivalent to first parameter of jQuery’s .animate() method Used to animate the submenu closed 
}); 
Questions connexes