aboutsummaryrefslogtreecommitdiffstats
path: root/app/containers/App
diff options
context:
space:
mode:
authorHsuan Lee <boczeratul@gmail.com>2019-04-09 15:17:08 +0800
committerHsuan Lee <boczeratul@gmail.com>2019-04-09 15:17:08 +0800
commit21fd4a3cd2edf60b42a1e8d30e275beed2b23733 (patch)
treeadb044e12f4a6c138df4276a7be30d5fe3950b23 /app/containers/App
parentb9c0c169ce805124cb6b3fb84c7db8df9a76151e (diff)
downloaddexon-lottery-21fd4a3cd2edf60b42a1e8d30e275beed2b23733.tar
dexon-lottery-21fd4a3cd2edf60b42a1e8d30e275beed2b23733.tar.gz
dexon-lottery-21fd4a3cd2edf60b42a1e8d30e275beed2b23733.tar.bz2
dexon-lottery-21fd4a3cd2edf60b42a1e8d30e275beed2b23733.tar.lz
dexon-lottery-21fd4a3cd2edf60b42a1e8d30e275beed2b23733.tar.xz
dexon-lottery-21fd4a3cd2edf60b42a1e8d30e275beed2b23733.tar.zst
dexon-lottery-21fd4a3cd2edf60b42a1e8d30e275beed2b23733.zip
Add scrollability to console
Diffstat (limited to 'app/containers/App')
-rw-r--r--app/containers/App/Console.js22
-rw-r--r--app/containers/App/LotteryItem.js5
2 files changed, 22 insertions, 5 deletions
diff --git a/app/containers/App/Console.js b/app/containers/App/Console.js
index ba8f6fc..bb2f2ab 100644
--- a/app/containers/App/Console.js
+++ b/app/containers/App/Console.js
@@ -13,9 +13,7 @@ const Body = styled.div`
position: absolute;
height: calc(100% - 30px);
width: calc(100% - 40px);
- display: flex;
- flex-direction: column;
- justify-content: flex-end;
+ display: block;
`;
// eslint-disable-next-line react/prefer-stateless-function
@@ -29,12 +27,26 @@ class Console extends PureComponent {
setInterval(this.updateList, 10000);
}
+ setBodyRef = (ref) => {
+ this.body = ref;
+
+ this.scrollToBottom();
+ };
+
updateList = () => {
LotteryContract.getPastEvents('NumberRevealed', {
fromBlock: 0,
toBlock: 'latest',
})
- .then(events => this.setState({ list: events }));
+ .then(events => this.setState({
+ list: events,
+ }, this.scrollToBottom));
+ }
+
+ scrollToBottom = () => {
+ if (!this.body) return;
+
+ this.body.scrollTop = this.body.offsetHeight;
}
render() {
@@ -46,7 +58,7 @@ class Console extends PureComponent {
Lottery History
</Header>
- <Body>
+ <Body innerRef={this.setBodyRef}>
{list.map(event => (
<LotteryItem
key={event.transactionHash}
diff --git a/app/containers/App/LotteryItem.js b/app/containers/App/LotteryItem.js
index 619b842..454f430 100644
--- a/app/containers/App/LotteryItem.js
+++ b/app/containers/App/LotteryItem.js
@@ -19,6 +19,7 @@ const Marker = styled.span`
const Item = styled.a`
margin-top: 20px;
+ flex: 1 0 auto;
display: flex;
align-items: flex-end;
white-space: pre;
@@ -28,6 +29,10 @@ const Item = styled.a`
display: block;
}
+ &:first-child {
+ margin-top: 0;
+ }
+
&:hover {
background: #222222;
}