progetto.html - first draft
This commit is contained in:
29
js/fara.js
29
js/fara.js
@@ -1,16 +1,25 @@
|
||||
//use strict;
|
||||
|
||||
export {Farapp};
|
||||
export function slider(nextimage) {
|
||||
let header = document.querySelector('header');
|
||||
|
||||
const Farapp = {
|
||||
slider : /*** Fade in??*/ function (element, nextimage) {
|
||||
//opacity = 1;
|
||||
let images = [
|
||||
'img/fara_background.jpg',
|
||||
//'img/fara_bg_2.jpg',
|
||||
'img/fara_bg_3.jpg',
|
||||
'img/fara_bg_4.jpg',
|
||||
'img/fara_bg_5.jpg',
|
||||
//'img/fara_bg_6.jpg',
|
||||
'img/fara_bg_7.jpg',
|
||||
'img/fara_bg_8.jpg',
|
||||
'img/fara_bg_9.jpg',
|
||||
'img/fara_bg_10.png',
|
||||
'img/fara_bg_11.jpg',
|
||||
];
|
||||
|
||||
if(nextimage >= images.length) {
|
||||
nextimage = 0;
|
||||
}
|
||||
element.style =
|
||||
'background-image : url("' +images[nextimage++] + '");';
|
||||
setTimeout(slider, 2000);
|
||||
if (nextimage >= images.length) {
|
||||
nextimage = 0;
|
||||
}
|
||||
header.setAttribute('style', 'background-image : url("' +images[nextimage++] + '");');
|
||||
setTimeout(slider(nextimage), 2000);
|
||||
}
|
||||
68
js/ui.js
68
js/ui.js
@@ -1,35 +1,57 @@
|
||||
//use strict;
|
||||
import { Farapp } from "./fara.js";
|
||||
|
||||
//import * as Farapp from './fara.js';
|
||||
let homeRE = new RegExp(/(https?:\S+\/$|index.html$)/);
|
||||
|
||||
if (homeRE.test(window.location.href)) {
|
||||
window.addEventListener('load', () => {
|
||||
let nextimage = 0;
|
||||
let header = document.querySelector('header');
|
||||
slider();
|
||||
|
||||
function slider() {
|
||||
/*** Fade in??*/
|
||||
//opacity = 1;
|
||||
|
||||
let images = [
|
||||
'img/fara_background.jpg',
|
||||
//'img/fara_bg_2.jpg',
|
||||
'img/fara_bg_3.jpg',
|
||||
'img/fara_bg_4.jpg',
|
||||
'img/fara_bg_5.jpg',
|
||||
//'img/fara_bg_6.jpg',
|
||||
'img/fara_bg_7.jpg',
|
||||
'img/fara_bg_8.jpg',
|
||||
'img/fara_bg_9.jpg',
|
||||
'img/fara_bg_10.png',
|
||||
'img/fara_bg_11.jpg',
|
||||
];
|
||||
|
||||
if (nextimage >= images.length) {
|
||||
nextimage = 0;
|
||||
}
|
||||
header.setAttribute('style', 'background-image : url("' + images[nextimage++] + '");');
|
||||
setTimeout(slider, 2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Apply active class to selected link...
|
||||
* @todo Inefficient!!
|
||||
*/
|
||||
window.addEventListener('load', () => {
|
||||
let navlinks = Array.from(document.querySelectorAll('#links a'));
|
||||
|
||||
navlinks.forEach(element => {
|
||||
let ref = element.href.substr(element.href.lastIndexOf('/'), element.href.length);
|
||||
|
||||
if (window.location.href.includes(ref) || element.href.includes('index.html')) {
|
||||
if (window.location.href.includes(ref)) {
|
||||
element.setAttribute('class', 'active');
|
||||
}
|
||||
if (homeRE.test(window.location.href)) {
|
||||
navlinks[0].setAttribute('class', 'active');
|
||||
}
|
||||
});
|
||||
|
||||
let images = [
|
||||
'img/fara_background.jpg',
|
||||
//'img/fara_bg_2.jpg',
|
||||
'img/fara_bg_3.jpg',
|
||||
'img/fara_bg_4.jpg',
|
||||
'img/fara_bg_5.jpg',
|
||||
//'img/fara_bg_6.jpg',
|
||||
'img/fara_bg_7.jpg',
|
||||
'img/fara_bg_8.jpg',
|
||||
'img/fara_bg_9.jpg',
|
||||
'img/fara_bg_10.png',
|
||||
'img/fara_bg_11.jpg',
|
||||
];
|
||||
let nextimage = 0;
|
||||
let header = document.querySelector('header');
|
||||
|
||||
Farapp.slider(header, nextimage);
|
||||
|
||||
});
|
||||
|
||||
window.addEventListener('scroll', event => {
|
||||
@@ -37,14 +59,14 @@ window.addEventListener('scroll', event => {
|
||||
let links = document.querySelector('#links');
|
||||
|
||||
if (window.pageYOffset !== 0) {
|
||||
nav.classList.add('bg-white');
|
||||
nav.classList.add('bg-white', 'border');
|
||||
nav.classList.remove('text-gray');
|
||||
links.classList.add('nav-dark');
|
||||
links.classList.remove('nav-light');
|
||||
}
|
||||
else {
|
||||
nav.classList.add('text-gray');
|
||||
nav.classList.remove('bg-white');
|
||||
nav.classList.remove('bg-white', 'border');
|
||||
links.classList.add('nav-light');
|
||||
links.classList.remove('nav-dark');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user