-
Notifications
You must be signed in to change notification settings - Fork 936
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds pin-to-top, appearance animation, and perf boosts. (#110)
- Loading branch information
Showing
14 changed files
with
109 additions
and
128 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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,68 @@ | ||
import React, { Component } from 'react' | ||
import { inject, observer } from 'mobx-react' | ||
import Colors from '../Theme/Colors' | ||
import getCommandComponent from '../Commands' | ||
import { map, reverse } from 'ramda' | ||
import { dotPath } from 'ramdasauce' | ||
import AppStyles from '../Theme/AppStyles' | ||
|
||
const Styles = { | ||
container: { | ||
backgroundColor: Colors.screen, | ||
...AppStyles.Layout.vbox | ||
}, | ||
commands: { | ||
paddingLeft: 0, | ||
paddingRight: 0, | ||
paddingTop: 0, | ||
paddingBottom: 0, | ||
overflowY: 'scroll', | ||
overflowX: 'hidden' | ||
} | ||
} | ||
|
||
@inject('session') | ||
@observer | ||
class Timeline extends Component { | ||
|
||
// fires when we will update | ||
componentWillUpdate () { | ||
const node = this.refs.commands | ||
// http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html | ||
// remember our height, position, and if we're at the top | ||
this.scrollHeight = node.scrollHeight | ||
this.scrollTop = node.scrollTop | ||
this.isPinned = this.scrollTop === 0 | ||
} | ||
|
||
// fires after we did update | ||
componentDidUpdate () { | ||
// should we be pinned to top, let's not auto-scroll | ||
if (this.isPinned) return | ||
const node = this.refs.commands | ||
// scroll to the place we were before | ||
// TODO: this falls apart as we reach max queue size as the scrollHeigh no longer changes | ||
node.scrollTop = this.scrollTop + node.scrollHeight - this.scrollHeight | ||
} | ||
|
||
render () { | ||
// grab the commands, but sdrawkcab | ||
const commands = reverse(dotPath('props.session.server.commands.all', this)) | ||
|
||
const renderItem = command => { | ||
const CommandComponent = getCommandComponent(command) | ||
return <CommandComponent key={command.messageId} command={command} /> | ||
} | ||
|
||
return ( | ||
<div style={Styles.container} ref='container'> | ||
<div style={Styles.commands} ref='commands'> | ||
{map(renderItem, commands)} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
} | ||
|
||
export default Timeline |
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 was deleted.
Oops, something went wrong.
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