add base layout

This commit is contained in:
Daniel Kummer 2012-07-31 12:59:15 +02:00
parent 477a02f980
commit b871e97e36
6 changed files with 1387 additions and 0 deletions

500
css/normalize.css vendored Normal file
View File

@ -0,0 +1,500 @@
/*! normalize.css 2012-07-07T09:50 UTC - http://github.com/necolas/normalize.css */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/*
* Corrects `block` display not defined in IE6/7/8/9 & FF3.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section,
summary {
display: block;
}
/*
* Corrects `inline-block` display not defined in IE6/7/8/9 & FF3.
*/
audio,
canvas,
video {
display: inline-block;
*display: inline;
*zoom: 1;
}
/*
* Prevents modern browsers from displaying `audio` without controls.
* Remove excess height in iOS5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/*
* Addresses styling for `hidden` attribute not present in IE7/8/9, FF3, S4.
* Known issue: no IE6 support.
*/
[hidden] {
display: none;
}
/* ==========================================================================
Base
========================================================================== */
/*
* 1. Corrects text resizing oddly in IE6/7 when body `font-size` is set using
* `em` units.
* 2. Prevents iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-size: 100%; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
-ms-text-size-adjust: 100%; /* 2 */
}
/*
* Addresses `font-family` inconsistency between `textarea` and other form
* elements.
*/
html,
button,
input,
select,
textarea {
font-family: sans-serif;
}
/*
* Addresses margins handled incorrectly in IE6/7.
*/
body {
margin: 0;
}
/* ==========================================================================
Links
========================================================================== */
/*
* Addresses `outline` inconsistency between Chrome and other browsers.
*/
a:focus {
outline: thin dotted;
}
/*
* Improves readability when focused and also mouse hovered in all browsers.
* people.opera.com/patrickl/experiments/keyboard/test
*/
a:active,
a:hover {
outline: 0;
}
/* ==========================================================================
Typography
========================================================================== */
/*
* Addresses font sizes and margins set differently in IE6/7.
* Addresses font sizes within `section` and `article` in FF4+, Chrome, S5.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
h2 {
font-size: 1.5em;
margin: 0.83em 0;
}
h3 {
font-size: 1.17em;
margin: 1em 0;
}
h4 {
font-size: 1em;
margin: 1.33em 0;
}
h5 {
font-size: 0.83em;
margin: 1.67em 0;
}
h6 {
font-size: 0.75em;
margin: 2.33em 0;
}
/*
* Addresses styling not present in IE7/8/9, S5, Chrome.
*/
abbr[title] {
border-bottom: 1px dotted;
}
/*
* Addresses style set to `bolder` in FF3+, S4/5, Chrome.
*/
b,
strong {
font-weight: bold;
}
blockquote {
margin: 1em 40px;
}
/*
* Addresses styling not present in S5, Chrome.
*/
dfn {
font-style: italic;
}
/*
* Addresses styling not present in IE6/7/8/9.
*/
mark {
background: #ff0;
color: #000;
}
/*
* Addresses margins set differently in IE6/7.
*/
p,
pre {
margin: 1em 0;
}
/*
* Corrects font family set oddly in IE6, S4/5, Chrome.
* en.wikipedia.org/wiki/User:Davidgothberg/Test59
*/
code,
kbd,
pre,
samp {
font-family: monospace, serif;
_font-family: 'courier new', monospace;
font-size: 1em;
}
/*
* Improves readability of pre-formatted text in all browsers.
*/
pre {
white-space: pre;
white-space: pre-wrap;
word-wrap: break-word;
}
/*
* Addresses CSS quotes not supported in IE6/7.
*/
q {
quotes: none;
}
/*
* Addresses `quotes` property not supported in S4.
*/
q:before,
q:after {
content: '';
content: none;
}
small {
font-size: 75%;
}
/*
* Prevents `sub` and `sup` affecting `line-height` in all browsers.
* gist.github.com/413930
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* ==========================================================================
Lists
========================================================================== */
/*
* Addresses margins set differently in IE6/7.
*/
dl,
menu,
ol,
ul {
margin: 1em 0;
}
dd {
margin: 0 0 0 40px;
}
/*
* Addresses paddings set differently in IE6/7.
*/
menu,
ol,
ul {
padding: 0 0 0 40px;
}
/*
* Corrects list images handled incorrectly in IE7.
*/
nav ul,
nav ol {
list-style: none;
list-style-image: none;
}
/* ==========================================================================
Embedded content
========================================================================== */
/*
* 1. Removes border when inside `a` element in IE6/7/8/9, FF3.
* 2. Improves image quality when scaled in IE7.
* code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/
*/
img {
border: 0; /* 1 */
-ms-interpolation-mode: bicubic; /* 2 */
}
/*
* Corrects overflow displayed oddly in IE9.
*/
svg:not(:root) {
overflow: hidden;
}
/* ==========================================================================
Figures
========================================================================== */
/*
* Addresses margin not present in IE6/7/8/9, S5, O11.
*/
figure {
margin: 0;
}
/* ==========================================================================
Forms
========================================================================== */
/*
* Corrects margin displayed oddly in IE6/7.
*/
form {
margin: 0;
}
/*
* Define consistent border, margin, and padding.
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/*
* 1. Corrects color not being inherited in IE6/7/8/9.
* 2. Corrects text not wrapping in FF3.
* 3. Corrects alignment displayed oddly in IE6/7.
*/
legend {
border: 0; /* 1 */
padding: 0;
white-space: normal; /* 2 */
*margin-left: -7px; /* 3 */
}
/*
* 1. Corrects font size not being inherited in all browsers.
* 2. Addresses margins set differently in IE6/7, FF3+, S5, Chrome.
* 3. Improves appearance and consistency in all browsers.
*/
button,
input,
select,
textarea {
font-size: 100%; /* 1 */
margin: 0; /* 2 */
vertical-align: baseline; /* 3 */
*vertical-align: middle; /* 3 */
}
/*
* Addresses FF3/4 setting `line-height` on `input` using `!important` in the
* UA stylesheet.
*/
button,
input {
line-height: normal;
}
/*
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
* and `video` controls.
* 2. Corrects inability to style clickable `input` types in iOS.
* 3. Improves usability and consistency of cursor style between image-type
* `input` and others.
* 4. Removes inner spacing in IE7 without affecting normal text inputs.
* Known issue: inner spacing remains in IE6.
*/
button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button; /* 2 */
cursor: pointer; /* 3 */
*overflow: visible; /* 4 */
}
/*
* Re-set default cursor for disabled elements.
*/
button[disabled],
input[disabled] {
cursor: default;
}
/*
* 1. Addresses box sizing set to content-box in IE8/9.
* 2. Removes excess padding in IE8/9.
* 3. Removes excess padding in IE7.
* Known issue: excess padding remains in IE6.
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
*height: 13px; /* 3 */
*width: 13px; /* 3 */
}
/*
* 1. Addresses `appearance` set to `searchfield` in S5, Chrome.
* 2. Addresses `box-sizing` set to `border-box` in S5, Chrome (include `-moz`
* to future-proof).
*/
input[type="search"] {
-webkit-appearance: textfield; /* 1 */
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box; /* 2 */
box-sizing: content-box;
}
/*
* Removes inner padding and search cancel button in S5, Chrome on OS X.
*/
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/*
* Removes inner padding and border in FF3+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/*
* 1. Removes default vertical scrollbar in IE6/7/8/9.
* 2. Improves readability and alignment in all browsers.
*/
textarea {
overflow: auto; /* 1 */
vertical-align: top; /* 2 */
}
/* ==========================================================================
Tables
========================================================================== */
/*
* Remove most spacing between table cells.
*/
table {
border-collapse: collapse;
border-spacing: 0;
}

265
css/style.css Normal file
View File

@ -0,0 +1,265 @@
body {
background: rgba(165, 170, 255, 0.15);
font-family: Georgia, Times New Roman, Times, serif;
font-weight: bold;
font-size: 30px;
text-align: center;
}
h1 {
font-size: 120px;
font-weight: normal;
margin: 0;
font-family: 'Sansita One', cursive;
color: #3a7eff;
text-shadow: 0 2px 1px #000;
line-height: 1;
}
h2 {
font-size: 80px;
font-weight: normal;
margin: 0;
text-shadow: 0 2px 1px #000;
color: #FFB000;
font-family: 'Sansita One', cursive;
}
h3 {
font-size: 40px;
font-weight: normal;
margin: 0;
color: #D92B00;
text-shadow: 0 2px 1px #000;
font-family: 'Sansita One', cursive;
}
p {
width: 80%;
margin: 20px auto;
text-shadow: 0 2px 1px #fff;
color: #222438;
}
a, a:visited {
color: #D92B00;
font-weight: bold;
font-style: italic;
}
ul {
list-style: none;
}
.download {
padding: 10px;
}
pre {
font-size: 18px;
}
blockquote {
text-align: left;
width: 720px;
margin: 10px auto;
background: #C5C3DE;
border: solid 2px #69697A;
padding: 0 40px;
}
code {
font-style: normal;
padding-left: 5px;
}
/*---------------------------------------- BLOCKS */
.scrollblock {
position: relative;
margin: 0;
width: 100%;
height: 600px;
}
.scrollblock h2 {
padding-top: 100px;
}
.divider {
font-size: 14px;
}
.divider, .accent {
color: #69697A;
text-shadow: none;
}
#console {
display: none;
position: fixed;
top: 0;
left: 15px;
width: 500px;
margin: 0;
font-size: 14px;
font-style: italic;
background-color: #69697A;
text-shadow: none;
text-align: left;
padding: 3px 10px;
border-radius: 0 0 10px 10px;
z-index: 99;
opacity: .8;
}
#intro {
overflow: hidden;
}
#title {
margin: 80px auto 0;
width: 1100px;
position: relative;
z-index: 99;
}
#author {
width: 640px;
position: absolute;
top: 180px;
right: 15%;
font-size: 20px;
text-align: right;
font-style: italic;
color: #D92B00;
z-index:100;
}
.twitter-share-button {
position: relative;
top: 8px;
left: 4px;
}
#desc {
position: absolute;
top: 250px;
width: 100%;
}
#download {
position: absolute;
top: 380px;
font-size: 18px;
width: 100%;
line-height: 1.8;
}
#download a {
color: #69697A;
}
#examples-pin {
height: 500px;
}
#examples-transition {
overflow: hidden;
}
#examples-parallax {
overflow: hidden;
}
#parallax2 {
position: absolute;
top: 200px;
left: -50px;
color: #C5C3DE;
opacity: .2;
font-size: 210px;
text-shadow: none;
}
#parallax3 {
position: absolute;
top: 320px;
right: 40px;
color: #C5C3DE;
opacity: .4;
font-size: 160px;
text-shadow: none;
}
#easing span {
position: relative;
top:0;
left:0;
}
#easing_bottom {
width: 330px;
height: 13px;
margin: auto;
background: #131420;
border-bottom: 1px solid #30334F;
position: relative;
top: 276px;
border-radius: 2px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
border-radius: 4px;
}
#howtouse {
height: 2100px;
}
#disclaimer {
font-size: 18px;
font-style: italic;
font-weight: normal;
margin: 0 auto;
}
#instructions {
padding-top: 40px;
}
#instructions p {
margin: 0px auto 20px;
}
#instructions-animation {
padding-top: 40px;
}
.param-list {
color: #C5C3DE;
font-size: 18px;
line-height: 1.4;
padding: 0 18px;
}
.param-list li {
padding-bottom: 20px;
text-shadow: 0 2px 1px #000;
}
.param {
display: block;
color: #69697A;
}
.param-def small {
display: block;
font-weight: normal;
font-style: italic;
}
#credits {
height: 525px;
margin-top: 100px;
}

98
index.html Normal file
View File

@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>git-flow cheatsheet</title>
<link href='http://fonts.googleapis.com/css?family=Sansita+One' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/normalize.css" type="text/css">
<link rel="stylesheet" href="css/style.css" type="text/css">
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/jquery.lettering-0.6.1.min.js"></script>
<script src="js/jquery.scrollorama.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-33766650-1']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div class="scrollblock" id="intro">
<h1 id="title">git-flow cheatsheet</h1>
<p id="author">
created by <a href="http://twitter.com/0r1g4m14dd1c7">Daniel Kummer</a>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="0r1g4m14dd1c7" data-size="large">Tweet</a>
<script>!function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = "//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, "script", "twitter-wjs");</script>
</p>
<p id="desc">efficient branching using git-flow by <a href="http://nvie.com/">nvie</a>
</p>
</div>
<p id="console"></p>
<div class="scrollblock" id="into">
<h2 id="zoom-in">sorry..</h2>
<p>This is still a work in progress, stay tuned for update (happening soon)</p>
</div>
<div class="scrollblock">
<p> another block</p>
</div>
<script>
$(document).ready(function () {
var scrollorama = $.scrollorama({ blocks:'.scrollblock' });
// assign function to add behavior for onBlockChange event
scrollorama.onBlockChange(function () {
var i = scrollorama.blockIndex;
$('#console')
.css('display', 'block')
.text('onBlockChange | blockIndex:' + i + ' | current block: ' + scrollorama.settings.blocks.eq(i).attr('id'));
});
$('#title').lettering();
$('#title span')
.css('display', 'block')
.css('float', 'left');
$('.char9').css('padding-left', '6px');
scrollorama.animate('#zoom-in', { delay:200, duration:600, property:'zoom', start:8 });
// animate some examples
scrollorama.animate('#unpin', { duration:500, property:'padding-top', start:400, pin:true });
scrollorama.animate('#fade-in', { delay:400, duration:300, property:'opacity', start:0 });
scrollorama.animate('#fly-in', { delay:400, duration:300, property:'left', start:-1400, end:0 });
scrollorama.animate('#rotate-in', { duration:800, property:'rotate', start:720 });
scrollorama.animate('#any', { delay:700, duration:200, property:'opacity', start:0 });
scrollorama.animate('#any', { delay:800, duration:200, property:'letter-spacing', start:18 });
// animate the parallaxing
scrollorama.animate('#parallax2', { delay:400, duration:600, property:'top', start:800, end:-800 });
scrollorama.animate('#parallax3', { delay:200, duration:1200, property:'top', start:500, end:-500 });
});
</script>
</body>
</html>

4
js/jquery-1.7.2.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
js/jquery.lettering-0.6.1.min.js vendored Normal file
View File

@ -0,0 +1,2 @@
/* Lettering.JS 0.6.1 by Dave Rupert - http://daverupert.com */
(function($){function injector(t,splitter,klass,after){var a=t.text().split(splitter),inject='';if(a.length){$(a).each(function(i,item){inject+='<span class="'+klass+(i+1)+'">'+item+'</span>'+after});t.empty().append(inject)}}var methods={init:function(){return this.each(function(){injector($(this),'','char','')})},words:function(){return this.each(function(){injector($(this),' ','word',' ')})},lines:function(){return this.each(function(){var r="eefec303079ad17405c889e092e105b0";injector($(this).children("br").replaceWith(r).end(),r,'line','')})}};$.fn.lettering=function(method){if(method&&methods[method]){return methods[method].apply(this,[].slice.call(arguments,1))}else if(method==='letters'||!method){return methods.init.apply(this,[].slice.call(arguments,0))}$.error('Method '+method+' does not exist on jQuery.lettering');return this}})(jQuery);

518
js/jquery.scrollorama.js Normal file
View File

@ -0,0 +1,518 @@
/*
scrollorama - The jQuery plugin for doing cool scrolly stuff
by John Polacek (@johnpolacek)
Dual licensed under MIT and GPL.
*/
(function($) {
$.scrollorama = function(options) {
var scrollorama = this,
blocks = [],
browserPrefix = '',
onBlockChange = function() {},
latestKnownScrollY = 0,
ticking = false,
requestAnimFrame = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
},
defaults = {offset:0, enablePin: true};
scrollorama.settings = $.extend({}, defaults, options);
scrollorama.blockIndex = 0;
if (options.blocks === undefined) { alert('ERROR: Must assign blocks class selector to scrollorama plugin'); }
// PRIVATE FUNCTIONS
function init() {
var i, block, didScroll = false;
if (typeof scrollorama.settings.blocks === 'string') { scrollorama.settings.blocks = $(scrollorama.settings.blocks); }
// set browser prefix
if ($.browser.mozilla) { browserPrefix = '-moz-'; }
if ($.browser.webkit) { browserPrefix = '-webkit-'; }
if ($.browser.opera) { browserPrefix = '-o-'; }
if ($.browser.msie) { browserPrefix = '-ms-'; }
// create blocks array to contain animation props
$('body').css('position','relative');
for (i=0; i<scrollorama.settings.blocks.length; i++) {
block = scrollorama.settings.blocks.eq(i);
blocks.push({
block: block,
top: block.offset().top - parseInt(block.css('margin-top'), 10),
pin: 0,
animations:[]
});
}
// convert block elements to absolute position
if (scrollorama.settings.enablePin.toString() === 'true') {
for (i=0; i<blocks.length; i++) {
blocks[i].block
.css('position', 'absolute')
.css('top', blocks[i].top);
}
}
$('body').prepend('<div id="scroll-wrap"></div>');
latestKnownScrollY = 0;
ticking = false;
$(window).on( 'scroll.scrollorama', onScroll );
}
function onScroll() {
latestKnownScrollY = window.scrollY;
requestTick();
}
function requestTick() {
if(!ticking) {
requestAnimFrame(function(){
onScrollorama();
update();
});
}
ticking = true;
}
function update() {
// reset the tick so we can
// capture the next onScroll
ticking = false;
}
function onScrollorama() {
var scrollTop = $(window).scrollTop(),
currBlockIndex = getCurrBlockIndex(scrollTop),
i, j, anim, startAnimPos, endAnimPos, animPercent, animVal;
// update all animations
for (i=0; i<blocks.length; i++) {
// go through the animations for each block
if (blocks[i].animations.length) {
for (j=0; j<blocks[i].animations.length; j++) {
anim = blocks[i].animations[j];
// if above current block, settings should be at start value
if (i > currBlockIndex) {
if (currBlockIndex !== i-1 && anim.baseline !== 'bottom') {
setProperty(anim.element, anim.property, anim.startVal);
}
if (blocks[i].pin) {
blocks[i].block
.css('position', 'absolute')
.css('top', blocks[i].top);
}
}
// if below current block, settings should be at end value
// unless on an element that gets animated when it hits the bottom of the viewport
else if (i < currBlockIndex) {
setProperty(anim.element, anim.property, anim.endVal);
if (blocks[i].pin) {
blocks[i].block
.css('position', 'absolute')
.css('top', (blocks[i].top + blocks[i].pin));
}
}
// otherwise, set values per scroll position
if (i === currBlockIndex || (currBlockIndex === i-1 && anim.baseline === 'bottom')) {
// if block gets pinned, set position fixed
if (blocks[i].pin && currBlockIndex === i) {
blocks[i].block
.css('position', 'fixed')
.css('top', 0);
}
// set start and end animation positions
startAnimPos = blocks[i].top + anim.delay;
if (anim.baseline === 'bottom') { startAnimPos -= $(window).height(); }
endAnimPos = startAnimPos + anim.duration;
// if scroll is before start of animation, set to start value
if (scrollTop < startAnimPos) {
setProperty(anim.element, anim.property, anim.startVal);
}
// if scroll is after end of animation, set to end value
else if (scrollTop > endAnimPos) {
setProperty(anim.element, anim.property, anim.endVal);
if (blocks[i].pin) {
blocks[i].block
.css('position', 'absolute')
.css('top', (blocks[i].top + blocks[i].pin));
}
}
// otherwise, set value based on scroll
else {
// calculate percent to animate
animPercent = (scrollTop - startAnimPos) / anim.duration;
// account for easing if there is any
if ( anim.easing && $.isFunction( $.easing[anim.easing] ) ) {
animPercent = $.easing[anim.easing]( animPercent, animPercent*1000, 0, 1, 1000 );
}
// then multiply the percent by the value range and calculate the new value
animVal = anim.startVal + (animPercent * (anim.endVal - anim.startVal));
setProperty(anim.element, anim.property, animVal);
}
}
}
}
}
// update blockIndex and trigger event if changed
if (scrollorama.blockIndex !== currBlockIndex) {
scrollorama.blockIndex = currBlockIndex;
onBlockChange();
}
}
function getCurrBlockIndex(scrollTop) {
var currBlockIndex = 0, i;
for (i=0; i<blocks.length; i++) {
// check if block is in view
if (blocks[i].top <= scrollTop - scrollorama.settings.offset) { currBlockIndex = i; }
}
return currBlockIndex;
}
function setProperty(target, prop, val) {
var scaleCSS, currentPosition;
if (prop === 'rotate' || prop === 'zoom' || prop === 'scale') {
if (prop === 'rotate') {
target.css(browserPrefix+'transform', 'rotate('+val+'deg)');
} else if (prop === 'zoom' || prop === 'scale') {
scaleCSS = 'scale('+val+')';
if (browserPrefix !== '-ms-') {
target.css(browserPrefix+'transform', scaleCSS);
} else {
target.css('zoom', scaleCSS);
}
}
}
else if(prop === 'background-position-x' || prop === 'background-position-y' ) {
currentPosition = target.css('background-position').split(' ');
if(prop === 'background-position-x') {
target.css('background-position',val+'px '+currentPosition[1]);
}
if(prop === 'background-position-y') {
target.css('background-position', currentPosition[0]+' '+val+'px');
}
}
else if(prop === 'text-shadow' ) {
target.css(prop,'0px 0px '+val+'px #ffffff');
} else {
target.css(prop, val);
}
}
// PUBLIC FUNCTIONS
scrollorama.animate = function(target) {
var targetIndex,
targetBlock,
anim,
offset,
i, j;
/*
target = animation target
arguments = array of animation parameters
anim = object that contains all animation params (created from arguments)
offset = positioning helper for pinning
animation parameters:
delay = amount of scrolling (in pixels) before animation starts
duration = amount of scrolling (in pixels) over which the animation occurs
property = css property being animated
start = start value of the property
end = end value of the property
pin = pin block during animation duration (applies to all animations within block)
baseline = top (default, when block reaches top of viewport) or bottom (when block first comies into view)
easing = just like jquery's easing functions
*/
// if string, convert to DOM object
if (typeof target === 'string') { target = $(target); }
// find block of target
for (i=0; i<blocks.length; i++) {
if (blocks[i].block.has(target).length) {
targetBlock = blocks[i];
targetIndex = i;
}
}
// add each animation to the blocks animations array from function arguments
for (i=1; i<arguments.length; i++) {
anim = arguments[i];
// for top/left/right/bottom, set relative positioning if static
if (anim.property === 'top' || anim.property === 'left' || anim.property === 'bottom' || anim.property === 'right' ) {
if (target.css('position') === 'static') { target.css('position','relative'); }
// set anim.start, anim.end defaults
cssValue = parseInt(target.css(anim.property),10);
if (anim.start === undefined) {
anim.start = isNaN(cssValue) ? 0 : cssValue;
} else if (anim.end === undefined) {
anim.end = isNaN(cssValue) ? 0 : cssValue;
}
}
// set anim.start/anim.end defaults for rotate, zoom/scale, letter-spacing
if (anim.property === 'rotate') {
if (anim.start === undefined) { anim.start = 0; }
if (anim.end === undefined) { anim.end = 0; }
} else if (anim.property === 'zoom' || anim.property === 'scale' ) {
if (anim.start === undefined) { anim.start = 1; }
if (anim.end === undefined) { anim.end = 1; }
} else if (anim.property === 'letter-spacing' && target.css(anim.property)) {
if (anim.start === undefined) { anim.start = 1; }
if (anim.end === undefined) { anim.end = 1; }
}
if (anim.baseline === undefined) {
if (anim.pin || targetBlock.pin || targetIndex === 0) {
anim.baseline = 'top';
} else {
anim.baseline = 'bottom';
}
}
if (anim.delay === undefined) { anim.delay = 0; }
targetBlock.animations.push({
element: target,
delay: anim.delay,
duration: anim.duration,
property: anim.property,
startVal: anim.start !== undefined ? anim.start : parseInt(target.css(anim.property),10), // if undefined, use current css value
endVal: anim.end !== undefined ? anim.end : parseInt(target.css(anim.property),10), // if undefined, use current css value
baseline: anim.baseline !== undefined ? anim.baseline : 'bottom',
easing: anim.easing
});
if (anim.pin) {
if (targetBlock.pin < anim.duration + anim.delay) {
offset = anim.duration + anim.delay - targetBlock.pin;
targetBlock.pin += offset;
// adjust positions of blocks below target block
for (j=targetIndex+1; j<blocks.length; j++) {
blocks[j].top += offset;
blocks[j].block.css('top', blocks[j].top);
}
}
}
}
onScrollorama();
};
// function for passing blockChange event callback
scrollorama.onBlockChange = function(f) {
onBlockChange = f;
};
// function for getting an array of scrollpoints
// (top of each animation block and animation element scroll start point)
scrollorama.getScrollpoints = function() {
var scrollpoints = [],i,j,anim;
for (i=0; i<blocks.length; i++) {
scrollpoints.push(blocks[i].top);
// go through the animations for each block
if (blocks[i].animations.length && blocks[i].pin > 0) {
for (j=0; j<blocks[i].animations.length; j++) {
anim = blocks[i].animations[j];
scrollpoints.push(blocks[i].top + anim.delay + anim.duration);
}
}
}
// make sure scrollpoints are in numeric order
scrollpoints.sort(function(a,b) {return a - b;});
return scrollpoints;
};
// Remove scrollorama
scrollorama.destroy = function () {
// Remove animations
for (i=0; i<blocks.length; i++) {
// Remove CSS rules
blocks[i].block.css({
top: '',
position: ''
});
// Remove scrolloroma-specific attributes
delete blocks[i].animations;
delete blocks[i].top;
delete blocks[i].pin;
}
// Unbind the window scroll event
$(window).off('scroll.scrollorama');
$('#scroll-wrap').remove();
// Remove the scrolloroma object
delete scrollorama;
};
// INIT
init();
return scrollorama;
};
//
// Easing functions from jQuery UI
//
$.extend($.easing, {
def: 'easeOutQuad',
swing: function (x, t, b, c, d) {
//alert($.easing.default);
return $.easing[$.easing.def](x, t, b, c, d);
},
easeInQuad: function (x, t, b, c, d) {
return c*(t/=d)*t + b;
},
easeOutQuad: function (x, t, b, c, d) {
return -c *(t/=d)*(t-2) + b;
},
easeInOutQuad: function (x, t, b, c, d) {
if ((t/=d/2) < 1) { return c/2*t*t + b; }
return -c/2 * ((--t)*(t-2) - 1) + b;
},
easeInCubic: function (x, t, b, c, d) {
return c*(t/=d)*t*t + b;
},
easeOutCubic: function (x, t, b, c, d) {
return c*((t=t/d-1)*t*t + 1) + b;
},
easeInOutCubic: function (x, t, b, c, d) {
if ((t/=d/2) < 1) { return c/2*t*t*t + b; }
return c/2*((t-=2)*t*t + 2) + b;
},
easeInQuart: function (x, t, b, c, d) {
return c*(t/=d)*t*t*t + b;
},
easeOutQuart: function (x, t, b, c, d) {
return -c * ((t=t/d-1)*t*t*t - 1) + b;
},
easeInOutQuart: function (x, t, b, c, d) {
if ((t/=d/2) < 1) { return c/2*t*t*t*t + b; }
return -c/2 * ((t-=2)*t*t*t - 2) + b;
},
easeInQuint: function (x, t, b, c, d) {
return c*(t/=d)*t*t*t*t + b;
},
easeOutQuint: function (x, t, b, c, d) {
return c*((t=t/d-1)*t*t*t*t + 1) + b;
},
easeInOutQuint: function (x, t, b, c, d) {
if ((t/=d/2) < 1) { return c/2*t*t*t*t*t + b; }
return c/2*((t-=2)*t*t*t*t + 2) + b;
},
easeInSine: function (x, t, b, c, d) {
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
},
easeOutSine: function (x, t, b, c, d) {
return c * Math.sin(t/d * (Math.PI/2)) + b;
},
easeInOutSine: function (x, t, b, c, d) {
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
},
easeInExpo: function (x, t, b, c, d) {
return (t===0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
},
easeOutExpo: function (x, t, b, c, d) {
return (t===d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
},
easeInOutExpo: function (x, t, b, c, d) {
if (t===0) { return b; }
if (t===d) { return b+c; }
if ((t/=d/2) < 1) { return c/2 * Math.pow(2, 10 * (t - 1)) + b; }
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
},
easeInCirc: function (x, t, b, c, d) {
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
},
easeOutCirc: function (x, t, b, c, d) {
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
},
easeInOutCirc: function (x, t, b, c, d) {
if ((t/=d/2) < 1) { return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; }
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
},
easeInElastic: function (x, t, b, c, d) {
var s=1.70158,p=0,a=c;
if (t===0) { return b; }
if ((t/=d)===1) { return b+c; }
if (!p) { p=d*0.3; }
if (a < Math.abs(c)) { a=c; s=p/4; }
else{ s = p/(2*Math.PI) * Math.asin (c/a); }
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
},
easeOutElastic: function (x, t, b, c, d) {
var s=1.70158,p=0,a=c;
if (t===0) { return b; }
if ((t/=d)===1) { return b+c; }
if (!p) { p=d*0.3; }
if (a < Math.abs(c)) { a=c; s=p/4; }
else { s = p/(2*Math.PI) * Math.asin (c/a); }
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
},
easeInOutElastic: function (x, t, b, c, d) {
var s=1.70158,p=0,a=c;
if (t===0) { return b; }
if ((t/=d/2)===2) { return b+c; }
if (!p) { p=d*(0.3*1.5); }
if (a < Math.abs(c)) { a=c; s=p/4; }
else { s = p/(2*Math.PI) * Math.asin (c/a); }
if (t < 1) { return -0.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; }
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*0.5 + c + b;
},
easeInBack: function (x, t, b, c, d, s) {
if (s === undefined) { s = 1.70158; }
return c*(t/=d)*t*((s+1)*t - s) + b;
},
easeOutBack: function (x, t, b, c, d, s) {
if (s === undefined) { s = 1.70158; }
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
},
easeInOutBack: function (x, t, b, c, d, s) {
if (s === undefined) { s = 1.70158; }
if ((t/=d/2) < 1) { return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; }
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
},
easeInBounce: function (x, t, b, c, d) {
return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
},
easeOutBounce: function (x, t, b, c, d) {
if ((t/=d) < (1/2.75)) {
return c*(7.5625*t*t) + b;
} else if (t < (2/2.75)) {
return c*(7.5625*(t-=(1.5/2.75))*t + 0.75) + b;
} else if (t < (2.5/2.75)) {
return c*(7.5625*(t-=(2.25/2.75))*t + 0.9375) + b;
} else {
return c*(7.5625*(t-=(2.625/2.75))*t + 0.984375) + b;
}
},
easeInOutBounce: function (x, t, b, c, d) {
if (t < d/2) { return $.easing.easeInBounce (x, t*2, 0, c, d) * 0.5 + b; }
return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * 0.5 + c*0.5 + b;
}
});
})(jQuery);