Skip to main content

Animated Frame Slideshow slideshow, javascript, frame, animation, svg, shape, path, web design


Animated Frame Slideshow







https://animejs.com/



artspider designerhttps://www.youtube.com/channel/UCD10SZSEyZCFAR4DFx_uNyg



SOURCE CODE



HTML SOURCE_CODE:-
index .html

👇


<!DOCTYPE html>
<html lang="en" class="no-js">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Animated Frame Slideshow </title>
        <meta name="description" content="A slideshow that shows an animated SVG frame on the transitions between slides" />
        <meta name="keywords" content="slideshow, javascript, frame, animation, svg, shape, path, web design "/>
        <meta name"author" content="Codrops" />

        <link rel="stylesheet" type="text/css" href="css/base.css" />
        <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
    
    </head>
    <body class="demo-6 loading">
        <div class="header">
            <a href="#" class="logo">
                T.
              </a>
              <div class="loc">
                <ul>
                  <li><a href="#">HOME</a></li>
                  <li><a href="#">ABOUT US</a></li>
                  <li><a href="#">SERVICE</a></li>
                  <li><a href="#">CONTACT</a></li>
                  
            
            </div>
            </div>
        <main>
            
            <div class="slideshow">
                <div class="slides slides--images">
                    <div class="slide slide--current">
                        <div class="slide__img" style="background-image: url(img/13.jpg) "></div>
                    </div>
                    <div class="slide">
                        <div class="slide__img" style="background-image: url(img/14.jpg) "></div>
                    </div>
                    <div class="slide">
                        <div class="slide__img" style="background-image: url(img/15.jpg) "></div>
                    </div>
                    <div class="slide">
                        <div class="slide__img" style="background-image: url(img/16.jpg) "></div>
                    </div>
                </div>
                <div class="slides slides--titles">
                    <div class="slide slide--current">
                        <h2 class="slide__title">Artspider</h2>
                    </div>
                    <div class="slide">
                        <h2 class="slide__title">Discover</h2>
                    </div>
                    <div class="slide">
                        <h2 class="slide__title">Design</h2>
                    </div>
                    <div class="slide">
                        <h2 class="slide__title">Create</h2>
                    </div>
                    
                </div>
                <nav class="slidenav">
                    <button class="slidenav__item slidenav__item--prev" ><i class="fas fa-arrow-alt-circle-left" id="pr_button"></i></button>
                    
                    <button class="slidenav__item slidenav__item--next" ><i class="fas fa-arrow-alt-circle-right" id="ne_button"></i></button>
                </nav>
            </div>
        </main>
        <script src="js/demo.js"></script>
        <script src="js/imagesloaded.pkgd.min.js"></script>
        <script src="js/anime.min.js"></script>
        <script src="js/demo6.js"></script>
    </body>
</html>


CSS SOURCE_CODE:-


*,
*::after,
*::before {
    padding0;
    margin0;
    box-sizingborder-box;
}

html {
    background#fff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI"HelveticaArialsans-serif;
    min-height100vh;
    color#57585c;
    colorvar(--color-text);
    background-color#fff;
    background-colorvar(--color-bg);
    -webkit-font-smoothingantialiased;
    -moz-osx-font-smoothinggrayscale;
}
.header{
    positionabsolute;
    top0;
    left0;
    width100%;
    padding:10px 100px;
    displayflex;
    justify-content:space-between;
    align-itemscenter;
    z-index400;

  }
  .logo{
    positionrelative;
    max-width60px;
   font-size35px;
   transformrotate(360deg);
   font-familycursive;
transition0.5s;
colorrgb(235235235); 
text-decorationnone;


  }
  .logo:hover{
transformrotate(0deg);
colorrgb(101010);

  }

  .header ul{
    positionrelative;
    displayflex;
    
  }
  .header ul li{
    list-stylenone;
  }
  .header ul li a{
    displayinline-block;
    colorrgb(240239245);
    font-weight400;
    margin-left40px;
    text-decorationnone;
    font-size12px;
    font-familysans-serif;
    transition.5s;
    }
    .header ul li a:hover{
    
        colorrgb(23321818);
       
        }

       

/* Color schemes */
.slide__img{
     background-sizecover;
}

.demo-6 {
    --color-textrgb(235228228);
    --color-bg#303030;
    --color-linkrgb(246245245);
    --color-link-hover#f5f841;
    --color-stitle#e9e6e6;
    --fontsize-stitle12vw;
    --color-navrgb(240238238);
    --color-nav-hover#f5f841;
}

/* Fade effect */
.js body {
    opacity0;
    transition: opacity 0.3s;
}

.js body.render {
    opacity1;
}




main {
    positionrelative;
    width100%;
}

.content {
    positionrelative;
    displayflex;
    justify-contentcenter;
    align-itemscenter;
    margin0 auto;
    min-height100vh;
}

.content--fixed {
    positionfixed;
    z-index10000;
    top0;
    left0;
    displaygrid;
    align-contentspace-between;
    width100%;
    max-widthnone;
    min-height0;
    height100vh;
    padding1.5em;
    pointer-eventsnone;
    grid-template-columns50% 50%;
    grid-template-rowsauto auto 4em;
    grid-template-areas'header github'
    '... ...'
    '... demos';
}

.content--fixed a {
    pointer-eventsauto;
}



.demos {
    positionrelative;
    displayblock;
    align-selfend;
    text-aligncenter;
    grid-area: demos;
}

.demo {
    margin0 0.15em;
}

.demo:hover,
.demo:focus {
    opacity0.5;
}

.demo span {
    white-spacenowrap;
    text-transformlowercase;
    pointer-eventsnone;
}

.demo span::before {
    content'#';
}

a.demo--current {
    pointer-eventsnone;
}
#pr_button {

    font-size50px;
}
#ne_button {
    
    font-size50px;
}


.slideshow {
    width100%;
    height100vh;
    positionrelative;
    overflowhidden;
}

.slides {
    positionabsolute;
    width100%;
    height100%;
}

.slide {
    positionabsolute;
    width100%;
    height100%;
    overflowhidden;
    opacity0;
    pointer-eventsnone;
    displayflex;
    flex-directioncolumn;
    align-contentcenter;
    justify-contentcenter;
    align-itemscenter;
}

.slide--current {
    opacity1;
    pointer-eventsauto;
}

.slide__img {
    positionabsolute;
    top-200px;
    left-200px;
    widthcalc(100% + 400px);
    heightcalc(100% + 400px);
    background-sizecover;
    background-position50% 50%;
}

.slidenav {
    positionabsolute;
    width300px;
    margin-left-150px;
    left90%;
    bottom0;
    
    padding2em;
}

.slidenav__item {
    border0;
    backgroundnone;
    font-weightbold;
    colorvar(--color-nav);
}

.slidenav__item:focus {
    outlinenone;
}

.slidenav__item:hover {
    colorvar(--color-nav-hover);
}

.shape {
    positionabsolute;
    width100%;
    height100%;
    fillvar(--color-shape-fill);
    top0;
    pointer-eventsnone;
}

.slide__title {
    positionrelative;
    font-sizevar(--fontsize-stitle);
    margin0;
    cursordefault;
    line-height1;
    colorvar(--color-stitle);
}

.slide__desc {
    positionrelative;
    font-size1.5em;
    margin0 0 2em 0;
    cursordefault;
    colorvar(--color-sdesc);
    padding0 1em;
    text-aligncenter;
}

.slide__link {
    positionrelative;
    font-size1em;
    font-weightbold;
    padding1em 2em;
    displayblock;
    colorvar(--color-slink);
    backgroundvar(--color-slink-bg);
    transitioncolor 0.3sbackground 0.3s;
}

.slide__link:hover {
    colorvar(--color-slink-hover);
    backgroundvar(--color-slink-hover-bg);
}



Javascript (.js file) SOURCE_CODE:-


{
    setTimeout(() => document.body.classList.add('render'), 60);
    const navdemos = Array.from(document.querySelectorAll('nav.demos > .demo'));
    const navigate = (linkEl=> {
        document.body.classList.remove('render');
        document.body.addEventListener('transitionend', () => window.location = linkEl.href);
    };
    navdemos.forEach(link => link.addEventListener('click', (ev=> {
        ev.preventDefault();
        navigate(ev.target);
    }));
}



{
    
    function debounce(funcwaitimmediate) {
        var timeout;
        return function() {
            var context = thisargs = arguments;
            var later = function() {
                timeout = null;
                if (!immediatefunc.apply(contextargs);
            };
            var callNow = immediate && !timeout;
            clearTimeout(timeout);
            timeout = setTimeout(laterwait);
            if (callNowfunc.apply(contextargs);
        };
    };
    
    class Slideshow {
        constructor(el) {
            this.DOM = {};
            this.DOM.el = el;
            this.settings = {
                animation: {
                    slides: {
                        duration: 1000,
                        easing: 'easeOutQuint'
                    },
                    shape: {
                        duration: 300,
                        easing: {in: 'easeOutQuint'out: 'easeOutQuad'}
                    }
                },
                frameFill: 'url(#gradient1)'
            }
            this.init();
        }
        init() {
            this.DOM.slides = Array.from(this.DOM.el.querySelectorAll('.slides--images > .slide'));
            this.slidesTotal = this.DOM.slides.length;
            this.DOM.nav = this.DOM.el.querySelector('.slidenav');
            this.DOM.titles = this.DOM.el.querySelector('.slides--titles');
            this.DOM.titlesSlides = Array.from(this.DOM.titles.querySelectorAll('.slide'));
            this.DOM.nextCtrl = this.DOM.nav.querySelector('.slidenav__item--next');
            this.DOM.prevCtrl = this.DOM.nav.querySelector('.slidenav__item--prev');
            this.current = 0;
            this.createFrame(); 
            this.initEvents();
        }
        createFrame() {
            this.rect = this.DOM.el.getBoundingClientRect();
            this.frameSize = this.rect.width/12;
            this.paths = {
                initial: this.calculatePath('initial'),
                final: this.calculatePath('final')
            };
            this.DOM.svg = document.createElementNS('http://www.w3.org/2000/svg''svg');
            this.DOM.svg.setAttribute('class''shape');
            this.DOM.svg.setAttribute('width','100%');
            this.DOM.svg.setAttribute('height','100%');
            this.DOM.svg.setAttribute('viewbox',`0 0 ${this.rect.width} ${this.rect.height}`);
            this.DOM.svg.innerHTML = `
            <defs>
            <linearGradient id="gradient1" x1="0%" y1="0%" x2="0%" y2="100%">
                <stop offset="0%" stop-color="#09012d"/>
                <stop offset="100%" stop-color="#0f2b73"/>
            </linearGradient>
            </defs>
            <path fill="${this.settings.frameFill}" d="${this.paths.initial}"/>`;
            this.DOM.el.insertBefore(this.DOM.svgthis.DOM.titles);
            this.DOM.shape = this.DOM.svg.querySelector('path');
        }
        updateFrame() {
            this.paths.initial = this.calculatePath('initial');
            this.paths.final = this.calculatePath('final');
            this.DOM.svg.setAttribute('viewbox',`0 0 ${this.rect.width} ${this.rect.height}`);
            this.DOM.shape.setAttribute('d'this.isAnimating ? this.paths.final : this.paths.initial);
        }
        calculatePath(path = 'initial') {

            if ( path === 'initial' ) {
                return `M 0,0 0,${this.rect.height} ${this.rect.width},${this.rect.height} ${this.rect.width},0 0,0 Z M 0,0 ${this.rect.width},0 ${this.rect.width},${this.rect.height} 0,${this.rect.height} Z`;
            }
            else {
                const point1 = {x: this.rect.width/4-50y: this.rect.height/4+50};
                const point2 = {x: this.rect.width/4+50y: this.rect.height/4-50};
                const point3 = {x: this.rect.width-point2.xy: this.rect.height-point2.y};
                const point4 = {x: this.rect.width-point1.xy: this.rect.height-point1.y};

                return `M 0,0 0,${this.rect.height} ${this.rect.width},${this.rect.height} ${this.rect.width},0 0,0 Z M ${point1.x},${point1.y} ${point2.x},${point2.y} ${point4.x},${point4.y} ${point3.x},${point3.y} Z`;
            }
        }
        initEvents() {
            this.DOM.nextCtrl.addEventListener('click', () => this.navigate('next'));
            this.DOM.prevCtrl.addEventListener('click', () => this.navigate('prev'));
            
            window.addEventListener('resize'debounce(() => {
                this.rect = this.DOM.el.getBoundingClientRect();
                this.updateFrame();
            }, 20));
            
            document.addEventListener('keydown', (ev=> {
                const keyCode = ev.keyCode || ev.which;
                if ( keyCode === 37 ) {
                    this.navigate('prev');
                }
                else if ( keyCode === 39 ) {
                    this.navigate('next');
                }
            });
        }
        navigate(dir = 'next') {
            if ( this.isAnimating ) return false;
            this.isAnimating = true;

            const animateShapeIn = anime({
                targets: this.DOM.shape,
                duration: this.settings.animation.shape.duration,
                easing: this.settings.animation.shape.easing.in,
                d: this.paths.final
            });

            const animateSlides = () => {
                return new Promise((resolvereject=> {
                    const currentSlide = this.DOM.slides[this.current];
                    anime({
                        targets: currentSlide,
                        duration: this.settings.animation.slides.duration,
                        easing: this.settings.animation.slides.easing,
                        translateY: dir === 'next' ? this.rect.height : -1*this.rect.height,
                        complete: () => {
                            currentSlide.classList.remove('slide--current');
                            resolve();
                        }
                    });

                    const currentTitleSlide = this.DOM.titlesSlides[this.current];
                    anime({
                        targets: currentTitleSlide.children,
                        duration: this.settings.animation.slides.duration,
                        easing: this.settings.animation.slides.easing,
                        delay: (t,i,total=> dir === 'next' ? i*100 : (total-i-1)*100,
                        translateY: [0dir === 'next' ? 100 : -100],
                        opacity: [1,0],
                        complete: () => {
                            currentTitleSlide.classList.remove('slide--current');
                            resolve();
                        }
                    });
        
                    this.current = dir === 'next' ? 
                        this.current < this.slidesTotal-1 ? this.current + 1 : 0 :
                        this.current > 0 ? this.current - 1 : this.slidesTotal-1
                    
                    const newSlide = this.DOM.slides[this.current];
                    newSlide.classList.add('slide--current');
                    anime({
                        targets: newSlide,
                        duration: this.settings.animation.slides.duration,
                        easing: this.settings.animation.slides.easing,
                        translateY: [dir === 'next' ? -1*this.rect.height : this.rect.height,0]
                    });
        
                    const newSlideImg = newSlide.querySelector('.slide__img');
                    
                    anime.remove(newSlideImg);
                    anime({
                        targets: newSlideImg,
                        duration: this.settings.animation.slides.duration*3,
                        easing: this.settings.animation.slides.easing,
                        translateY: [dir === 'next' ? -100 : 1000],
                        scale: [0.2,1]
                    });
                    
                    const newTitleSlide = this.DOM.titlesSlides[this.current];
                    newTitleSlide.classList.add('slide--current');
                    anime({
                        targets: newTitleSlide.children,
                        duration: this.settings.animation.slides.duration*1.5,
                        easing: this.settings.animation.slides.easing,
                        delay: (t,i,total=> dir === 'next' ? i*100+100 : (total-i-1)*100+100,
                        translateY: [dir === 'next' ? -100 : 100 ,0],
                        opacity: [0,1]
                    });
                });
            };

            const animateShapeOut = () => {
                anime({
                    targets: this.DOM.shape,
                    duration: this.settings.animation.shape.duration,
                    easing: this.settings.animation.shape.easing.out,
                    d: this.paths.initial,
                    complete: () => this.isAnimating = false
                });
            }

            animateShapeIn.finished.then(animateSlides).then(animateShapeOut);
        }
    };

    new Slideshow(document.querySelector('.slideshow'));
    imagesLoaded('.slide__img', { background: true }, () => document.body.classList.remove('loading'));
};


web design video My YOUTUBE channel




Tags:  
slideshow, javascript, frame, animation, svg, shape, path, web design





Comments

Popular posts from this blog

Create A Pizza Website Using HTML And CSS and GSAP| Page transition animation by gsap. Artspider

https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js SOURCE CODE HTML  SOURCE_CODE:- index .html 👇 <! DOCTYPE   html > < html > < head >      < meta   charset = 'utf-8' >      < meta   http-equiv = 'X-UA-Compatible'   content = 'IE=edge' >      < title > home page transion </ title >      < meta   name = 'viewport'   content = 'width=device-width, initial-scale=1' >      < link   rel = 'stylesheet'   type = 'text/css'   media = 'screen'   href = 'main.css' >      </ head > < body   >          < div   class = "cover" >          < img   src = "img/logo.png"   alt = ""   class = "logo" >      ...

How To Make A Website Using HTML CSS & Bootstrap | Personal Portfolio Website Design Tutorial

How To Make A Website Using HTML CSS & Bootstrap | Personal Portfolio Website Design Tutorial SOURCE CODE HTML  SOURCE_CODE:- index .html 👇 <!DOCTYPE html> <html> <head>     <meta charset='utf-8'>     <meta http-equiv='X-UA-Compatible' content='IE=edge'>     <title>Page Title</title>     <meta name='viewport' content='width=device-width, initial-scale=1'>     <!-- Google Fonts -->   <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Raleway:300,300i,400,400i,500,500i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">   <!-- Vendor CSS Files -->   <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">   <link href="assets/vendor/icofont/icofont.min.css" rel="stylesheet">   <link href="assets/v...

How to create Page transition animation by Greensock (gsap)?

 Create Page transition animation by Greensock (gsap) https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js SOURCE CODE HTML  SOURCE_CODE:- index .html 👇 <! DOCTYPE   html > < html > < head >      < meta   charset = 'utf-8' >      < meta   http-equiv = 'X-UA-Compatible'   content = 'IE=edge' >      < title >  index Page  </ title >      < meta   name = 'viewport'   content = 'width=device-width, initial-scale=1' >      < link   rel = 'stylesheet'   type = 'text/css'   media = 'screen'   href = 'main.css' >      </ head > < body >      < div   class = "header" >          < a   href = "#" >         ...