jquery SlideDown SlideUp 揭开
我想知道是否有人可以帮助我指出正确的方向。
我正在使用动态驱动器的幻灯片菜单: http://www.dynamicdrive.com/style/csslibrary/item/jquery_multi_level_css_menu_2/
我已经修改了它,所以它不是一个下拉菜单,而是一个下拉菜单。
我遇到的问题是,对于下拉效果,它使用 jquerys .slideDown 来发现子菜单,并使用 .slideUp 来隐藏子菜单。
现在对于下拉效果来说这一切都很好,但是对于下拉效果来说,slideDown 会从上到下显示菜单栏。 请参阅此处查看正在发生的情况的示例。
http://www.falkenkitchens.com/index.php
我在 jquery 文档上读到SlideDown/slideUp 基本上会揭开内容,我可以用什么来反向揭开子菜单?所以它从下到上都被覆盖了?
非常感谢任何想法,我不是 js/jquery 专家,但如果指向正确的方向,我也许能够实现这一目标。
脚本如下:
var jqueryslidemenu={
animateduration: {over: 200, out: 100}, //duration of slide in/ out animation, in milliseconds
buildmenu:function(menuid, arrowsvar){
jQuery(document).ready(function($){
var $mainmenu=$("#"+menuid+">ul")
var $headers=$mainmenu.find("ul").parent()
$headers.each(function(i){
var $curobj=$(this)
var $subul=$(this).find('ul:eq(0)')
this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
this.istopheader=$curobj.parents("ul").length==1? true : false
$subul.css({top:this.istopheader? -this._dimensions.subulh+"px" : -this._dimensions.subulh+this._dimensions.h})
$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: arrowsvar.down[2]} : {}).append(
'<img src="'+ (this.istopheader? arrowsvar.down[1] : arrowsvar.right[1])
+'" class="' + (this.istopheader? arrowsvar.down[0] : arrowsvar.right[0])
+ '" style="border:0;" />'
)
$curobj.hover(
function(e){
var $targetul=$(this).children("ul:eq(0)")
this._offsets={left:$(this).offset().left, bottom:$(this).offset().bottom}
var menuleft=this.istopheader? 0 : this._dimensions.w
menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
if ($targetul.queue().length<=1) //if 1 or less queued animations
$targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).slideDown(jqueryslidemenu.animateduration.over)
},
function(e){
var $targetul=$(this).children("ul:eq(0)")
$targetul.slideUp(jqueryslidemenu.animateduration.out)
}
) //end hover
$curobj.click(function(){
$(this).children("ul:eq(0)").hide()
})
}) //end $headers.each()
$mainmenu.find("ul").css({display:'none', visibility:'visible'})
}) //end document.ready
}
}
Am wondering if someone can help point me in the right direction.
I'm using a slide menu i got of dynamic drive:
http://www.dynamicdrive.com/style/csslibrary/item/jquery_multi_level_css_menu_2/
I have modified it so rather than being a drop down menu it drops up.
the problem i am having is that for the drop-up effect it uses jquerys .slideDown to uncover the sub-menu and .slideUp to hide the submenu.
now for a dropdown effect this is all well and good, but for a drop up the slideDown uncovers the menu from the top down to the menu bar.
see here for an example of whats happening.
http://www.falkenkitchens.com/index.php
i read on the jquery docs that the slideDown/slideUp basicaly uncovers the content, what can i use to reverse uncover the sub menu? so it gets uncovered from bottom to top?
any ideas greatly appreciated, i am not a js/jquery expert but if pointed in the right direction i might be able to get this working.
the script is below:
var jqueryslidemenu={
animateduration: {over: 200, out: 100}, //duration of slide in/ out animation, in milliseconds
buildmenu:function(menuid, arrowsvar){
jQuery(document).ready(function($){
var $mainmenu=$("#"+menuid+">ul")
var $headers=$mainmenu.find("ul").parent()
$headers.each(function(i){
var $curobj=$(this)
var $subul=$(this).find('ul:eq(0)')
this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
this.istopheader=$curobj.parents("ul").length==1? true : false
$subul.css({top:this.istopheader? -this._dimensions.subulh+"px" : -this._dimensions.subulh+this._dimensions.h})
$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: arrowsvar.down[2]} : {}).append(
'<img src="'+ (this.istopheader? arrowsvar.down[1] : arrowsvar.right[1])
+'" class="' + (this.istopheader? arrowsvar.down[0] : arrowsvar.right[0])
+ '" style="border:0;" />'
)
$curobj.hover(
function(e){
var $targetul=$(this).children("ul:eq(0)")
this._offsets={left:$(this).offset().left, bottom:$(this).offset().bottom}
var menuleft=this.istopheader? 0 : this._dimensions.w
menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
if ($targetul.queue().length<=1) //if 1 or less queued animations
$targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).slideDown(jqueryslidemenu.animateduration.over)
},
function(e){
var $targetul=$(this).children("ul:eq(0)")
$targetul.slideUp(jqueryslidemenu.animateduration.out)
}
) //end hover
$curobj.click(function(){
$(this).children("ul:eq(0)").hide()
})
}) //end $headers.each()
$mainmenu.find("ul").css({display:'none', visibility:'visible'})
}) //end document.ready
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 jQuery UI (您必须将其包含在 jQuery 文件之后) - 即
$(this).hide ("slide", { 方向: "向下" }, 1000);
或$(this).show("slide", { 方向: "向上" }, 1000);
示例 http://docs.jquery.com/UI/Effects/Slide
use the jQuery UI (you have to include it after the jQuery file) - ie
$(this).hide("slide", { direction: "down" }, 1000);
or$(this).show("slide", { direction: "up" }, 1000);
example http://docs.jquery.com/UI/Effects/Slide