some-react-components / react-scrollchor

A React component for scroll to `#hash` links with smooth animations
ISC License
149 stars 24 forks source link

is there any way to use this in conjunction with react router? #4

Closed chrisdobler closed 8 years ago

chrisdobler commented 8 years ago

If the anchor is on a different page, is there any way to have it trigger the router?

bySabi commented 8 years ago

Before create this component I make another https://github.com/bySabi/react-router-hash-scroll that do the same on top of react-router Link. The time passed and I though this approach don't make too much sense that's why I rewrote it using anchors <a> tags. Animated scroll is a recurrent issue on react router without a clear solution, see: https://github.com/ReactTraining/react-router/issues/394, probably due that scroll is a document DOM level stuff, far beyond the boundaries of pureness "React Component".

I don't know what you are trying to do but 'scroll' to a external link isn't possible with React Scrollchor right now. Initially I create this component thinking on landing pages but I open to go more far.

One solution to your use case could be: First load external page using router then scroll to it. If you are working with infinite scroll like page, maybe react-waypoint can trigger react-router page load. Is you take a look at Scrollchor code, it is really simple and all the dirty DOM stuffs is apart on modules that can be reused. You can create your own solution with it and askme anything about this.

bySabi commented 8 years ago

closed due inactivity.