aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/ScrollBox.tsx
blob: d4620ae3f35c3c1cd2f75063c4b767cfb282f096 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import React = require('react');

export class ScrollBox extends React.Component<React.PropsWithChildren<{}>> {
    onWheel = (e: React.WheelEvent) => {
        if (e.currentTarget.scrollHeight > e.currentTarget.clientHeight) {
            // If the element has a scroll bar, then we don't want the containing collection to zoom
            e.stopPropagation();
        }
    };

    render() {
        return (
            <div
                style={{
                    overflow: 'auto',
                    width: '100%',
                    height: '100%',
                }}
                onWheel={this.onWheel}>
                {this.props.children}
            </div>
        );
    }
}