import * as React from 'react'; import cx from 'classnames'; export class GridScroll extends React.Component { constructor( props: iAXDataGridScrollProps ) { super( props ); this.onClickScrollTrack = this.onClickScrollTrack.bind( this ); } public onClickScrollTrack( e, barName ) { e.preventDefault(); if ( e.target.getAttribute( 'data-scroll' ) ) { this.props.onClickScrollTrack( e, barName ); } } public render() { const { mounted, bodyHeight, pageHeight, verticalScrollerHeight, verticalScrollerWidth, horizontalScrollerWidth, horizontalScrollerHeight, verticalScrollBarHeight, horizontalScrollBarWidth, scrollerArrowSize, scrollerPadding, scrollBarLeft, scrollBarTop, onMouseDownScrollBar, onClickScrollArrow, } = this.props; if ( !mounted ) return null; if ( verticalScrollerWidth === 0 && horizontalScrollerHeight === 0 ) return null; let arrowWidth = (scrollerArrowSize - scrollerPadding * 2) / 2; let verticalArrowStyles = { width: verticalScrollerWidth, height: scrollerArrowSize / 2 + scrollerPadding }; let verticalTopArrowStyles = { left: scrollerPadding, top: (verticalArrowStyles.height - arrowWidth) / 2, borderTop: '0 none', borderRight: 'solid ' + arrowWidth + 'px transparent', borderBottomWidth: (arrowWidth) + 'px', borderLeft: 'solid ' + arrowWidth + 'px transparent' }; let verticalBottomArrowStyles = { left: scrollerPadding, top: (verticalArrowStyles.height - arrowWidth) / 2, borderTopWidth: (arrowWidth) + 'px', borderRight: 'solid ' + arrowWidth + 'px transparent', borderBottom: '0 none', borderLeft: 'solid ' + arrowWidth + 'px transparent' }; let verticalStyles = { width: verticalScrollerWidth, height: verticalScrollerHeight + scrollerPadding * 2 + scrollerArrowSize, bottom: pageHeight, padding: scrollerPadding, paddingTop: scrollerArrowSize / 2 + scrollerPadding }; let verticalBarStyles = { height: verticalScrollBarHeight, top: scrollBarTop }; let horizontalArrowStyles = { width: scrollerArrowSize / 2 + scrollerPadding, height: horizontalScrollerHeight }; let horizontalLeftArrowStyles = { left: (horizontalArrowStyles.width - arrowWidth) / 2, top: scrollerPadding, borderTop: 'solid ' + arrowWidth + 'px transparent', borderRightWidth: (arrowWidth) + 'px', borderBottom: 'solid ' + arrowWidth + 'px transparent', borderLeft: '0 none' }; let horizontalRightArrowStyles = { left: (horizontalArrowStyles.width - arrowWidth) / 2, top: scrollerPadding, borderTop: 'solid ' + arrowWidth + 'px transparent', borderRight: '0 none', borderBottom: 'solid ' + arrowWidth + 'px transparent', borderLeftWidth: (arrowWidth) + 'px' }; let horizontalStyles = { width: horizontalScrollerWidth + scrollerPadding * 2 + scrollerArrowSize, height: horizontalScrollerHeight, bottom: (pageHeight - 1 - horizontalScrollerHeight) / 2, right: (pageHeight - 1 - horizontalScrollerHeight) / 2, padding: scrollerPadding, paddingLeft: scrollerArrowSize / 2 + scrollerPadding }; let horizontalBarStyles = { width: horizontalScrollBarWidth, left: scrollBarLeft }; return (
{(verticalScrollerWidth) ? (
onClickScrollArrow( e, 'up' )} />
this.onClickScrollTrack( e, 'vertical' )}>
onMouseDownScrollBar( e, 'vertical' )} />
onClickScrollArrow( e, 'down' )} />
) : null} {(horizontalScrollerHeight) ? (
onClickScrollArrow( e, 'left' )} />
this.onClickScrollTrack( e, 'horizontal' )}>
onMouseDownScrollBar( e, 'horizontal' )} />
onClickScrollArrow( e, 'right' )} />
) : null}
); } }