logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

column.js (1081B)


  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import detectPassiveEvents from 'detect-passive-events';
  4. import { scrollTop } from '../scroll';
  5. export default class Column extends React.PureComponent {
  6. static propTypes = {
  7. children: PropTypes.node,
  8. };
  9. scrollTop () {
  10. const scrollable = this.node.querySelector('.scrollable');
  11. if (!scrollable) {
  12. return;
  13. }
  14. this._interruptScrollAnimation = scrollTop(scrollable);
  15. }
  16. handleWheel = () => {
  17. if (typeof this._interruptScrollAnimation !== 'function') {
  18. return;
  19. }
  20. this._interruptScrollAnimation();
  21. }
  22. setRef = c => {
  23. this.node = c;
  24. }
  25. componentDidMount () {
  26. this.node.addEventListener('wheel', this.handleWheel, detectPassiveEvents.hasSupport ? { passive: true } : false);
  27. }
  28. componentWillUnmount () {
  29. this.node.removeEventListener('wheel', this.handleWheel);
  30. }
  31. render () {
  32. const { children } = this.props;
  33. return (
  34. <div role='region' className='column' ref={this.setRef}>
  35. {children}
  36. </div>
  37. );
  38. }
  39. }