Scolling rules

This commit is contained in:
James Barnsley
2018-10-25 17:00:49 +13:00
parent 99b700d5aa
commit d5a96fe716
16 changed files with 13852 additions and 10508 deletions

View File

@ -2,6 +2,8 @@
import React from 'react';
import {Link} from 'react-router';
import * as helpers from '../helpers';
/**
* Extends react-router's Link but provides the ability to hook in to the navigation event
* which lets us scroll to the top of our <main> for a more traditional navigation experience
@ -14,7 +16,14 @@ export default class extends React.Component{
handleClick(e){
if (!this.props.retainScroll){
document.getElementById('main').scrollTo(0, 0);
if (this.props.scrollTo){
var element = document.getElementById(this.props.scrollTo);
if (element){
element.scrollIntoView();
}
} else {
helpers.scrollToTop();
}
}
}