Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
Posts Page in React js

I have posts page every post have id . how i can listen to scroll and save the current post_id that user can start where he left off ?

I wont to make thing like this : onUserSeePost : post postId to back_end

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Your question is not clear, Kindly add some code.

Add a scroll event listener. Store the scroll location in the localstorage, When the user returns to the page scroll him back to the location

//Event listener to store the scroll position
addEventListener("scroll", function (e) {
  // Get the new Value
  var newValue = e.target.scrollTop;
  //Subtract the two and conclude
  if (oldValue - newValue < 0) {
    console.log("down");
  } else if (oldValue - newValue > 0) {
    console.log("up");
  }
  // Update the old value
  oldValue = newValue;
});

//scroll him back
function scrollMe() {
  el.scrollTop = localStorage.getItem("myscroll");
}
about 4 years ago · Juan Pablo Isaza Relatório

0

I don't know if I get the idea, for what you want to do, but if you want to be in the exact same position where the user left the scroll bar you could use the property of the window window.scrollY, you can see an example here, but I think you don't need a event handler, maybe you could use the localStorage API to do the trick, save that position then just check if there is some position saved in the localStorage and just do something like:

window.scrollY = 700 <= value in pixels, from where is going to be the scroll bar in the Y axis on the document.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda