Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!