0

ページを上下に移動するとサイズが変更されるナビゲーション バーがあります。ページの上部では、縮小するべきではありませんが、縮小します。ユーザーがページの上部にいるかどうかを確認し、ナビゲーション バーを縮小しないようにする必要があります。コードは次のとおりです。

<script type="text/javascript">
     $('#brand_logo').on('inview mouseenter', function(event, visible) {
    if (visible === true) {
         console.log("I got my eye on it Charlie");
        $("#topnav").animate({
            opacity: 1.0,
            width: '98%',
            height: '38px'
        });
        // $(".head-wrap-left").hide();
    } else {
         console.log("Let's set the mood.");

        $("#topnav").animate({
            opacity: 0.9, //0.6 original
              width: '310px',
              height: '33px'

        });
        $("#topnav_behind").slideUp();

        $('#topnav').bind({
                    mouseenter: function() {
                        $("#topnav").animate({opacity: 1.0, width: '98%', height: '38px'});
                    },
                    mouseleave: function() {
                           $("#topnav").animate({opacity: 0.9, width: '310px', height: '33px'});
                    }
                    });
        }});


</script>
4

1 に答える 1

0

重複の可能性: https://stackoverflow.com/a/473010/1250044

$.extend($.expr[':'], {
    inView: function(a) {
        var st = (document.documentElement.scrollTop || document.body.scrollTop),
            ot = $(a).offset().top,
            wh = (window.innerHeight && window.innerHeight < $(window).height()) ? window.innerHeight : $(window).height();
        return ot > st && ($(a).height() + ot) < (st + wh);
    }
});
于 2012-09-27T16:23:01.313 に答える