- 
      
 - 
        
Save swestphal/cd74e75a82787102dbfc66bcfff87049 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
koistya revised this gist
Aug 2, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ let ticking = false; class App extends React.Component { componentDidMount() { window.addEventListener('scroll', this.handleScroll, true); } componentWillUnmount() {  - 
        
koistya revised this gist
Jul 4, 2018 . No changes.There are no files selected for viewing
 - 
        
koistya revised this gist
Jul 4, 2018 . 1 changed file with 15 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,30 @@ import React from 'react'; let lastScrollY = 0; let ticking = false; class App extends React.Component { componentDidMount() { window.addEventListener('scroll', this.handleScroll); } componentWillUnmount() { window.removeEventListener('scroll', this.handleScroll); } nav = React.createRef(); handleScroll = () => { lastScrollY = window.scrollY; if (!ticking) { window.requestAnimationFrame(() => { this.nav.current.style.top = `${lastScrollY}px`; ticking = false; }); ticking = true; } }; render() {  - 
        
koistya renamed this gist
Jul 4, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
koistya revised this gist
Jul 4, 2018 . 1 changed file with 19 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,31 +1,28 @@ import React from 'react'; class App extends React.Component { componentDidMount() { document.documentElement.addEventListener('scroll', this.handleScroll); } componentWillUnmount() { document.documentElement.removeEventListener('scroll', this.handleScroll); } nav = React.createRef(); handleScroll = () => { this.nav.current.style.top = document.documentElement.scrollTop + 'px'; }; render() { return ( <div> <nav ref={this.nav}> </nav> <div> ); } } export default App;  - 
        
koistya revised this gist
Jan 14, 2015 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,9 +12,7 @@ var Application = React.createClass({ }, componentWillUnmount() { document.documentElement.removeEventListener('scroll', this.handleScroll); }, render() {  - 
        
koistya revised this gist
Jan 14, 2015 . 1 changed file with 18 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,24 +5,24 @@ var ExecutionEnvironment = require('react/lib/ExecutionEnvironment'); var Application = React.createClass({ componentDidMount() { if (ExecutionEnvironment.canUseDOM) { document.documentElement.addEventListener('scroll', this.handleScroll); } }, componentWillUnmount() { if (ExecutionEnvironment.canUseDOM) { document.documentElement.removeEventListener('scroll', this.handleScroll); } }, render() { return <div> <nav ref="nav"> </nav> <div>; }, handleScroll() { this.refs.nav.getDOMNode().style.top = document.documentElement.scrollTop + 'px';  - 
        
koistya created this gist
Jan 14, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ 'use strict'; var React = require('react'); var ExecutionEnvironment = require('react/lib/ExecutionEnvironment'); var Application = React.createClass({ componentDidMount() { if (ExecutionEnvironment.canUseDOM) { document.documentElement.addEventListener('scroll', this.handleScroll); } }, componentWillUnmount() { if (ExecutionEnvironment.canUseDOM) { document.documentElement.removeEventListener('scroll', this.handleScroll); } }, render() { return <div> <nav ref="nav"> </nav> <div>; }, handleScroll() { this.refs.nav.getDOMNode().style.top = document.documentElement.scrollTop + 'px'; } }); module.exports = Application;