forked from LiveCarta/LiveCartaWP
wp redesign
This commit is contained in:
88
htdocs/wp-content/themes/lawcarta/assets/js/ui.js
Normal file
88
htdocs/wp-content/themes/lawcarta/assets/js/ui.js
Normal file
@@ -0,0 +1,88 @@
|
||||
window.addEventListener('DOMContentLoaded', function(){
|
||||
|
||||
// home page scripts start
|
||||
function startTopBlockAnimations(){
|
||||
const lines = [
|
||||
'customized learning experiences.',
|
||||
'online publishing.',
|
||||
'customized teaching experiences.'
|
||||
];
|
||||
let currentTextNum = 0;
|
||||
const element = document.getElementById('animatedText');
|
||||
|
||||
function clearCurrent(){
|
||||
element.innerText = element.innerText.slice(0, -1);
|
||||
if (element.innerText.length > 0 ) {
|
||||
setTimeout(function(){
|
||||
clearCurrent();
|
||||
}, 30);
|
||||
} else {
|
||||
currentTextNum++;
|
||||
if (currentTextNum > lines.length - 1) {
|
||||
currentTextNum = 0;
|
||||
}
|
||||
setTimeout(function(){
|
||||
addNext();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function addNext(){
|
||||
if (!element) return;
|
||||
element.innerText = lines[currentTextNum].substr(0, element.innerText.length + 1);
|
||||
if (element.innerText.length === lines[currentTextNum].length ) {
|
||||
setTimeout(function(){
|
||||
clearCurrent();
|
||||
}, 1000);
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
addNext();
|
||||
}, 30);
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
addNext();
|
||||
}, 1000);
|
||||
|
||||
function promoTopNext(){
|
||||
if (document.querySelectorAll('.promo-backs').length){
|
||||
setTimeout(function(){
|
||||
let currents = document.querySelectorAll('.promo-bg.current');
|
||||
currents.forEach(item => {
|
||||
item.classList.remove('current');
|
||||
if (item.nextElementSibling){
|
||||
item.nextElementSibling.classList.add('current');
|
||||
} else {
|
||||
item.closest('.promo-backs').find('.promo-bg:first-child').classList.add('current');
|
||||
}
|
||||
});
|
||||
promoTopNext();
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
promoTopNext();
|
||||
}
|
||||
|
||||
if (this.document.querySelector('.promo-top')) {
|
||||
startTopBlockAnimations();
|
||||
}
|
||||
// home page scripts end
|
||||
|
||||
// sliders
|
||||
|
||||
document.querySelectorAll('.splide').forEach(slider => {
|
||||
new Splide( slider, {
|
||||
type: 'loop',
|
||||
perPage: 3,
|
||||
perMove: 1,
|
||||
rewind : true,
|
||||
pagination: false,
|
||||
gap: 10,
|
||||
breakpoints: {
|
||||
1000: { perPage: 2 },
|
||||
768 : { perPage: 1, gap: 0 },
|
||||
}
|
||||
} ).mount();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user