Flicker scrolling problem (Safari/Firefox) for a fixed logo












0















I'm trying to overcome a flickering problem that occurs just in Safari/Firefox (not Chrome). I have a long page scroll, a fixed position logo that after a transition to the next section change with an absolute position logo that behaves like a fixed through jquery (you can have a look here).
The problem is that jquery it is calculating it's offset top while scrolling but seems it is not being able to keep up with the scroll and the logo flickers a lot.



What it looks if checking with inspector it's that the position it is changing but for some reason not at the same pace of the scrolling.



I also tried a different solution using .css(transform, traslateY()) instead of .css("top") (ex here) but still shows the same result.



The code:



<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>




function logoSwitch () {
$('.altLogo').each(function() {

var diff = $(".startLogo, .postLogo").offset().top - $(this).closest('.row').offset().top ;

$(this).css('top' , '0px')
$(this).css('-webkit-transform' , 'translateY(' + diff + 'px)')

});
};

$(document).scroll(function() {logoSwitch();});

logoSwitch();


* {
padding: 0px;
margin: 0;
}

.rowstart {
min-height: 200vh;
overflow: hidden;
position: relative;
width: 100%;
background-color:
rgba(0,110,220,0.4);

}
.row {
min-height: 200vh;
overflow: hidden;
position: relative;
width: 100%;
}

.blu {
color: rgba(0,110,220,1);
}

.azul {
background: #E8F2FC;
}

.logo {
font-family: "Europa-Bold";
font-size: 50px;
top: 20px;
left: 20px;
line-height:100%;
text-align: left;
height:60px;
}

.startLogo {
position: fixed;
}

.altLogo {
position: absolute;
-webkit-will-change:transform;
}

.white {
color: white;
}


<div class="rowstart">

<div class="logo white startLogo">GIVE A SHIT <br>
<div class="mission">
MISSION
</div>
</div>


</div>


<div class="row azul">

<h1 class="logo blu altLogo">GIVE A SHIT <br>
WATER
</h1>


</div>











share|improve this question





























    0















    I'm trying to overcome a flickering problem that occurs just in Safari/Firefox (not Chrome). I have a long page scroll, a fixed position logo that after a transition to the next section change with an absolute position logo that behaves like a fixed through jquery (you can have a look here).
    The problem is that jquery it is calculating it's offset top while scrolling but seems it is not being able to keep up with the scroll and the logo flickers a lot.



    What it looks if checking with inspector it's that the position it is changing but for some reason not at the same pace of the scrolling.



    I also tried a different solution using .css(transform, traslateY()) instead of .css("top") (ex here) but still shows the same result.



    The code:



    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>




    function logoSwitch () {
    $('.altLogo').each(function() {

    var diff = $(".startLogo, .postLogo").offset().top - $(this).closest('.row').offset().top ;

    $(this).css('top' , '0px')
    $(this).css('-webkit-transform' , 'translateY(' + diff + 'px)')

    });
    };

    $(document).scroll(function() {logoSwitch();});

    logoSwitch();


    * {
    padding: 0px;
    margin: 0;
    }

    .rowstart {
    min-height: 200vh;
    overflow: hidden;
    position: relative;
    width: 100%;
    background-color:
    rgba(0,110,220,0.4);

    }
    .row {
    min-height: 200vh;
    overflow: hidden;
    position: relative;
    width: 100%;
    }

    .blu {
    color: rgba(0,110,220,1);
    }

    .azul {
    background: #E8F2FC;
    }

    .logo {
    font-family: "Europa-Bold";
    font-size: 50px;
    top: 20px;
    left: 20px;
    line-height:100%;
    text-align: left;
    height:60px;
    }

    .startLogo {
    position: fixed;
    }

    .altLogo {
    position: absolute;
    -webkit-will-change:transform;
    }

    .white {
    color: white;
    }


    <div class="rowstart">

    <div class="logo white startLogo">GIVE A SHIT <br>
    <div class="mission">
    MISSION
    </div>
    </div>


    </div>


    <div class="row azul">

    <h1 class="logo blu altLogo">GIVE A SHIT <br>
    WATER
    </h1>


    </div>











    share|improve this question



























      0












      0








      0








      I'm trying to overcome a flickering problem that occurs just in Safari/Firefox (not Chrome). I have a long page scroll, a fixed position logo that after a transition to the next section change with an absolute position logo that behaves like a fixed through jquery (you can have a look here).
      The problem is that jquery it is calculating it's offset top while scrolling but seems it is not being able to keep up with the scroll and the logo flickers a lot.



      What it looks if checking with inspector it's that the position it is changing but for some reason not at the same pace of the scrolling.



      I also tried a different solution using .css(transform, traslateY()) instead of .css("top") (ex here) but still shows the same result.



      The code:



      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>




      function logoSwitch () {
      $('.altLogo').each(function() {

      var diff = $(".startLogo, .postLogo").offset().top - $(this).closest('.row').offset().top ;

      $(this).css('top' , '0px')
      $(this).css('-webkit-transform' , 'translateY(' + diff + 'px)')

      });
      };

      $(document).scroll(function() {logoSwitch();});

      logoSwitch();


      * {
      padding: 0px;
      margin: 0;
      }

      .rowstart {
      min-height: 200vh;
      overflow: hidden;
      position: relative;
      width: 100%;
      background-color:
      rgba(0,110,220,0.4);

      }
      .row {
      min-height: 200vh;
      overflow: hidden;
      position: relative;
      width: 100%;
      }

      .blu {
      color: rgba(0,110,220,1);
      }

      .azul {
      background: #E8F2FC;
      }

      .logo {
      font-family: "Europa-Bold";
      font-size: 50px;
      top: 20px;
      left: 20px;
      line-height:100%;
      text-align: left;
      height:60px;
      }

      .startLogo {
      position: fixed;
      }

      .altLogo {
      position: absolute;
      -webkit-will-change:transform;
      }

      .white {
      color: white;
      }


      <div class="rowstart">

      <div class="logo white startLogo">GIVE A SHIT <br>
      <div class="mission">
      MISSION
      </div>
      </div>


      </div>


      <div class="row azul">

      <h1 class="logo blu altLogo">GIVE A SHIT <br>
      WATER
      </h1>


      </div>











      share|improve this question
















      I'm trying to overcome a flickering problem that occurs just in Safari/Firefox (not Chrome). I have a long page scroll, a fixed position logo that after a transition to the next section change with an absolute position logo that behaves like a fixed through jquery (you can have a look here).
      The problem is that jquery it is calculating it's offset top while scrolling but seems it is not being able to keep up with the scroll and the logo flickers a lot.



      What it looks if checking with inspector it's that the position it is changing but for some reason not at the same pace of the scrolling.



      I also tried a different solution using .css(transform, traslateY()) instead of .css("top") (ex here) but still shows the same result.



      The code:



      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>




      function logoSwitch () {
      $('.altLogo').each(function() {

      var diff = $(".startLogo, .postLogo").offset().top - $(this).closest('.row').offset().top ;

      $(this).css('top' , '0px')
      $(this).css('-webkit-transform' , 'translateY(' + diff + 'px)')

      });
      };

      $(document).scroll(function() {logoSwitch();});

      logoSwitch();


      * {
      padding: 0px;
      margin: 0;
      }

      .rowstart {
      min-height: 200vh;
      overflow: hidden;
      position: relative;
      width: 100%;
      background-color:
      rgba(0,110,220,0.4);

      }
      .row {
      min-height: 200vh;
      overflow: hidden;
      position: relative;
      width: 100%;
      }

      .blu {
      color: rgba(0,110,220,1);
      }

      .azul {
      background: #E8F2FC;
      }

      .logo {
      font-family: "Europa-Bold";
      font-size: 50px;
      top: 20px;
      left: 20px;
      line-height:100%;
      text-align: left;
      height:60px;
      }

      .startLogo {
      position: fixed;
      }

      .altLogo {
      position: absolute;
      -webkit-will-change:transform;
      }

      .white {
      color: white;
      }


      <div class="rowstart">

      <div class="logo white startLogo">GIVE A SHIT <br>
      <div class="mission">
      MISSION
      </div>
      </div>


      </div>


      <div class="row azul">

      <h1 class="logo blu altLogo">GIVE A SHIT <br>
      WATER
      </h1>


      </div>








      jquery fixed absolute






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 0:43







      Lorenzo Scodeller

















      asked Nov 25 '18 at 23:11









      Lorenzo ScodellerLorenzo Scodeller

      33




      33
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53472944%2fflicker-scrolling-problem-safari-firefox-for-a-fixed-logo%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53472944%2fflicker-scrolling-problem-safari-firefox-for-a-fixed-logo%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'