Skip to content

Commit 805dfc9

Browse files
committed
Accurate search box behavior
1 parent e34a3ad commit 805dfc9

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

css/search-box.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
font-size: 18px;
99
color: var(--foreground-0);
1010
margin-bottom: 20px;
11+
transition: 0.05s;
12+
pointer-events: all;
13+
margin-top: 26px;
1114
}
1215

1316
.search-box:active,
@@ -16,6 +19,14 @@
1619
border: none;
1720
}
1821

22+
.search-box:disabled {
23+
height: 0px;
24+
padding-top: 0px;
25+
padding-bottom: 0px;
26+
margin-bottom: 0px;
27+
pointer-events: none;
28+
}
29+
1930
::-webkit-input-placeholder {
2031
/* WebKit, Blink, Edge */
2132
color: var(--foreground-1);
@@ -36,4 +47,4 @@
3647
::placeholder {
3748
/* Most modern browsers support this now. */
3849
color: var(--foreground-1);
39-
}
50+
}

pages/Home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const Home = async () => {
2525
<!-- <span class="new-message-button">􀈎</span> --!>
2626
</p>
2727
</div>
28-
<h1 class="app-header">Messages</h1>
28+
<h1 class="app-header" style="margin-bottom: -20px;">Messages</h1>
2929
<input tabindex="-1" class="search-box" type="text" onkeyup="SearchContacts()" value="" placeholder="􀊫 Search"/>
3030
</div>
3131
<div id="homepage-contacts" style="overflow-y: scroll; flex: 1 1 auto;">

scripts/iMessage.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ catch {
3434
}))
3535
}
3636

37+
let LastContactsScrollTop = 0;
38+
let ContactsContainer = document.getElementById("homepage-contacts")
39+
ContactsContainer.addEventListener("scroll", (event) => {
40+
let diff = ContactsContainer.scrollTop - LastContactsScrollTop;
41+
if (diff < 0) {
42+
document.getElementsByClassName("search-box")[0].removeAttribute("disabled")
43+
}
44+
else {
45+
document.getElementsByClassName("search-box")[0].setAttribute("disabled", true)
46+
}
47+
LastContactsScrollTop = ContactsContainer.scrollTop
48+
})
49+
3750
let ContactImgCache = []
3851
const GetCachedContactImg = (docid) => {
3952
for (const Elem of ContactImgCache) {
@@ -877,7 +890,7 @@ const ProcessResponse = async (json) => {
877890
ApplyReactions(json)
878891

879892
// Scroll to bottom
880-
MessageContainer.scrollTop = MessageContainer.scrollHeight;
893+
//MessageContainer.scrollTop = MessageContainer.scrollHeight;
881894
}
882895

883896
const SwapTab = (TabNum, Intent = "") => {

0 commit comments

Comments
 (0)