-
Notifications
You must be signed in to change notification settings - Fork 45.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Locally attach wheel, scroll and touch events
- Loading branch information
Showing
7 changed files
with
180 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const React = global.React; | ||
|
||
function wait(time) { | ||
console.log('Blocking!'); | ||
var startTime = new Date().getTime(); | ||
var endTime = startTime + time; | ||
while (new Date().getTime() < endTime) { | ||
// wait for it... | ||
} | ||
console.log('Not blocking!'); | ||
} | ||
|
||
var scrollable = { | ||
width: 300, | ||
height: 200, | ||
overflowY: 'auto', | ||
margin: '0 auto', | ||
background: '#ededed', | ||
}; | ||
|
||
class ScrollFixture extends React.Component { | ||
componentDidMount() { | ||
// jank up the main thread! | ||
this.jank = setInterval(() => wait(3000), 4000); | ||
} | ||
|
||
componentWillUnmount() { | ||
clearInterval(this.jank); | ||
} | ||
|
||
onWheel() { | ||
console.log('wheel'); | ||
} | ||
|
||
onTouchStart() { | ||
console.log('touch start'); | ||
} | ||
|
||
onTouchMove() { | ||
console.log('touch move'); | ||
} | ||
|
||
render() { | ||
let listItems = []; | ||
|
||
// This is to produce a long enough page to allow for scrolling | ||
for (var i = 0; i < 50; i++) { | ||
listItems.push(<li key={i}>List item #{i + 1}</li>); | ||
} | ||
|
||
return ( | ||
<section> | ||
<h2>Scroll Testing</h2> | ||
<p> | ||
Mouse wheel, track pad scroll, and touch events should not be blocked | ||
by JS execution in IE Edge, Safari, and Firefox. | ||
</p> | ||
<div | ||
style={scrollable} | ||
onTouchStart={this.onTouchStart} | ||
onTouchMove={this.onTouchMove} | ||
onWheel={this.onWheel}> | ||
<h2>I am scrollable!</h2> | ||
<ul>{listItems}</ul> | ||
</div> | ||
<ul>{listItems}</ul> | ||
</section> | ||
); | ||
} | ||
} | ||
|
||
export default ScrollFixture; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters