Skip to content

Commit

Permalink
fix(scroll): add timeout to scroll on incoming message
Browse files Browse the repository at this point in the history
  • Loading branch information
ph1p committed Nov 16, 2019
1 parent 5ad7ca8 commit a0c5c06
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/shared/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const state = store({
disableAutoScroll: false,
scrollToBottom() {
if (!state.disableAutoScroll) {
console.log('ok', state.disableAutoScroll);
// scroll to bottom
if (state.messagesRef.current) {
state.messagesRef.current.scrollTop =
Expand Down Expand Up @@ -109,7 +110,8 @@ const state = store({
}

state.messages.push(newMessage);
state.scrollToBottom();

setTimeout(state.scrollToBottom, 0);
} catch (e) {
console.log(e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/user-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const UserListView: FunctionComponent = () => {
<div
className="color"
style={{ backgroundColor: user.color || '#000' }}
></div>
/>
<div className="name">{user.name}</div>
</div>
))}
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = (env, argv) => ({
},
resolve: { extensions: ['.tsx', '.ts', '.jsx', '.js'] },
output: {
// filename: '[name].js',
filename: '[name].js',
path: path.resolve(__dirname, figmaPlugin.name)
},
plugins: [
Expand Down

0 comments on commit a0c5c06

Please sign in to comment.