Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JUMP TO #1713

Merged
merged 7 commits into from
May 9, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/scss/docs/Layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ $sidebar-width: 250px;
.Layout {
background-color: $gray;

&-container,
&-navigationContainer,
&-content {
height: 100%;
min-height: 100%;
}

&-container {
padding-top: $nav-height;
min-height: calc(100% - #{$nav-height});
margin-top: $nav-height;
}

&-navigationContainer {
Expand Down
2 changes: 1 addition & 1 deletion docs/scss/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ html,
body,
#root,
[data-reactroot] {
height: 100%;
min-height: 100%;
}
27 changes: 26 additions & 1 deletion docs/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,36 @@ function logPageView() {
ReactGA.pageview(window.location.pathname);
}

// https://github.com/ReactTraining/react-router/issues/394#issuecomment-220221604
function hashLinkScroll() {
const { hash } = window.location;
if (hash !== '') {
// Push onto callback queue so it runs after the DOM is updated,
// this is required when navigating from a different page so that
// the element is rendered on the page before trying to getElementById.
setTimeout(() => {
const id = hash.replace('#', '');
const element = document.getElementById(id);
if (element) {
element.scrollIntoView();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window.scrollBy(0, -60); afterward?

window.scrollBy(0, -60); // Offset for header
}
}, 0);
}
}

function onRouterUpdate() {
logPageView();
hashLinkScroll();
}

export function init() {
setTimeout(() => hashLinkScroll(), 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, missed it: setTimeout(hashLinkScroll, 0)


render(
<Router
history={browserHistory}
onUpdate={logPageView}
onUpdate={onRouterUpdate}
>
<Route path="/" component={Layout} endpoints={api.endpoints}>
<Route component={IndexLayout}>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/Endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Endpoint(props) {
{methods.map(function(method, index) {
return (
<li key={index}>
<Link to={`#${method.name}`}>{method.name}</Link>
<a href={`#${method.name}`}>{method.name}</a>
</li>
);
})}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/Method.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function Method(props) {
}

return (
<div className="Method">
<div id={name} className="Method">
<h2>{name}</h2>
<div className="Method-section">
<p className="Method-description">{description}</p>
Expand Down