cycle text in order

This commit is contained in:
Thomas Smith 2022-07-05 16:05:33 -04:00
parent 833b6ee186
commit c88fcb215a
3 changed files with 23 additions and 110 deletions

View file

@ -7,7 +7,7 @@
<div class="row hero my-auto"> <div class="row hero my-auto">
<div style="z-index:100; display:flex; flex-direction:column;" class="col-lg-6 col-sm-12"> <div style="z-index:100; display:flex; flex-direction:column;" class="col-lg-6 col-sm-12">
<div style="margin-top:auto; margin-bottom:auto;"> <div style="margin-top:auto; margin-bottom:auto;">
<h1 class="display-1 mb-4"><span class="yellow">Equitable</span> Open&#8208;Source for <span id="cycle-br"><br></span><span class="verb">web3</span></h1> <h1 class="display-1 mb-4"><span class="yellow">Equitable</span> Open&#8208;Source for <span id="cycle-br"><br></span><span id="cycle">web3</span></h1>
<p class="mb-5 fs-sm-5 fs-lg-6 lead">The tools that build the internet have steeped too long. For the past two <p class="mb-5 fs-sm-5 fs-lg-6 lead">The tools that build the internet have steeped too long. For the past two
decades, big tech has made trillions off the generosity of visionary developers and web pioneers… never decades, big tech has made trillions off the generosity of visionary developers and web pioneers… never
thanking, never mentioning, and certainly never paying. At tea, were brewing something to change that by thanking, never mentioning, and certainly never paying. At tea, were brewing something to change that by

View file

@ -154,70 +154,27 @@ integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+
</script> </script>
<script> <script>
var words = (function(){ const textList = [
var words = [ "web3",
'web', "game dev",
'web3', "web",
'game dev', "AI",
'AI', "automation",
'automation', "data",
'data', "ML",
'ML', "smart contracts",
'devops', "devops",
'smart contracts', "ML",
'creating', "creating",
'everything', "everything",
'<i>you<i>' "<i>you<i>"
], ];
el = document.querySelector('.verb'), const cycle = document.querySelector("#cycle");
currentIndex, let i = 0;
currentWord, const cycleText = () => {
prevWord, cycle.innerHTML = textList[i];
duration = 3000; i = ++i % textList.length;
var _getIndex = function(max, min){
currentIndex = Math.floor(Math.random() * (max - min + 1)) + min;
//Generates a random number between beginning and end of words array
return currentIndex;
}; };
var _getWord = function(index){ cycleText();
currentWord = words[index]; setInterval(cycleText, 1200);
return currentWord;
};
var _clear = function() {
setTimeout(function(){
el.className = 'verb';
}, duration/4);
};
var _toggleWord = function(duration){
setInterval(function(){
//Stores value of previous word
prevWord = currentWord;
//Generate new current word
currentWord = words[_getIndex(words.length-1, 0)];
//Generate new word if prev matches current
if(prevWord === currentWord){
currentWord = words[_getIndex(words.length-1, 0)];
}
//Swap new value
el.innerHTML = currentWord;
//Clear class styles
_clear();
//Fade in word
el.classList.add(
'js-block',
'js-fade-in-verb'
);
}, duration);
};
var _init = function(){
_toggleWord(duration);
};
//Public API
return {
init : function(){
_init();
}
};
})();
words.init();
</script> </script>

View file

@ -522,47 +522,3 @@ For authenticated users:
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%232B3033'%3e%3cpath fill-rule='evenodd' d='m12.14 8.753-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z'/%3e%3c/svg%3e"); background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%232B3033'%3e%3cpath fill-rule='evenodd' d='m12.14 8.753-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z'/%3e%3c/svg%3e");
transform: rotate(90deg); transform: rotate(90deg);
} }
/* CSS for text cycling */
@-moz-keyframes
fade-it { 0% {
opacity:0
}
100% {
opacity:1
}
}
@-webkit-keyframes
fade-it { 0% {
opacity:0
}
100% {
opacity:1
}
}
@keyframes
fade-it { 0% {
opacity:0
}
100% {
opacity:1
}
}
.js-fade-in-verb {
animation-name: fade-it;
animation-duration: 1s;
animation-fill-mode: forwards;
-webkit-animation-name: fade-it;
-webkit-animation-duration: 1s;
-webkit-animation-fill-mode: forwards
}
.verb.js-block { display: inline-block }
.verb.js-hide {
display: none;
opacity: 0
}
.verb {
display: inline-block;
visibility: visible;
}