Slider update
This commit is contained in:
@@ -147,22 +147,26 @@ const allowedExtensions = [
|
|||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
* Load type of image, can be used to load images for different platforms (i.e. mobile optimization)
|
* Load type of image, can be used to load images for different platforms (i.e. mobile optimization)
|
||||||
* @param name - The name appended to the image filename
|
* @param postfix - What is appended to each image after a dash. Example: /path/to/image becomes /path/to/image-platform.jpg
|
||||||
|
* for postfix = platform
|
||||||
*/
|
*/
|
||||||
var loadImageType = (name) => {
|
var loadImageType = (postfix) => {
|
||||||
sliderElements.forEach(el => {
|
sliderElements.forEach(el => {
|
||||||
const baseURL = el.dataset.imageBaseURL;
|
const baseURL = el.dataset.imageBaseUrl;
|
||||||
const filetype = el.dataset.filetype;
|
const filetype = el.dataset.filetype;
|
||||||
// TODO: Verification (i.e. baseURL cannot contain .something in the end, filetype may only be jpg, jpeg, webp, svg or png)
|
|
||||||
if (allowedExtensions.indexOf(filetype) === -1) {
|
if (allowedExtensions.indexOf(filetype) === -1) {
|
||||||
console.warn('[ SLIDER ] Invalid filetype ' + filetype + ' for image element with id ' + el.id);
|
console.warn('[ SLIDER ] Invalid filetype ' + filetype + ' for image element with id ' + el.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (baseURL.lastIndexOf('.') > baseURL.lastIndexOf('/')) {
|
if (!baseURL) {
|
||||||
console.warn('[ SLIDER ] ImageBaseURL incorrect for image element with id ' + el.id);
|
console.error('[ SLIDER ] ImageBaseURL undefined for element with id ' + el.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
el.style.setProperty('background-image', baseURL + name + filetype);
|
if (baseURL.lastIndexOf('.') > baseURL.lastIndexOf('/')) {
|
||||||
|
console.warn('[ SLIDER ] ImageBaseURL incorrect for element with id ' + el.id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
el.style.backgroundImage = `url( ${baseURL}-${postfix + filetype} )`;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
for (const el in fetchedElements) {
|
for (const el in fetchedElements) {
|
||||||
|
|||||||
66
components/slider/ts/resize.ts
Normal file
66
components/slider/ts/resize.ts
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/* eslint-disable no-var */
|
||||||
|
interface SizeConfig {
|
||||||
|
[name: string]: {
|
||||||
|
'min-width': number;
|
||||||
|
'max-width': number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let sizeConfig: SizeConfig = {};
|
||||||
|
|
||||||
|
|
||||||
|
var resizeConfigure = ( config: SizeConfig ) => {
|
||||||
|
sizeConfig = config;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const handleResize = () => {
|
||||||
|
const sizes = Object.keys( sizeConfig );
|
||||||
|
|
||||||
|
for ( let i = 0; i < sizes.length; i++ ) {
|
||||||
|
const size = sizes[i];
|
||||||
|
|
||||||
|
if (
|
||||||
|
window.innerWidth < sizeConfig[ size ][ 'max-width' ]
|
||||||
|
&& window.innerWidth > sizeConfig[ size ][ 'min-width' ] ) {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const allowedExtensions = [
|
||||||
|
'webp',
|
||||||
|
'jpg',
|
||||||
|
'jpeg',
|
||||||
|
'svg',
|
||||||
|
'png'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load type of image, can be used to load images for different platforms (i.e. mobile optimization)
|
||||||
|
* @param postfix - What is appended to each image after a dash. Example: /path/to/image becomes /path/to/image-platform.jpg
|
||||||
|
* for postfix = platform
|
||||||
|
*/
|
||||||
|
const loadImageType = ( postfix: string ) => {
|
||||||
|
sliderElements.forEach( el => {
|
||||||
|
const baseURL = el.dataset.imageBaseUrl;
|
||||||
|
const filetype = el.dataset.filetype;
|
||||||
|
|
||||||
|
if ( allowedExtensions.indexOf( filetype ) === -1 ) {
|
||||||
|
console.warn( '[ SLIDER ] Invalid filetype ' + filetype + ' for image element with id ' + el.id );
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !baseURL ) {
|
||||||
|
console.error( '[ SLIDER ] ImageBaseURL undefined for element with id ' + el.id );
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( baseURL.lastIndexOf( '.' ) > baseURL.lastIndexOf( '/' ) ) {
|
||||||
|
console.warn( '[ SLIDER ] ImageBaseURL incorrect for element with id ' + el.id );
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
el.style.backgroundImage = `url( ${ baseURL }-${ postfix + filetype } )`;
|
||||||
|
} );
|
||||||
|
};
|
||||||
@@ -163,42 +163,6 @@ const stopSliderAutoAdvance = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const allowedExtensions = [
|
|
||||||
'webp',
|
|
||||||
'jpg',
|
|
||||||
'jpeg',
|
|
||||||
'svg',
|
|
||||||
'png'
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load type of image, can be used to load images for different platforms (i.e. mobile optimization)
|
|
||||||
* @param name - The name appended to the image filename
|
|
||||||
*/
|
|
||||||
|
|
||||||
var loadImageType = ( name: string ) => {
|
|
||||||
sliderElements.forEach( el => {
|
|
||||||
const baseURL = el.dataset.imageBaseURL;
|
|
||||||
const filetype = el.dataset.filetype;
|
|
||||||
|
|
||||||
// TODO: Verification (i.e. baseURL cannot contain .something in the end, filetype may only be jpg, jpeg, webp, svg or png)
|
|
||||||
if ( allowedExtensions.indexOf( filetype ) === -1 ) {
|
|
||||||
console.warn( '[ SLIDER ] Invalid filetype ' + filetype + ' for image element with id ' + el.id );
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( baseURL.lastIndexOf( '.' ) > baseURL.lastIndexOf( '/' ) ) {
|
|
||||||
console.warn( '[ SLIDER ] ImageBaseURL incorrect for image element with id ' + el.id );
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
el.style.setProperty( 'background-image', baseURL + name + filetype );
|
|
||||||
} );
|
|
||||||
};
|
|
||||||
|
|
||||||
for ( const el in fetchedElements ) {
|
for ( const el in fetchedElements ) {
|
||||||
if ( fetchedElements[ el ].className ) {
|
if ( fetchedElements[ el ].className ) {
|
||||||
sliderElements.push( ( fetchedElements[ el ] as HTMLDivElement ) );
|
sliderElements.push( ( fetchedElements[ el ] as HTMLDivElement ) );
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ nav a:hover {
|
|||||||
z-index: 100;
|
z-index: 100;
|
||||||
background-color: var(--color-background-accent);
|
background-color: var(--color-background-accent);
|
||||||
transition: left 0.5s, top 0.5s;
|
transition: left 0.5s, top 0.5s;
|
||||||
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-top-bar {
|
.nav-top-bar {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ a {
|
|||||||
|
|
||||||
.slider {
|
.slider {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: calc(100vw / 16 * 11);
|
height: 80vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slider-element {
|
.slider-element {
|
||||||
@@ -262,11 +262,6 @@ a {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (min-width: 800px) {
|
@media only screen and (min-width: 800px) {
|
||||||
.slider {
|
|
||||||
width: 100vw;
|
|
||||||
height: 80vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slider-controls {
|
.slider-controls {
|
||||||
font-size: 3rem;
|
font-size: 3rem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,11 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=7" />
|
<meta http-equiv="X-UA-Compatible" content="IE=7" />
|
||||||
<meta name="keywords" content="software store, custom software, foss" />
|
<meta name="keywords" content="software store, custom software, foss" />
|
||||||
<meta name="description" content="Discover amazing software projects like ConductorCalc, libreevent, a secure and reliable authentication system and much more and get support for it all" />
|
<meta name="description"
|
||||||
|
content="Discover amazing software projects like ConductorCalc, libreevent, a secure and reliable authentication system and much more and get support for it all" />
|
||||||
<meta name="og:title" content="janishutz.com - software to make your life easier" />
|
<meta name="og:title" content="janishutz.com - software to make your life easier" />
|
||||||
<meta name="og:description" content="Discover projects, services and more developed by Janis Hutz, get support and more!" />
|
<meta name="og:description"
|
||||||
|
content="Discover projects, services and more developed by Janis Hutz, get support and more!" />
|
||||||
<meta name="og:image" content="https://static.janishutz.com/logo.jpg" />
|
<meta name="og:image" content="https://static.janishutz.com/logo.jpg" />
|
||||||
<meta name="og:type" content="website" />
|
<meta name="og:type" content="website" />
|
||||||
<meta name="og:url" content="https://janishutz.com" />
|
<meta name="og:url" content="https://janishutz.com" />
|
||||||
@@ -29,32 +31,33 @@
|
|||||||
<!-- <video src="https://static.janishutz.com/assets/video-home.mp4" autoplay class="title-video"></video> -->
|
<!-- <video src="https://static.janishutz.com/assets/video-home.mp4" autoplay class="title-video"></video> -->
|
||||||
<div class="slider">
|
<div class="slider">
|
||||||
<div class="slider-container">
|
<div class="slider-container">
|
||||||
<div class="slider-element current"
|
<div id="conductorcalc" class="slider-element current"
|
||||||
style="background-image: url( 'https://static.janishutz.com/assets/home/conductorcalc.jpg' );">
|
data-image-base-url="https://static.janishutz.com/assets/home/conductorcalc" data-filetype="jpg">
|
||||||
<div class="slider-info">
|
<div class="slider-info">
|
||||||
<h2>ConductorCalc</h2>
|
<h2>ConductorCalc</h2>
|
||||||
<p>The perfect tool to aid you in the complex calculations necessary when building high voltage lines</p>
|
<p>The perfect tool to aid you in the complex calculations necessary when building high voltage
|
||||||
|
lines</p>
|
||||||
<a href="https://conductorcalc.com" class="button" target="_blank">Check it out</a>
|
<a href="https://conductorcalc.com" class="button" target="_blank">Check it out</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="slider-element"
|
<div id="musicplayer" class="slider-element"
|
||||||
style="background-image: url( 'https://static.janishutz.com/assets/projects/musicplayer-title.jpg' );">
|
data-image-base-url="https://static.janishutz.com/assets/projects/musicplayer" data-filetype="jpg">
|
||||||
<div class="slider-info">
|
<div class="slider-info">
|
||||||
<h2>MusicPlayer</h2>
|
<h2>MusicPlayer</h2>
|
||||||
<p>Your one-stop solution for music at your next party</p>
|
<p>Your one-stop solution for music at your next party</p>
|
||||||
<a href="/projects/musicplayer" class="button">Check it out</a>
|
<a href="/projects/musicplayer" class="button">Check it out</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="slider-element"
|
<div id="libreevent" class="slider-element"
|
||||||
style="background-image: url( 'https://store-cdn.janishutz.com/assets/libreevent/libreevent-title.jpg' );">
|
data-image-base-url="https://static.janishutz.com/assets/projects/libreevent" data-filetype="jpg">
|
||||||
<div class="slider-info">
|
<div class="slider-info">
|
||||||
<h2>libreǝvent</h2>
|
<h2>libreǝvent</h2>
|
||||||
<p>The all-in-one solution for your next event!</p>
|
<p>The all-in-one solution for your next event!</p>
|
||||||
<a href="https://libreevent.janishutz.com" class="button" target="_blank">Check it out</a>
|
<a href="https://libreevent.janishutz.com" class="button" target="_blank">Check it out</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="slider-element"
|
<div id="foss" data-image-base-url="https://static.janishutz.com/assets/home/foss" data-filetype="jpg"
|
||||||
style="background-image: url( 'https://static.janishutz.com/assets/home/foss.jpg' );">
|
class="slider-element">
|
||||||
<div class="slider-info">
|
<div class="slider-info">
|
||||||
<h2>Open Source Projects</h2>
|
<h2>Open Source Projects</h2>
|
||||||
<p>Free Software, developed by Janis Hutz & the community</p>
|
<p>Free Software, developed by Janis Hutz & the community</p>
|
||||||
@@ -118,7 +121,10 @@
|
|||||||
<footer></footer>
|
<footer></footer>
|
||||||
|
|
||||||
<script src="https://static.janishutz.com/js/slider.js"></script>
|
<script src="https://static.janishutz.com/js/slider.js"></script>
|
||||||
<script>activateSlider(7500)</script>
|
<script>
|
||||||
|
activateSlider(7500);
|
||||||
|
loadImageType('desktop');
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user