Skip to content

Commit

Permalink
integrate smooth scrolling more react style
Browse files Browse the repository at this point in the history
  • Loading branch information
xMartin committed Nov 29, 2017
1 parent 82aa925 commit 349e1d3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions js/app/components/main.js
Expand Up @@ -41,7 +41,7 @@ function (React, createReactClass, PureRenderMixin, PropTypes, SmoothScroll, Loa
window.addEventListener('scroll', this.checkTransactionsHeadingVisibility);
window.addEventListener('resize', this.checkTransactionsHeadingVisibility);
this.checkTransactionsHeadingVisibility();
new SmoothScroll('#transactions-heading-link');
this.scroller = new SmoothScroll();
},

componentWillUnmount: function () {
Expand Down Expand Up @@ -70,6 +70,10 @@ function (React, createReactClass, PureRenderMixin, PropTypes, SmoothScroll, Loa
}
},

onTransitionsTeaserClick: function () {
this.scroller.animateScroll(this.refs.transactionsHeading);
},

render: function () {
return (
el('div', {className: 'scene mainScene' + (this.props.visible ? '' : ' hidden')},
Expand Down Expand Up @@ -117,12 +121,15 @@ function (React, createReactClass, PureRenderMixin, PropTypes, SmoothScroll, Loa
this.props.transactions.length
?
el('div', {className: 'row'},
el('h3', {ref: 'transactionsHeading', className: 'transactions-heading', id: 'transactions-heading'}, 'Transactions'),
el('h3', {ref: 'transactionsHeading', className: 'transactions-heading'}, 'Transactions'),
(
this.state.transactionsHeadingIsOutOfViewport
?
el('h3', {className: 'transactions-heading transactions-heading-fixed'},
el('a', {href: '#transactions-heading', id: 'transactions-heading-link'}, '▼ Transactions')
el('h3', {
className: 'transactions-heading transactions-heading-fixed',
onClick: this.onTransitionsTeaserClick
},
'▼ Transactions'
)
:
null
Expand Down

0 comments on commit 349e1d3

Please sign in to comment.