D
D
DeveloperV2020-05-10 14:37:16
JavaScript
DeveloperV, 2020-05-10 14:37:16

Why doesn't javascript work on a small screen resolution?

var header = $("#header"),
  introH = $("#intro").innerHeight(),
  scrollOffset = $(window).scrollTop();

/* Fixed Header */
checkScroll(scrollOffset);

$(window).on("scroll", function () {
  scrollOffset = $(this).scrollTop();

  checkScroll(scrollOffset);
});

function checkScroll(scrollOffset) {
  if (scrollOffset >= introH) {
    header.addClass("fixed");
  } else {
    header.removeClass("fixed");
  }
}

Everything works, when you click on the About menu , a fixed header appears after the .intro block, but as soon as I turn on the adaptive 5eb7e40f84fdf188536131.png, the height of the visible area decreases and the header appears much lower. How can this be fixed? https://varfolomeiq.github.io/mogo/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2020-05-10
@developerV

introH is calculated once when loading the script, you change the height resolution - introH remains at the initial value, calculate it every time anew in checkScroll

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question