jQuery滚动窗口关闭后窗口

时间:2016-10-11 09:05:01

标签: javascript jquery

我需要关闭窗口,以便从启动页面到家中运行淡出动画。 但是在家里我需要窗口,为了在滚动中添加一个类,然后我用它来改变标题。 这段代码不起作用:

$(window).ready(function(){
    $(this).one('scroll', function() { 
        $(window).off("scroll"); 
        $(".splash").slideUp("800", function() {
            $("html, body").animate({"scrollTop":"0px"},100);
            $(".site").delay(100).animate({"opacity":"1.0"},800);
            $("html, body").on("scroll")
        });
    });
});

可以帮我找到解决方案吗?谢谢!

如果需要,这是我用于添加类的代码:

$(document).ready(function( $ ) {
    $(window).scroll(function() {
        var sT = $(this).scrollTop();
        if (sT >= 200) {
            $('header').addClass('scroll-header')
        } else {
            $('header').removeClass('scroll-header')
        }
    });
});

HTML:

<body <?php body_class(); ?>>
 <div class="show_splash">
    <div class="splash fade-in">
        <?php
            $post_id = 93;
            $queried_post = get_post($post_id);
            echo $queried_post->post_content;
        ?>

    </div>
</div>
<div id="page" class="site">
    <header id="masthead" class="site-header cf" role="banner">

CSS:

.cf:before,
.cf:after {
  content: " ";
  /* 1 */
  display: table;
  /* 2 */ }

.cf:after {
  clear: both; }

.cf {
  *zoom: 1; }

.bk_splash{
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
}

1 个答案:

答案 0 :(得分:0)

最后我尝试不使用滚动关闭,并使用简单的

进行更改
.show_splash{position: fixed;}

通过这种方式很好地工作!!!

相关问题