moxystudio / next-router-scroll Goto Github PK
View Code? Open in Web Editor NEWTake control of when scroll is updated and restored in your Next.js projects.
License: MIT License
Take control of when scroll is updated and restored in your Next.js projects.
License: MIT License
https://github.com/vercel/next.js/pull/13914/files#diff-5eff10c96fa6858c659318492c4cf7f7
It seems that the X and Y coordinates are being stored in the router state, meaning perhaps we can leverage those instead of saving into the local storage.
Hi there team!
Your package here is stupendous and valuable, so thank you for your hard work! This topic is, somehow, not super easy for some reason. You'd think, the browser should just do its thing and โ ?
A common use case that I ran into is waiting for a specific element to render before updateScroll
is called. I read over the README and I read over your tests (thanks for adding those!). Unfortunately, I couldn't quite piece together just "how" registering an element would allow me to "wait for it to render" before updating scroll.
So what I did instead was use the update ref
pattern that React outlines here.
My implementation ended up looking a little like this:
const MyComponent = () => {
const divRef = useCallback(
(node) => {
if (node !== null) {
updateScroll();
}
},
[updateScroll]
);
return (
<div ref={divRef}>hi</div>
);
}
This ended up working pretty well for me, and allowed me to explicitly wait for a node to appear before updating scroll.
The reason I'm opening this issue, is I'm wondering if the README could be more clear about how to use registerElement
and updateScroll
together. If the intended use case for those is not similar to the above implementation, would it be valuable to add an example that showed how to do something like this?
Thanks again for all your hard work!
Please tell me about the plan to open the declaration file for typescript user.
If you don't have any plan for now, then can I pull request the declare file?
Thank you for your attention.
Will next-router-scroll
be updated so it is compatible with Next.js version 12? Currently peer and dev dependencies are atmost version 11.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.