Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fadeout feature and made bounce-in/fadeout stay on-work #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
128 changes: 127 additions & 1 deletion css/style.css
Expand Up @@ -182,6 +182,12 @@ header h1 {
-moz-animation: cd-bounce-1 0.6s;
animation: cd-bounce-1 0.6s;
}
.cssanimations .cd-timeline-img.bounce-out {
visibility: hidden;
-webkit-animation: cd-bounce-3 0.6s;
-moz-animation: cd-bounce-3 0.6s;
animation: cd-bounce-3 0.6s;
}
}

@-webkit-keyframes cd-bounce-1 {
Expand Down Expand Up @@ -241,6 +247,68 @@ header h1 {
transform: scale(1);
}
}

@-webkit-keyframes cd-bounce-3 {
0% {
opacity: 1;
-webkit-transform: scale(0.5);
}

60% {
opacity: 1;
-webkit-transform: scale(1.2);
}

100% {
opacity: 0;
-webkit-transform: scale(0);
}
}
@-moz-keyframes cd-bounce-3 {
0% {
opacity: 1;
-webkit-transform: scale(0.5);
}

60% {
opacity: 1;
-webkit-transform: scale(1.2);
}

100% {
opacity: 0;
-webkit-transform: scale(0);
}
}
@keyframes cd-bounce-3 {
0% {
opacity: 1;
-webkit-transform: scale(0.5);
-moz-transform: scale(0.5);
-ms-transform: scale(0.5);
-o-transform: scale(0.5);
transform: scale(0.5);
}

60% {
opacity: 1;
-webkit-transform: scale(1.2);
-moz-transform: scale(1.2);
-ms-transform: scale(1.2);
-o-transform: scale(1.2);
transform: scale(1.2);
}

100% {
opacity: 0;
-webkit-transform: scale(0);
-moz-transform: scale(0);
-ms-transform: scale(0);
-o-transform: scale(0);
transform: scale(0);
}
}

.cd-timeline-content {
position: relative;
margin-left: 60px;
Expand Down Expand Up @@ -293,7 +361,7 @@ header h1 {
border: 7px solid transparent;
border-right: 7px solid white;
}
@media only screen and (min-width: 768px) {
@media only screen and (min-width: 1170px) {
.cd-timeline-content h2 {
font-size: 20px;
font-size: 1.25rem;
Expand Down Expand Up @@ -357,6 +425,11 @@ header h1 {
-moz-animation: cd-bounce-2 0.6s;
animation: cd-bounce-2 0.6s;
}
.cssanimations .cd-timeline-content.bounce-out {
-webkit-animation: cd-bounce-4-inverse 0.6s;
-moz-animation: cd-bounce-4-inverse 0.6s;
animation: cd-bounce-4-inverse 0.6s;
}
}

@media only screen and (min-width: 1170px) {
Expand All @@ -366,6 +439,11 @@ header h1 {
-moz-animation: cd-bounce-2-inverse 0.6s;
animation: cd-bounce-2-inverse 0.6s;
}
.cssanimations .cd-timeline-block:nth-child(even) .cd-timeline-content.bounce-out {
-webkit-animation: cd-bounce-4 0.6s;
-moz-animation: cd-bounce-4 0.6s;
animation: cd-bounce-4 0.6s;
}
}
@-webkit-keyframes cd-bounce-2 {
0% {
Expand Down Expand Up @@ -481,3 +559,51 @@ header h1 {
transform: translateX(0);
}
}

@-webkit-keyframes cd-bounce-4 {
0% {
opacity: 1;
}

100% {
opacity: 0;
-webkit-transform: translate3d(100px, 0, 0);
transform: translate3d(100px, 0, 0);
}
}

@keyframes cd-bounce-4 {
0% {
opacity: 1;
}

100% {
opacity: 0;
-webkit-transform: translate3d(100px, 0, 0);
transform: translate3d(100px, 0, 0);
}
}

@-webkit-keyframes cd-bounce-4-inverse {
0% {
opacity: 1;
}

100% {
opacity: 0;
-webkit-transform: translate3d(-100px, 0, 0);
transform: translate3d(-100px, 0, 0);
}
}

@keyframes cd-bounce-4-inverse {
0% {
opacity: 1;
}

100% {
opacity: 0;
-webkit-transform: translate3d(-100px, 0, 0);
transform: translate3d(-100px, 0, 0);
}
}
10 changes: 8 additions & 2 deletions js/main.js
Expand Up @@ -9,10 +9,16 @@ jQuery(document).ready(function($){
});

//on scolling, show/animate timeline blocks when enter the viewport
//fadeout/animate timeline when scrollup the viewport
$(window).on('scroll', function(){
$timeline_block.each(function(){
if( $(this).offset().top <= $(window).scrollTop()+$(window).height()*0.75 && $(this).find('.cd-timeline-img').hasClass('is-hidden') ) {
$(this).find('.cd-timeline-img, .cd-timeline-content').removeClass('is-hidden').addClass('bounce-in');
if( $(this).offset().top < $(window).scrollTop()+$(window).height()*0.75 && $(this).find('.cd-timeline-img').is('.is-hidden, .bounce-out') ) {
$(this).find('.cd-timeline-img, .cd-timeline-content').removeClass('is-hidden bounce-out').addClass('bounce-in');
}
if($(this).offset().top >= $(window).scrollTop()+$(window).height()*0.75 && $(this).find('.cd-timeline-img').is('.bounce-in')) {
$(this).find('.cd-timeline-img, .cd-timeline-content').removeClass('bounce-in').addClass('bounce-out');
} else if($(this).offset().top >= $(window).scrollTop()+$(window).height()*0.80 && $(this).find('.cd-timeline-img').is('.bounce-out')) {
$(this).find('.cd-timeline-img, .cd-timeline-content').removeClass('bounce-out').addClass('is-hidden');
}
});
});
Expand Down