Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 85a57b0

Browse files
authored
Merge pull request #16 from readthedocs/fade-out-fade-in
Add animation for fading-in and fading-out
2 parents 0d96d05 + a83d301 commit 85a57b0

File tree

4 files changed

+20
-25
lines changed

4 files changed

+20
-25
lines changed

sphinx_search/_static/css/rtd_sphinx_search.css

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
width: 90%;
122122
margin-bottom: 15px;
123123
}
124+
124125
.search__outer .bar:before,
125126
.search__outer .bar:after {
126127
content: "";
@@ -131,9 +132,11 @@
131132
background: #5264ae;
132133
transition: 0.2s ease all;
133134
}
135+
134136
.search__outer .bar:before {
135137
left: 50%;
136138
}
139+
137140
.search__outer .bar:after {
138141
right: 50%;
139142
}
@@ -163,14 +166,8 @@
163166
cursor: pointer;
164167
}
165168

166-
/* Helper class */
167-
168-
.display-block {
169-
display: block;
170-
animation: fade-in 0.4s;
171-
}
172-
173169
/* Title of each search result */
170+
174171
.search__result__title {
175172
/* Display and box model */
176173
display: inline-block;
@@ -185,11 +182,13 @@
185182
}
186183

187184
/* Path of each search result */
185+
188186
.search__result__path {
189187
color: #b3b3b3;
190188
}
191189

192190
/* Content of each search result */
191+
193192
.search__result__content {
194193
text-decoration: none;
195194
color: black;
@@ -200,6 +199,7 @@
200199
}
201200

202201
/* Highlighting of matched results */
202+
203203
.search__outer em {
204204
font-style: normal;
205205
}

sphinx_search/_static/css/rtd_sphinx_search.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sphinx_search/_static/js/rtd_sphinx_search.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,16 @@ const showSearchModal = () => {
372372
let search_bar = getInputField();
373373
search_bar.blur();
374374

375-
let search_outer_wrapper = document.querySelector(
376-
".search__outer__wrapper"
377-
);
378-
search_outer_wrapper.classList.add("display-block");
379-
380-
// sets the value of the input field to empty string and focus it.
381-
let search_outer_input = document.querySelector(".search__outer__input");
382-
if (search_outer_input !== null) {
383-
search_outer_input.value = "";
384-
search_outer_input.focus();
385-
}
375+
$(".search__outer__wrapper").fadeIn(400, () => {
376+
// sets the value of the input field to empty string and focus it.
377+
let search_outer_input = document.querySelector(
378+
".search__outer__input"
379+
);
380+
if (search_outer_input !== null) {
381+
search_outer_input.value = "";
382+
search_outer_input.focus();
383+
}
384+
});
386385
};
387386

388387
/**
@@ -399,11 +398,7 @@ const removeSearchModal = () => {
399398
search_outer_input.blur();
400399
}
401400

402-
// sets display="none" to fianlly hide the modal.
403-
let search_outer_wrapper = document.querySelector(
404-
".search__outer__wrapper"
405-
);
406-
search_outer_wrapper.classList.remove("display-block");
401+
$(".search__outer__wrapper").fadeOut(400);
407402
};
408403

409404
window.addEventListener("DOMContentLoaded", evt => {

0 commit comments

Comments
 (0)