Skip to content

Commit

Permalink
bump version and improve reversed chat direction
Browse files Browse the repository at this point in the history
  • Loading branch information
night committed Feb 11, 2019
1 parent 5802b08 commit 670971c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "BetterTTV",
"author": "Night",
"version": "7.2.50",
"version": "7.2.51",
"description": "BetterTTV enhances Twitch with new features, emotes, and more.",
"main": "betterttv.js",
"scripts": {
Expand Down
23 changes: 19 additions & 4 deletions src/modules/chat_direction/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
const $ = require('jquery');
const settings = require('../../settings');
const twitch = require('../../utils/twitch');

const CHAT_LINE_SELECTOR = '.chat-list__lines .chat-line__message';
const CHAT_LIST_SCROLL_CONTENT = '.chat-list .chat-list__lines .simplebar-scroll-content';

class ChatDirection {
constructor() {
settings.add({
id: 'chatDirection',
id: 'reverseChatDirection',
name: 'Reverse Chat Messages Direction',
defaultValue: false,
description: 'New chat messages come from the top'
});
settings.on('changed.chatDirection', () => this.toggleChatDirection());
settings.on('changed.reverseChatDirection', () => this.toggleChatDirection());
settings.on('load.chat', () => this.toggleChatAutoScrolling());
this.toggleChatDirection();
}

toggleChatAutoScrolling() {
const scroller = twitch.getChatScroller();
const reverseChatDirection = settings.get('reverseChatDirection');
if (!scroller) return;
scroller.setState({
isAutoScrolling: !reverseChatDirection
});
if (reverseChatDirection) {
$(CHAT_LIST_SCROLL_CONTENT)[0].scrollTop = 0;
}
}

toggleChatDirection() {
$(CHAT_LINE_SELECTOR).parent().toggleClass('bttv-chat-direction-reversed', settings.get('chatDirection'));
$('body').toggleClass('bttv-chat-direction-reversed', settings.get('reverseChatDirection'));
this.toggleChatAutoScrolling();
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/modules/chat_direction/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
.bttv-chat-direction-reversed {
display: flex;
flex-direction: column-reverse;
.chat-list__more-messages-placeholder {
display: none;
}

.chat-list .chat-list__lines div[role="log"] {
display: flex;
flex-direction: column-reverse;
}
}

0 comments on commit 670971c

Please sign in to comment.