开发者

jquery slideDown slideUp to uncover

开发者 https://www.devze.com 2023-04-05 19:35 出处:网络
A开发者_开发百科m wondering if someone can help point me in the right direction. I\'m using a slide menu i got of dynamic drive:

A开发者_开发百科m 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
    }
    }


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号