Skip to content

Commit fa975b6

Browse files
Merge branch 'commit-14-Remove-Scrollbar-Thumb-Disappearance' into merge-14-Remove-Scrollbar-Thumb-Disappearance
2 parents 1cd9cac + f4c8e46 commit fa975b6

File tree

11 files changed

+61
-21
lines changed

11 files changed

+61
-21
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Add the default stylesheet `dist/fixed-data-table.css` using a link tag or impor
3838

3939
Implementing a table involves three component types- `<Table/>`,`<Column/>`, and `<Cell/>`.
4040

41-
`<Table />` contains configuration information for the entire table, like dimensions and row count. It's also where you pass down the data to be rendered in the table.
41+
`<Table />` contains configuration information for the entire table, like dimensions and row count.
4242

4343
```javascript
4444

@@ -50,7 +50,6 @@ Implementing a table involves three component types- `<Table/>`,`<Column/>`, and
5050
width={5000}
5151
height={5050}
5252
headerHeight={50}
53-
data={rows}>
5453
...
5554
</Table>
5655
```

examples/PaginationExample.js renamed to examples/InfiniteScrollExample.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class PagedData {
5050
}
5151
}
5252

53-
class PaginationExample extends React.Component {
53+
class InfiniteScrollExample extends React.Component {
5454
constructor(props) {
5555
super(props);
5656

@@ -124,4 +124,4 @@ class PaginationExample extends React.Component {
124124
}
125125
}
126126

127-
module.exports = PaginationExample;
127+
module.exports = InfiniteScrollExample;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"less": "^2.2.0",
3939
"less-loader": "^2.0.0",
4040
"marked": "^0.3.2",
41-
"mocha": "^2.5.3",
41+
"mocha": "5.2.0",
4242
"mocha-loader": "^1.0.0",
4343
"mocha-webpack": "1.0.0-rc.1",
4444
"null-loader": "^0.1.0",
@@ -58,6 +58,7 @@
5858
"webpack-dev-server": "^2.6.1"
5959
},
6060
"scripts": {
61+
"webpack": "webpack",
6162
"site-dev-server": "./build_helpers/startSiteDevServer.sh",
6263
"site-build": "./build_helpers/buildStaticSite.sh",
6364
"build-dist": "./build_helpers/buildDist.sh",

site/Constants.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ exports.ExamplePages = {
9696
title: 'Column Groups',
9797
description: 'Table with column groupings.',
9898
},
99-
PAGINATION_EXAMPLE: {
100-
location: 'example-pagination.html',
101-
fileName: 'PaginationExample.js',
102-
title: 'Pagination',
99+
INFINITE_SCROLL_EXAMPLE: {
100+
location: 'example-infinite-scroll.html',
101+
fileName: 'InfiniteScrollExample.js',
102+
title: 'Infinite Scroll',
103103
description: 'A table example that pages in data as the user scrolls. We fake this by having a promise that resolves after a few milliseconds',
104104
},
105105
FILTER_EXAMPLE: {

site/examples/ExamplesPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var EXAMPLE_COMPONENTS = {
3737
[ExamplePages.EXPANDED_EXAMPLE.location]: require('../../examples/ExpandedExample'),
3838
[ExamplePages.FLEXGROW_EXAMPLE.location]: require('../../examples/FlexGrowExample'),
3939
[ExamplePages.COLUMN_GROUPS_EXAMPLE.location]: require('../../examples/ColumnGroupsExample'),
40-
[ExamplePages.PAGINATION_EXAMPLE.location]: require('../../examples/PaginationExample'),
40+
[ExamplePages.INFINITE_SCROLL_EXAMPLE.location]: require('../../examples/InfiniteScrollExample'),
4141
[ExamplePages.FILTER_EXAMPLE.location]: require('../../examples/FilterExample'),
4242
[ExamplePages.SORT_EXAMPLE.location]: require('../../examples/SortExample'),
4343
[ExamplePages.RESPONSIVE_EXAMPLE.location]: require('../../examples/ResponsiveExample'),

src/FixedDataTable.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ class FixedDataTable extends React.Component {
137137
*/
138138
touchScrollEnabled: PropTypes.bool,
139139

140-
// TODO (jordan) Remove propType of showScrollbarX & showScrollbarY without losing documentation (moved to scrollFlags)
141140
/**
142141
* Boolean flags to control if scrolling with keys is enabled
143142
*/
144143
keyboardScrollEnabled: PropTypes.bool,
145144
keyboardPageEnabled: PropTypes.bool,
146145

146+
// TODO (jordan) Remove propType of showScrollbarX & showScrollbarY without losing documentation (moved to scrollFlags)
147147
/**
148148
* Hide the scrollbar but still enable scroll functionality
149149
*/
@@ -666,6 +666,7 @@ class FixedDataTable extends React.Component {
666666
onScroll={this._onVerticalScroll}
667667
verticalTop={bodyOffsetTop}
668668
position={scrollY}
669+
touchEnabled={touchScrollEnabled}
669670
/>;
670671
}
671672

@@ -678,6 +679,7 @@ class FixedDataTable extends React.Component {
678679
onScroll={this._onHorizontalScroll}
679680
position={scrollX}
680681
size={width}
682+
touchEnabled={touchScrollEnabled}
681683
/>;
682684
}
683685

@@ -779,15 +781,18 @@ class FixedDataTable extends React.Component {
779781
style={{top: footOffsetTop}}
780782
/>;
781783
}
782-
784+
var tabIndex = null;
785+
if (this.props.keyboardPageEnabled || this.props.keyboardScrollEnabled) {
786+
tabIndex = 0;
787+
}
783788
return (
784789
<div
785790
className={joinClasses(
786791
className,
787792
cx('fixedDataTableLayout/main'),
788793
cx('public/fixedDataTable/main'),
789794
)}
790-
tabIndex={0}
795+
tabIndex={tabIndex}
791796
onKeyDown={this._onKeyDown}
792797
onWheel={this._wheelHandler.onWheel}
793798
onTouchStart={this._touchHandler.onTouchStart}

src/ReactTouchHandler.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class ReactTouchHandler {
101101
}
102102

103103
onTouchStart(/*object*/ event) {
104+
104105
// Start tracking drag delta for scrolling
105106
this._lastTouchX = event.touches[0].pageX;
106107
this._lastTouchY = event.touches[0].pageY;
@@ -147,6 +148,7 @@ class ReactTouchHandler {
147148
}
148149

149150
onTouchMove(/*object*/ event) {
151+
150152
var moveX = event.touches[0].pageX;
151153
var moveY = event.touches[0].pageY;
152154

src/Scrollbar.js

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class Scrollbar extends React.PureComponent {
4444
position: PropTypes.number,
4545
size: PropTypes.number.isRequired,
4646
trackColor: PropTypes.oneOf(['gray']),
47+
touchEnabled: PropTypes.bool,
4748
zIndex: PropTypes.number,
4849
verticalTop: PropTypes.number
4950
}
@@ -92,6 +93,8 @@ class Scrollbar extends React.PureComponent {
9293

9394
_onRefFace = (ref) => this._faceRef = ref;
9495

96+
_onRefRoot = (ref) => this._rootRef = ref;
97+
9598
render() /*?object*/ {
9699
if (!this.state.scrollable) {
97100
return null;
@@ -145,6 +148,7 @@ class Scrollbar extends React.PureComponent {
145148
FixedDataTableTranslateDOMPosition(faceStyle, 0, position, this._initialRender);
146149
}
147150

151+
mainStyle.touchAction = 'none';
148152
mainStyle.zIndex = this.props.zIndex;
149153

150154
if (this.props.trackColor === 'gray') {
@@ -157,10 +161,14 @@ class Scrollbar extends React.PureComponent {
157161
onBlur={this._onBlur}
158162
onKeyDown={this._onKeyDown}
159163
onMouseDown={this._onMouseDown}
164+
onTouchCancel={this._onTouchCancel}
165+
onTouchEnd={this._onTouchEnd}
166+
onTouchMove={this._onTouchMove}
167+
onTouchStart={this._onTouchStart}
160168
onWheel={this._wheelHandler.onWheel}
161169
className={mainClassName}
162170
style={mainStyle}
163-
tabIndex={0}>
171+
ref={this._onRefRoot}>
164172
<div
165173
ref={this._onRefFace}
166174
className={faceClassName}
@@ -186,7 +194,8 @@ class Scrollbar extends React.PureComponent {
186194
this._mouseMoveTracker = new DOMMouseMoveTracker(
187195
this._onMouseMove,
188196
this._onMouseMoveEnd,
189-
document.documentElement
197+
document.documentElement,
198+
this.props.touchEnabled
190199
);
191200

192201
if (this.props.position !== undefined &&
@@ -322,8 +331,8 @@ class Scrollbar extends React.PureComponent {
322331
// magically available for browsers somehow.
323332
var nativeEvent = event.nativeEvent;
324333
var position = this.state.isHorizontal ?
325-
nativeEvent.offsetX || nativeEvent.layerX :
326-
nativeEvent.offsetY || nativeEvent.layerY;
334+
nativeEvent.offsetX || nativeEvent.layerX || this.getTouchX(nativeEvent) :
335+
nativeEvent.offsetY || nativeEvent.layerY || this.getTouchY(nativeEvent);
327336

328337
// MouseDown on the scroll-track directly, move the center of the
329338
// scroll-face to the mouse position.
@@ -344,7 +353,24 @@ class Scrollbar extends React.PureComponent {
344353

345354
this._mouseMoveTracker.captureMouseMoves(event);
346355
// Focus the node so it may receive keyboard event.
347-
ReactDOM.findDOMNode(this).focus();
356+
this._rootRef.focus();
357+
}
358+
359+
_onTouchCancel = (/*object*/ event) => {
360+
event.stopPropagation();
361+
}
362+
363+
_onTouchEnd = (/*object*/ event) => {
364+
event.stopPropagation();
365+
}
366+
367+
_onTouchMove = (/*object*/ event) => {
368+
event.stopPropagation();
369+
}
370+
371+
_onTouchStart = (/*object*/ event) => {
372+
event.stopPropagation();
373+
this._onMouseDown(event);
348374
}
349375

350376
_onMouseMove = (/*number*/ deltaX, /*number*/ deltaY) => {
@@ -476,6 +502,14 @@ class Scrollbar extends React.PureComponent {
476502
}
477503
}
478504

505+
getTouchX = (/*object*/ e) => {
506+
return Math.round(e.targetTouches[0].pageX - e.target.getBoundingClientRect().x);
507+
}
508+
509+
getTouchY = (/*object*/ e) => {
510+
return Math.round(e.targetTouches[0].pageY - e.target.getBoundingClientRect().y);
511+
}
512+
479513
_setNextState = (/*object*/ nextState, /*?object*/ props) => {
480514
props = props || this.props;
481515
var controlledPosition = props.position;

src/css/layout/ScrollbarLayout.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
z-index: 1;
4444
transition-duration: 250ms;
4545
transition-timing-function: ease;
46-
transition-property: background-color width position;
46+
transition-property: width;
4747
}
4848

4949
/**

src/selectors/roughHeights.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function roughHeights(columnProps, elementHeights, rowSettings,
126126
* @param {{
127127
* overflowX: string,
128128
* showScrollbarX: boolean,
129-
* }}
129+
* }} scrollFlags
130130
* @param {number} width
131131
* @return {ScrollbarState}
132132
*/

0 commit comments

Comments
 (0)