Skip to content

Commit 4d49aea

Browse files
committed
Add animation when displaying quotes
1 parent b620657 commit 4d49aea

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

apps/homepage/static/homepage/js/random-quotes/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
function init() {
2-
// Show the first quote
32
getRandomQuote();
43

5-
// Change quote every RANDOM_QUOTE
4+
// Change quote every RANDOM_QUOTE_INTERVAL
65
setInterval(function() { getRandomQuote(); }, random_quote_interval);
76

8-
// Retrieve random quote using the api
97
function getRandomQuote() {
108
// Get the text and author span id
119
let text = document.getElementById("quote-text");
@@ -17,9 +15,23 @@ function init() {
1715
text.textContent = data.result.text
1816
author.textContent = data.result.author
1917
})
18+
// Animate display
19+
let quote_block = document.getElementById("quote-block");
20+
fadeInQuote(quote_block)
2021
}
2122
}
2223

24+
function fadeInQuote(quote, duration=2000) {
25+
quote.animate([
26+
{ // from
27+
opacity: 0,
28+
},
29+
{ // to
30+
opacity: 1,
31+
}
32+
], duration);
33+
}
34+
2335
export default {
2436
init
2537
}

apps/homepage/templates/homepage/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
<img class="logo" src="{{ assets|get_asset_key:'commons/img/logo_text.png' }}" alt="Python Canarias" />
3939

40-
<div class="quote is-centered">
40+
<div id="quote-block" class="quote is-centered">
4141
<p>
4242
<i class="fas fa-quote-left"></i>
4343
<span id="quote-text">

0 commit comments

Comments
 (0)