The code powering m.abunchtell.com https://m.abunchtell.com
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

54 lignes
1.1 KiB

  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. label: PropTypes.string,
  9. };
  10. scrollTop () {
  11. const scrollable = this.node.querySelector('.scrollable');
  12. if (!scrollable) {
  13. return;
  14. }
  15. this._interruptScrollAnimation = scrollTop(scrollable);
  16. }
  17. handleWheel = () => {
  18. if (typeof this._interruptScrollAnimation !== 'function') {
  19. return;
  20. }
  21. this._interruptScrollAnimation();
  22. }
  23. setRef = c => {
  24. this.node = c;
  25. }
  26. componentDidMount () {
  27. this.node.addEventListener('wheel', this.handleWheel, detectPassiveEvents.hasSupport ? { passive: true } : false);
  28. }
  29. componentWillUnmount () {
  30. this.node.removeEventListener('wheel', this.handleWheel);
  31. }
  32. render () {
  33. const { label, children } = this.props;
  34. return (
  35. <div role='region' aria-label={label} className='column' ref={this.setRef}>
  36. {children}
  37. </div>
  38. );
  39. }
  40. }