标题滚动问题

时间:2016-12-01 13:39:37

标签: javascript php css

这是一个wordpress网站,当我向下滚动时,我有一个标题的问题,你可以在第一个图像中看到标题是透明的,然后一旦我向下滚动有一个glicth,标题闪烁,同时向下滚动背景,实际上背景应该只在我们向上滚动时出现, 请检查链接,然后尝试快速滚动页面,您会看到标题中的闪烁:enter image description here

代码:`

<script type="text/javascript">
var mywindow = $(window);
var mypos = mywindow.scrollTop();
var up = false;
var newscroll;
mywindow.scroll(function () {
    newscroll = mywindow.scrollTop();
    if (newscroll > mypos && !up) {
        $('.header2').stop().slideToggle();
        up = !up;
        console.log(up);
    } else if(newscroll < mypos && up) {
        $('.header2').stop().slideToggle();
        up = !up;
    }
    mypos = newscroll;
});
</script>
 <script type="text/javascript">
jQuery(window).scroll(function() {    
    var scroll = jQuery(window).scrollTop();

    if (scroll > 300) {
        jQuery(".header2").addClass("dark");
    } else {
        jQuery(".header2").removeClass("dark");
    }
});
</script> 
.dark {
    background: #323232;
    position: fixed!important;
    border-bottom: none!important;
    margin: 0px; 
}
.site-logo {
    float: left!important;
    padding: 20px!important;
    margin-top: 0px!important;
    z-index: 999!important;
    position: relative!important;
    width: 200px!important;
}
<div id="contain">
<div class="fixed-header">
  <div class="header2">
  <?php if(true === get_theme_mod('show_topbar')){ ?>
  <div class="fulltop">
  <div class="wrap"><div class="pm-left"><?php echo ( get_theme_mod( 'topbar_text' ) ); ?></div><div class="pm-right social"><?php my_social_media_icons(); ?></div></div>
  </div>
  <?php }?>
  <div class="wrap">
<?php if ( get_theme_mod( 'themeslug_logo' ) ) : ?>

.........
</div>
</div>

`

请帮助

0 个答案:

没有答案