CSS3 knowledge needed
What You need is a set of elements:
- Code: Select all
<div class="myelement animate">
<img src="..." alt="" />
</div>
first is class of your specific element, second makes it animate (well not quite yet). This way element will show as soon as it is on screen.
The other way:
- Code: Select all
<div class="myelement animate_queue">
<img class="animate_queue_element" src="..." alt="" />
<img class="animate_queue_element" src="..." alt="" />
<img class="animate_queue_element" src="..." alt="" />
</div>
This type of code is used to create queue of animations.
Now all the magic happends when You scroll down through the page, and Javascript detects that element is now "visible". It adds loaded class to it.
Now with this knowledge there is just one step to do - You need css3 classes that transform css parameters between element without loaded class and with:
- Code: Select all
/* Portfolio - animation */
.gkNspPM-Portfolio .animate_queue_element {
opacity: 0; filter: alpha(opacity=0);
position: relative;
-webkit-transform: scale(0);
-moz-transform: scale(0);
-ms-transform: scale(0);
-o-transform: scale(0);
transform: scale(0);
-webkit-transition: all .4s ease-out!important;
-moz-transition: all .4s ease-out!important;
-ms-transition: all .4s ease-out!important;
-o-transition: all .4s ease-out!important;
transition: all .4s ease-out!important;
}
.gkNspPM-Portfolio .animate_queue_element.loaded {
opacity: 1; filter: alpha(opacity=100);
top: 0;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1);
}
This part works with portfolio. What it does is set default scale and opacity of elements to 0 (1rst block of declarations), adds transition type speed and kind ( .4s ease-out) and then, if element gets class loaded, opacity and scale is changed to normal state. This way animation happends.
- Code: Select all
.gkTestimonial.animate {
opacity: 0; filter: alpha(opacity=0);
position: relative;
-webkit-transition: all .4s ease-out;
-moz-transition: all .4s ease-out;
-ms-transition: all .4s ease-out;
-o-transition: all .4s ease-out;
transition: all .4s ease-out;
}
.gkTestimonial.animate.loaded {
opacity: 1; filter: alpha(opacity=100);
}
This way You animate only opacity.
You can animate also potision, width, height, and quite all numerical values.