css: add chat animation on opening

This commit is contained in:
Sebastian Castro 2020-04-08 18:14:20 +02:00 committed by muxator
parent f5685f45c7
commit cbc6304243
5 changed files with 60 additions and 34 deletions

View file

@ -1,20 +1,38 @@
#chaticon, #chatbox { #chaticon, #chatbox {
visibility: hidden;
z-index: 400; z-index: 400;
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;
right: 25px; right: 25px;
}
#chaticon.visible, #chatbox.visible {
visibility: visible;
}
#chaticon {
border-top-left-radius: 5px; border-top-left-radius: 5px;
border-top-right-radius: 5px; border-top-right-radius: 5px;
display: none;
border: 1px solid #ccc; border: 1px solid #ccc;
border-bottom: none; border-bottom: none;
} }
#chatbox { .chat-content {
width: 400px; width: 400px;
height: 300px; height: 300px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
display: flex;
border: 1px solid #ccc;
border-bottom: none;
z-index: 401; z-index: 401;
background-color: #f7f7f7; background-color: #f7f7f7;
flex-direction: column; flex-direction: column;
transition: all 0.3s cubic-bezier(0.74, -0.05, 0.27, 1.75);
opacity: .3;
transform: scale(.5);
transform-origin: 100% 100%
}
#chatbox.visible .chat-content{
opacity: 1;
transform: scale(1);
} }
#chatbox.stickyChat { #chatbox.stickyChat {
@ -23,15 +41,20 @@
flex: 1 auto; /* take reminaning vertical space */ flex: 1 auto; /* take reminaning vertical space */
height: auto; height: auto;
right: 0; right: 0;
display: flex;
}
#chatbox.stickyChat .chat-content {
background-color: #f1f1f1; background-color: #f1f1f1;
border-radius: 0; border-radius: 0;
border: none; border: none;
border-left: 1px solid #ccc; border-left: 1px solid #ccc;
height: 100%;
width: 100%;
} }
#chatbox.stickyChat .stick-to-screen-btn { #chatbox.stickyChat .chat-content .stick-to-screen-btn {
display: none; display: none;
} }
#chatbox.stickyChat.chatAndUsersChat .hide-reduce-btn { #chatbox.stickyChat.chatAndUsersChat .chat-content .hide-reduce-btn {
display:none; display:none;
} }
@ -130,6 +153,10 @@
@media only screen and (max-width: 720px) { @media only screen and (max-width: 720px) {
#chatbox { #chatbox {
right: 0; right: 0;
width: 80%; bottom: 0;
left: 0;
}
#chatbox .chat-content {
width: 100%;
} }
} }

View file

@ -30,9 +30,8 @@ var chat = (function()
var self = { var self = {
show: function () show: function ()
{ {
$("#chaticon").hide(); $("#chaticon").removeClass('visible');
$("#chatbox").css('display', 'flex'); $("#chatbox").addClass('visible');
$("#gritter-container").hide();
self.scrollDown(); self.scrollDown();
chatMentions = 0; chatMentions = 0;
Tinycon.setBubble(0); Tinycon.setBubble(0);
@ -47,8 +46,13 @@ var chat = (function()
{ {
chat.show(); chat.show();
isStuck = (!isStuck || fromInitialCall); isStuck = (!isStuck || fromInitialCall);
$('#chatbox').hide();
// Add timeout to disable the chatbox animations
setTimeout(function() {
$('#chatbox, .sticky-container').toggleClass("stickyChat", isStuck);
$('#chatbox').css('display', 'flex');
}, 0);
$('#chatbox, .sticky-container').toggleClass("stickyChat", isStuck);
padcookie.setPref("chatAlwaysVisible", isStuck); padcookie.setPref("chatAlwaysVisible", isStuck);
$('#options-stickychat').prop('checked', isStuck); $('#options-stickychat').prop('checked', isStuck);
}, },
@ -78,15 +82,13 @@ var chat = (function()
} }
else { else {
$("#chatcounter").text("0"); $("#chatcounter").text("0");
$("#chaticon").show(); $("#chaticon").addClass('visible');
$("#chatbox").hide(); $("#chatbox").removeClass('visible');
$.gritter.removeAll();
$("#gritter-container").show();
} }
}, },
scrollDown: function() scrollDown: function()
{ {
if($('#chatbox').css("display") != "none"){ if($('.chat-content').is(':visible')){
if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) {
// if we use a slow animate here we can have a race condition when a users focus can not be moved away // if we use a slow animate here we can have a race condition when a users focus can not be moved away
// from the last message recieved. // from the last message recieved.
@ -153,7 +155,7 @@ var chat = (function()
var alreadyFocused = $("#chatinput").is(":focus"); var alreadyFocused = $("#chatinput").is(":focus");
// does the user already have the chatbox open? // does the user already have the chatbox open?
var chatOpen = $("#chatbox").is(":visible"); var chatOpen = $(".chat-content").is(":visible");
// does this message contain this user's name? (is the curretn user mentioned?) // does this message contain this user's name? (is the curretn user mentioned?)
var myName = $('#myusernameedit').val(); var myName = $('#myusernameedit').val();

View file

@ -1,4 +1,4 @@
#chatbox { .chat-content {
background: none; background: none;
padding: 0; padding: 0;
background-color: white; background-color: white;
@ -9,12 +9,12 @@
background-color: var(--bg-soft-color); background-color: var(--bg-soft-color);
} }
#chatbox.stickyChat { #chatbox.stickyChat .chat-content {
border: none; border: none;
background-color: var(--bg-soft-color); background-color: var(--bg-soft-color);
} }
#chatbox.stickyChat.chatAndUsersChat{ #chatbox.stickyChat.chatAndUsersChat .chat-content {
box-shadow: none; box-shadow: none;
} }
@ -50,7 +50,7 @@
background-color: transparent !important; background-color: transparent !important;
} }
#chatbox.stickyChat #chattext { #chatbox.stickyChat .chat-content #chattext {
padding: 0px; padding: 0px;
} }
@ -58,7 +58,7 @@
padding: 8px; padding: 8px;
} }
.plugin-ep_author_neat #chatbox.stickyChat #chattext { .plugin-ep_author_neat #chatbox.stickyChat .chat-content #chattext {
padding: 5px 3px; padding: 5px 3px;
} }
@ -75,10 +75,5 @@
right: 0; right: 0;
} }
#chatbox {
width: 100%;
right: 0;
}
.stick-to-screen-btn { display: none; } .stick-to-screen-btn { display: none; }
} }

View file

@ -73,11 +73,11 @@
.super-light-background.super-light-toolbar .toolbar { .super-light-background.super-light-toolbar .toolbar {
--border-color: var(--super-light-color); --border-color: var(--super-light-color);
} }
.super-light-background #chatbox, .super-light-background #chatbox.stickyChat { .super-light-background .chat-content, .super-light-background #chatbox.stickyChat .chat-content {
--bg-color: var(--super-light-color); --bg-color: var(--super-light-color);
--bg-soft-color: var(--super-light-color); --bg-soft-color: var(--super-light-color);
} }
.super-light-background #chatbox.stickyChat { .super-light-background #chatbox.stickyChat .chat-content {
box-shadow: none; box-shadow: none;
} }
/* ====================== */ /* ====================== */
@ -102,14 +102,14 @@
.light-background input[type="text"] { .light-background input[type="text"] {
background-color: var(--super-light-color); background-color: var(--super-light-color);
} }
.light-background #chatbox, .light-background #chatbox.stickyChat { .light-background .chat-content, .light-background #chatbox.stickyChat .chat-content {
--bg-color: var(--super-light-color); --bg-color: var(--super-light-color);
--bg-soft-color: var(--light-color); --bg-soft-color: var(--light-color);
--scrollbar-bg: var(--super-light-color); --scrollbar-bg: var(--super-light-color);
--scrollbar-track: var(--light-color); --scrollbar-track: var(--light-color);
--scrollbar-thumb: var(--middle-color); --scrollbar-thumb: var(--middle-color);
} }
.light-background #chatbox.stickyChat { .light-background #chatbox.stickyChat .chat-content {
box-shadow: none; box-shadow: none;
} }
/* Special combinaison with toolbar */ /* Special combinaison with toolbar */
@ -148,7 +148,7 @@
border: none; border: none;
border-radius: 8px; border-radius: 8px;
} }
.super-dark-background #chatbox, .super-dark-background #chatbox.stickyChat { .super-dark-background .chat-content, .super-dark-background #chatbox.stickyChat .chat-content {
background-color: var(--super-dark-color); background-color: var(--super-dark-color);
color: var(--light-color); color: var(--light-color);
} }
@ -160,7 +160,7 @@
.super-dark-background input[type="text"]::placeholder { .super-dark-background input[type="text"]::placeholder {
color: var(--middle-color); color: var(--middle-color);
} }
.super-dark-background #chatbox:not(.stickyChat) { .super-dark-background #chatbox:not(.stickyChat) .chat-content {
border: 1px solid var(--dark-color); border: 1px solid var(--dark-color);
} }
/* Special combinaison with toolbar */ /* Special combinaison with toolbar */
@ -196,7 +196,7 @@
border: none; border: none;
border-radius: 8px; border-radius: 8px;
} }
.dark-background #chatbox, .dark-background #chatbox.stickyChat { .dark-background .chat-content, .dark-background #chatbox.stickyChat .chat-content {
background-color: var(--dark-color); background-color: var(--dark-color);
color: var(--super-light-color); color: var(--super-light-color);
--border-color: var(--dark-soft-color); --border-color: var(--dark-soft-color);
@ -209,7 +209,7 @@
.dark-background input[type="text"]::placeholder { .dark-background input[type="text"]::placeholder {
color: var(--middle-color); color: var(--middle-color);
} }
.dark-background .popup-content, .dark-background #chatbox:not(.stickyChat) { .dark-background .popup-content, .dark-background #chatbox:not(.stickyChat) .chat-content {
box-shadow: 0 0 14px 0px var(--super-dark-color); box-shadow: 0 0 14px 0px var(--super-dark-color);
} }
/* Special combinaison with toolbar */ /* Special combinaison with toolbar */

View file

@ -361,13 +361,14 @@
<!----------- CHAT ------------> <!----------- CHAT ------------>
<!-----------------------------> <!----------------------------->
<div id="chaticon" onclick="chat.show();return false;" title="Chat (Alt C)"> <div id="chaticon" class="visible" onclick="chat.show();return false;" title="Chat (Alt C)">
<span id="chatlabel" data-l10n-id="pad.chat"></span> <span id="chatlabel" data-l10n-id="pad.chat"></span>
<span class="buttonicon buttonicon-chat"></span> <span class="buttonicon buttonicon-chat"></span>
<span id="chatcounter">0</span> <span id="chatcounter">0</span>
</div> </div>
<div id="chatbox"> <div id="chatbox">
<div class="chat-content">
<div id="titlebar"> <div id="titlebar">
<h1 id ="titlelabel" data-l10n-id="pad.chat"></h1> <h1 id ="titlelabel" data-l10n-id="pad.chat"></h1>
<a id="titlecross" class="hide-reduce-btn" onClick="chat.hide();return false;">-&nbsp;</a> <a id="titlecross" class="hide-reduce-btn" onClick="chat.hide();return false;">-&nbsp;</a>
@ -382,6 +383,7 @@
<input id="chatinput" type="text" maxlength="999" data-l10n-id="pad.chat.writeMessage.placeholder"> <input id="chatinput" type="text" maxlength="999" data-l10n-id="pad.chat.writeMessage.placeholder">
</form> </form>
</div> </div>
</div>
</div> </div>
</div> </div>