diff options
author | Sorin Davidoi <sorin.davidoi@gmail.com> | 2017-07-25 01:05:51 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-07-25 01:05:51 +0200 |
commit | ebf5a060843697d6c51ddfa2f80c1cff1054799e (patch) | |
tree | e39759bfb7c8b335c49a3356182551a039c44698 /app | |
parent | 23e854cb9176f7458fd7c2f66071486c21db239a (diff) |
fix(column): Use passive wheel listener (#4348)
* chore(yarn): Install detect-passive-events * fix(column): Use passive listener
Diffstat (limited to 'app')
-rw-r--r-- | app/javascript/mastodon/components/column.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/javascript/mastodon/components/column.js b/app/javascript/mastodon/components/column.js index 3cbb745c5..93f1d6260 100644 --- a/app/javascript/mastodon/components/column.js +++ b/app/javascript/mastodon/components/column.js @@ -1,5 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; +import detectPassiveEvents from 'detect-passive-events'; import scrollTop from '../scroll'; export default class Column extends React.PureComponent { @@ -30,11 +31,19 @@ export default class Column extends React.PureComponent { this.node = c; } + componentDidMount () { + this.node.addEventListener('wheel', this.handleWheel, detectPassiveEvents ? { passive: true } : false); + } + + componentWillUnmount () { + this.node.removeEventListener('wheel', this.handleWheel); + } + render () { const { children } = this.props; return ( - <div role='region' className='column' ref={this.setRef} onWheel={this.handleWheel}> + <div role='region' className='column' ref={this.setRef}> {children} </div> ); |