LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

This is a Post Title

I’m currently working on a project in which I require a Slides.com presentation to control a meteor app that pushes content to subscribers whenever slides change. This required the creator of the slide deck to sync their deck to the content they created in my app. Simple enough? But Slides.com doesn’t have a public API, so there is no direct way to accomplish this. I decided to create a Chrome extension that allows the author of the slide deck to authenticate their credentials with my Meteor application and sync their slide deck to the app. Check out my publicGitHub repo for the full extension code.

You should click on this post title. You wont believe what happens next.

I’m currently working on a project in which I require a Slides.com presentation to control a meteor app that pushes content to subscribers whenever slides change. This required the creator of the slide deck to sync their deck to the content they created in my app. Simple enough? But Slides.com doesn’t have a public API, so there is no direct way to accomplish this. I decided to create a Chrome extension that allows the author of the slide deck to authenticate their credentials with my Meteor application and sync their slide deck to the app. Check out my publicGitHub repo for the full extension code.

This is a Post Title

I’m currently working on a project in which I require a Slides.com presentation to control a meteor app that pushes content to subscribers whenever slides change. This required the creator of the slide deck to sync their deck to the content they created in my app. Simple enough? But Slides.com doesn’t have a public API, so there is no direct way to accomplish this. I decided to create a Chrome extension that allows the author of the slide deck to authenticate their credentials with my Meteor application and sync their slide deck to the app. Check out my publicGitHub repo for the full extension code.

CSS
@import url(https://fonts.googleapis.com/css?family=Lora:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700);
h1, h2, h3 {
  font-family: "Lora", Helvetica, serif;
}

h1 {
  font-size: 4rem;
}

h3 {
  font-size: 2.5rem;
}

body {
  font-family: "Source Sans Pro", Helvetica, sans-serif;
}

.post-item {
  width: 100%;
  position: relative;
  padding: 2rem;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
  margin-bottom: .5rem;
  z-index: 1;
  opacity: 0;
}
.post-item:hover:not(.active) .post-link {
  color: #27073A;
}
.post-item:hover:not(.active) .post-date {
  background-color: #27073A;
  color: white;
}
.post-item.active {
  z-index: 100;
}
.post-item.active .post-content {
  opacity: 1;
  -webkit-transform: translateY(0px);
          transform: translateY(0px);
  max-height: 2000px;
  -webkit-transition: all 600ms ease-out 600ms;
  transition: all 600ms ease-out 600ms;
}
.post-item.active .post-title {
  color: white;
}

.featured-image {
  position: absolute;
  top: 0;
  left: 0%;
  height: 100%;
  width: 100%;
  background-size: cover;
  background-position: center center;
  z-index: -1;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
}

.post-heading {
  width: 100%;
  padding: 2rem 0rem;
  -webkit-transition: opacity 600ms ease-out;
  transition: opacity 600ms ease-out;
}

.post-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
}
.post-overlay svg {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  pointer-events: none;
}
.post-overlay path {
  stroke-opacity: .5;
  stroke-width: 2;
}

.post-content {
  position: absolute;
  left: 0;
  top: 100;
  height: 100%;
  width: 100%;
  max-width: 600px;
  background-color: white;
  padding: 2rem;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  -webkit-transition: opacity 300ms ease-out;
  transition: opacity 300ms ease-out;
  -webkit-transform: translateY(50px);
          transform: translateY(50px);
  pointer-events: none;
}
.post-content .post-title {
  margin-bottom: 1.5rem;
}

.post-title {
  max-width: 700px;
  -webkit-transition: all 1000ms ease-out 200ms;
  transition: all 1000ms ease-out 200ms;
  cursor: pointer;
}

.post-body p {
  line-height: 1.6rem;
}

.post-link {
  color: white;
  line-height: 3rem;
  -webkit-transition: all 1000ms ease-out 200ms;
  transition: all 1000ms ease-out 200ms;
}

.post-date {
  padding: .5rem;
  background-color: white;
  color: #27073A;
  float: left;
}
JS
var defaultEasing = Power4.easeOut;

function animateTriangles(post, direction){
  var triangles = $(post).find('path');
	var postItemWidth = $(post).find('.post-link').outerWidth();
  _.each(triangles, function(triangle, index){
    var offsetLeft = triangle.getBoundingClientRect().left - 100;
    var props = {};
    
    if (direction === 'reset'){
      var props = {
        opacity: 1,
        fill: "#fff",
        stroke: "#fff",
        ease: defaultEasing,
        delay:  ((triangles.length) - (index)) / 1000
      }
      TweenMax.to(triangle, .5, props);
    } else if (direction === 'in' && offsetLeft < postItemWidth){   
      var props = {
        fill: "#fff",
        stroke: "#fff",
        ease: defaultEasing,
        delay: ((triangles.length) - (index)) / 1000
      }
      TweenMax.to(triangle, 1, props);
      
    } else if (direction === 'out' && offsetLeft < postItemWidth ){
       var props = {
        fill: "#27073A",
        stroke: "#27073A",
        ease: defaultEasing,
        delay: ((triangles.length) - (index)) / 1000
      }
      TweenMax.to(triangle, .3, props);
      
    } else if (direction === 'inAndOut'){
       var propsIn = {
         fill: "#27073A",
         stroke: "#27073A",
         ease: defaultEasing,
         delay: ((triangles.length) - (index)) / 1000
       }
       
       var propsOut = {
         fill: "#fff",
         stroke: '#fff',
         opacity: 0,
         ease: defaultEasing,
         delay: ((triangles.length) - (index)) / 900
       }
       
       TweenMax.to(triangle, .6, propsIn);
       TweenMax.to(triangle, 1, propsOut);
    }
  })                 
}

function animatePostsOut(posts){
  var activePost = $('.post-item.active');
  var offset = activePost.offset().top
  console.log(offset);
  
  _.each(posts, function(post){
    if (!$(post).hasClass('active')){
      TweenMax.to(post, .3, {opacity: 0, ease: defaultEasing})
    } else {
       TweenMax.to(post, .6, {top: -offset, ease: defaultEasing, delay: .5})
    }
  })
}

function animatePostsIn(posts){
  _.each(posts, function(post){
    if (!$(post).hasClass('active')){
      TweenMax.to(post, .3, {opacity: 1, top: 0, ease: defaultEasing});
    }
  })
}

$(function(){

  var posts = $('.post-item');
  
  _.each(posts, function(post, index){

    TweenMax.to(post, .1, {opacity: 1});

    var height = $(post).outerHeight();
    var width = $(post).outerWidth();
    var postOverlay = $(post).find('.post-overlay');

    var pattern = Trianglify({
      width: width, 
      height: height,
      x_colors: ['#fff', '#fff'],
      cell_size: 40
    });

    postOverlay.append(pattern.svg());

    var triangles = postOverlay.find('path');
    var postItemWidth = $(post).find('.post-link').outerWidth();
    animateTriangles(post, 'out');
  })

  $('.post-item').on('mouseenter', function(e){
    var post = this;
    if (!$(post).hasClass('active')){
      animateTriangles(post, 'in');
    }
  });

  $('.post-item').on('mouseleave', function(e){
    var post = this;
    if (!$(post).hasClass('active')){
      animateTriangles(post, 'out');   
    }
  });

  $('.post-item').on('click', function(e){
    e.preventDefault();
    var post = this;
    $(post).toggleClass('active');
    if ($(post).hasClass('active')){ 
      animatePostsOut(posts); 
      animateTriangles(post, 'inAndOut');
    } else {
       animatePostsIn(posts); 
       animateTriangles(post, 'reset');
    }
  })
});
Host Instantly Drag and Drop Website Builder

 

Description

Using trianglify javascript plugin and GSAP, this effect animates svg triangles in and out on hover, and then provides a neat post loading transition effect when a post title is clicked.
Term
Mon, 11/27/2017 - 22:07

Related Codes

Pen ID
Pen ID
Pen ID