Js make a smooth scroll

I seriously have a question about the scroll event. I tried to solve this problem all night, but I could not.

I am trying to use top navigation. The stick effect will be processed when the $(window).scrollTop()point is transmitted right before navigation.

The problem is that IE and Chrome will have a “blinking effect” (like a delay process), but not on Firefox.

During my research, I knew that Firefox has a "smooth scroll" by default.

However, please check this example in Chrome or IE.

http://www.backslash.gr/demos/jquery-sticky-navigation/

It's as smooth as on Firefox, and the code is just that ...

The fact is that I am doing the same thing as in this example, but why do I have a "blink" effect?

Is CSS a trick?

Is there a way that I can create a smooth scrool like that on firefox js ??

Many thanks for your help.

$(window).on('scroll', Sticky);

function Sticky(){
    $(this).scrollTop() > anchor.offset().top
    ? nav.css({ 'position': 'fixed', 
                      'z-index': z_index, 
                       top: y, 
                       left: x, })
    : nav.css({ 'position': 'static', });
};
+5
source share
2 answers

Looking at an incomplete code example, it is very difficult to determine what is happening, so please either update your question with the full code, or better, download JSFiddle to serve as an example, and we can directly update it with the necessary changes. So far (based on what I said earlier), it looks like you get the effect flickeringdue to typos in your code example :

? nav.css({ 'position': 'fixed', 
                  'z-index': z_index, 
                   top: y, 
                   left: x, })
: nav.css({ 'position': 'static', });

CSS, ( ,), CSS '. :

? nav.css({ 'position': 'fixed', 
                  'z-index': z_index, 
                   'top': y, 
                   'left': x })
: nav.css({ 'position': 'static' });

, z_index, y x.

: JSFiddle -. , , , , , , , . , JSFiddle, . , , . , . , - ( ).;)

+1

, .

  • , . , IE firefox .
  • , . js, , .

, , , . js , .

. .

+1

All Articles