Skip to content

Commit 9b0b2cf

Browse files
committed
auto hide tooltip when scoll down
1 parent 9f39a65 commit 9b0b2cf

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

themes/common.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
visibility: hidden;
3333
}
3434

35-
3635
/* height of the upload box */
3736
.wrap.svelte-xwlu1w {
3837
min-height: var(--size-32);
@@ -285,6 +284,18 @@
285284
left: 10px;
286285
}
287286

287+
#tooltip .hidden {
288+
/* display: none; */
289+
opacity: 0;
290+
transition: opacity 0.5s ease;
291+
}
292+
293+
#tooltip .visible {
294+
/* display: block; */
295+
opacity: 1;
296+
transition: opacity 0.5s ease;
297+
}
298+
288299
#elem_fontsize,
289300
#elem_top_p,
290301
#elem_temperature,

themes/common.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,24 @@ function minor_ui_adjustment() {
750750
var bar_btn_width = [];
751751
// 自动隐藏超出范围的toolbar按钮
752752
function auto_hide_toolbar() {
753-
var qq = document.getElementById('tooltip');
754-
var tab_nav = qq.getElementsByClassName('tab-nav');
753+
// if chatbot hit upper page boarder, hide all
754+
const elem_chatbot = document.getElementById('gpt-chatbot');
755+
const chatbot_top = elem_chatbot.getBoundingClientRect().top;
756+
var tooltip = document.getElementById('tooltip');
757+
var tab_nav = tooltip.getElementsByClassName('tab-nav')[0];
758+
759+
// 20 px 大概是一个字的高度
760+
if (chatbot_top < 20) {
761+
// tab_nav.style.display = 'none';
762+
if (tab_nav.classList.contains('visible')) {tab_nav.classList.remove('visible');}
763+
if (!tab_nav.classList.contains('hidden')) {tab_nav.classList.add('hidden');}
764+
return;
765+
}
766+
if (tab_nav.classList.contains('hidden')) {tab_nav.classList.remove('hidden');}
767+
if (!tab_nav.classList.contains('visible')) {tab_nav.classList.add('visible');}
768+
// tab_nav.style.display = '';
755769
if (tab_nav.length == 0) { return; }
756-
var btn_list = tab_nav[0].getElementsByTagName('button')
770+
var btn_list = tab_nav.getElementsByTagName('button')
757771
if (btn_list.length == 0) { return; }
758772
// 获取页面宽度
759773
var page_width = document.documentElement.clientWidth;

themes/welcome.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class WelcomeMessage {
203203
const elem_chatbot = document.getElementById('gpt-chatbot');
204204
const chatbot_top = elem_chatbot.getBoundingClientRect().top;
205205
const welcome_card_container = document.getElementsByClassName('welcome-card-container')[0];
206+
206207
// detect if welcome card overflow
207208
let welcome_card_overflow = false;
208209
if (welcome_card_container) {

0 commit comments

Comments
 (0)