Skip to content

Commit

Permalink
Fix search results slow scrolling (#273)
Browse files Browse the repository at this point in the history
also:
- improve its responsive design
- fix the js path in gulp
  • Loading branch information
cotes2020 committed Feb 4, 2021
1 parent f864b5c commit 5669f79
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion _includes/search-results.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
The Search results
-->
<div id="search-result-wrapper" class="d-flex justify-content-center unloaded">
<div class="col-12 col-xl-11 post-content">
<div class="col-12 col-sm-11 post-content">
<div id="search-hints">
<h4 class="text-muted mb-4">{{ site.data.label.panel.trending_tags | default: 'Trending Tags' }}</h4>

Expand Down
18 changes: 5 additions & 13 deletions _sass/addon/commons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -811,9 +811,6 @@ $sidebar-display: "sidebar-display";

#search-result-wrapper {
display: none;
position: fixed;
top: 0;
padding-top: 3rem;
height: 100%;
overflow: auto;
.post-content {
Expand Down Expand Up @@ -1257,6 +1254,10 @@ $sidebar-display: "sidebar-display";
min-width: 150px;
}

#search-result-wrapper {
margin-top: 3rem;
}

div.post-content .table-wrapper > table {
min-width: 70%;
}
Expand Down Expand Up @@ -1311,10 +1312,6 @@ $sidebar-display: "sidebar-display";
left: 210px;
}

#search-result-wrapper {
width: calc(100% - 210px);
}

#search-results > div {
max-width: 700px;
}
Expand Down Expand Up @@ -1392,10 +1389,6 @@ $sidebar-display: "sidebar-display";
transition: all 0.3s ease-in-out;
}

#search-result-wrapper {
width: calc(100% - 260px);
}

#search-results > div {
max-width: 46%;
&:nth-child(odd) {
Expand Down Expand Up @@ -1608,7 +1601,6 @@ $sidebar-display: "sidebar-display";
}

#search-result-wrapper {
width: calc(100% - #{$sidebar-width-large});
> div {
max-width: #{$main-content-max-width};
}
Expand Down Expand Up @@ -1651,7 +1643,7 @@ $sidebar-display: "sidebar-display";
}

#search-result-wrapper {
padding-right: calc(100% - #{$sidebar-width-large} - 1530px);
padding-right: calc(100% - #{$sidebar-width-large} - 1180px);
}

#panel-wrapper {
Expand Down
22 changes: 12 additions & 10 deletions assets/js/_commons/search-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ $(function() {
const input = $("#search-input");
const hints = $("#search-hints");


/*--- Actions in small screens (Sidebar unloaded) ---*/

const scrollBlocker = (function () {
let offset = 0;
return {
block() {
offset = $(window).scrollTop();
offset = window.scrollY;
$("html,body").scrollTop(0);
},
release() {
$("html,body").scrollTop(offset);
Expand All @@ -35,6 +33,9 @@ $(function() {
};
}());


/*--- Actions in small screens (Sidebar unloaded) ---*/

const mobileSearchBar = (function () {
return {
on() {
Expand All @@ -60,11 +61,11 @@ $(function() {
return {
on() {
if (!visible) {
// the block method must be called before $(#main) unloaded.
scrollBlocker.block();
resultWrapper.removeClass("unloaded");
main.addClass("hidden");

main.addClass("unloaded");
visible = true;
scrollBlocker.block();
}
},
off() {
Expand All @@ -75,12 +76,13 @@ $(function() {
}
resultWrapper.addClass("unloaded");
btnClear.removeClass("visible");
main.removeClass("hidden");
main.removeClass("unloaded");

// now the release method must be called after $(#main) display
scrollBlocker.release();

input.val("");
visible = false;

scrollBlocker.release();
}
},
isVisible() {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/dist/categories.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5669f79

Please sign in to comment.