3
git/.gitignore
vendored
Normal file
3
git/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.idea/
|
||||
.*.swp
|
||||
.DS_Store
|
||||
4
git/README.md
Normal file
4
git/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# Git - The Simple Guide
|
||||
|
||||
https://www.arnaudmorin.fr/git-guide/
|
||||
|
||||
227
git/css/style.css
Normal file
227
git/css/style.css
Normal file
@@ -0,0 +1,227 @@
|
||||
body {
|
||||
background: #FFF;
|
||||
font-family: Georgia, Times New Roman, Times, serif;
|
||||
font-size: 30px;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 60px;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
font-family: 'Chelsea Market', Georgia, serif;
|
||||
color: #000;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 70px;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
color: #FFB000;
|
||||
font-family: 'Chelsea Market', Georgia, serif;
|
||||
text-transform: lowercase;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 40px;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
margin-top: 40px;
|
||||
text-transform: lowercase;
|
||||
}
|
||||
|
||||
p {
|
||||
width: 960px;
|
||||
margin: 40px auto;
|
||||
color: #000;
|
||||
line-height: 200%;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
color: #000;
|
||||
font-size: 12px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
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 {
|
||||
background-color: #000;
|
||||
font-style: normal;
|
||||
border-radius: 10px;
|
||||
color: white;
|
||||
padding: 5px 15px;
|
||||
font-family: menlo, monospace;
|
||||
}
|
||||
|
||||
/*---------------------------------------- BLOCKS */
|
||||
|
||||
.scrollblock {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
color: white;
|
||||
padding-top: 80px;
|
||||
padding-bottom: 80px;
|
||||
}
|
||||
|
||||
.scrollblock h2 {
|
||||
|
||||
}
|
||||
|
||||
.block-title { background-color: #FFF; padding-bottom: 50px; }
|
||||
.block-title h2 { color: #000; }
|
||||
.block-title .meta { font-size: 16px; color: #999; }
|
||||
.block-title .meta a { font-size: 16px; color: #333; }
|
||||
.block-setup { background-color: #348fd4; }
|
||||
.block-setup h2 { color: #06406c; }
|
||||
.block-setup h2 a { background: none; padding: 0; font-size: normal; }
|
||||
.block-setup a { color: #FFF; font-size: 40px; font-weight: normal;font-style: normal; background-color: #06406c; padding: 10px 15px; border-radius: 10px; text-decoration: none; }
|
||||
.block-setup a:hover { text-decoration: underline; }
|
||||
.block-create { background-color: #06406c; }
|
||||
.block-create h2 { color: #FFF; }
|
||||
.block-create p { color: #FFF; }
|
||||
.block-create code { background-color: #000; color: #FFF; }
|
||||
.block-checkout { background-color: #FFF; }
|
||||
.block-checkout h2 { color: #000; }
|
||||
.block-trees { background-color: #4c0d09; }
|
||||
.block-trees h2 { color: #d3b2af; }
|
||||
.block-trees p { color: #d3b2af; }
|
||||
.block-trees code { color: #000; background-color: white; }
|
||||
.block-add { background-color: #cc4037; }
|
||||
.block-add h2, .block-add p { color: #4c0d09; }
|
||||
.block-remote { background-color: #ffc19f; }
|
||||
.block-remote h2 { color: #cc4037; }
|
||||
.block-branching { background-color: #000; }
|
||||
.block-branching h2 { color: #FFF; }
|
||||
.block-branching p { color: #DDD; }
|
||||
.block-branching code { color: #000; background-color: white; }
|
||||
.block-merging { background-color: #F2F2F2; }
|
||||
.block-merging h2 { color: #666; }
|
||||
.block-tagging { background-color: #F2F2F2; }
|
||||
.block-tagging h2 { color: #FFF; }
|
||||
.block-hints { background-color: #F2F2F2; }
|
||||
.block-hints h2 { color: #FFF; }
|
||||
.block-resources { background-color: #ffc19f; }
|
||||
.block-resources h2 { color: #cc4037; }
|
||||
.block-resources h3 { color: #7d1f19; }
|
||||
.block-resources ul { list-style: disc; margin: 0; padding: 0; }
|
||||
.block-resources ul li a { font-size: 24px; color: #cc4037; }
|
||||
.block-tagging { background-color: #348fd4; }
|
||||
.block-tagging h2 { color: #06406c; }
|
||||
.block-hints { background-color: #06406c; }
|
||||
.block-hints h2 { color: #FFF; }
|
||||
.block-hints p { color: #FFF; }
|
||||
.block-hints code { background-color: #000; color: #FFF; }
|
||||
.block-checkout-replace { background-color: #fff8c9; }
|
||||
.block-checkout-replace h2 { color: #2d2700; }
|
||||
.block-checkout-replace p { color: #615400; }
|
||||
.block-comments { background-color: #FFF; padding-bottom: 50px; font-size: 14px; color: #000; }
|
||||
.block-comments h2 { color: #000; }
|
||||
.block-comments h3 { font-size: 16px; }
|
||||
.block-comments #disqus_thread { width: 600px; text-align: left; margin-left: auto; margin-right: auto; }
|
||||
|
||||
.tower {
|
||||
display: block;
|
||||
width: 180px;
|
||||
height: 260px;
|
||||
position: absolute;
|
||||
top: 330px;
|
||||
right: 0;
|
||||
background: #FFF url(../img/git-tower.png) no-repeat;
|
||||
}
|
||||
|
||||
.cheatsheet {
|
||||
display: block;
|
||||
width: 180px;
|
||||
height: 250px;
|
||||
position: absolute;
|
||||
top: 346px;
|
||||
left: 0;
|
||||
background: #FFF url(../img/cheatsheet.png) no-repeat;
|
||||
}
|
||||
|
||||
.announcement {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.announcement img {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
#carbonads {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
padding: 10px;
|
||||
background-color: #dfdfdf;
|
||||
border-radius: 3px;
|
||||
max-width: 300px;
|
||||
margin: 0 auto;
|
||||
font-family: Verdana, "Helvetica Neue", Helvetica, sans-serif;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
#carbonads a {
|
||||
color: #606060;
|
||||
}
|
||||
|
||||
#carbonads a:hover {
|
||||
color: hsl(0, 0%, 20%);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#carbonads span {
|
||||
position: relative;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.carbon-img {
|
||||
float: left;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.carbon-img img { display: block; }
|
||||
|
||||
.carbon-text {
|
||||
display: block;
|
||||
float: left;
|
||||
max-width: calc(100% - 130px - 1em);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.carbon-poweredby {
|
||||
position: absolute;
|
||||
left: 144px;
|
||||
bottom: 0;
|
||||
display: block;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
font-size: 9px;
|
||||
}
|
||||
BIN
git/files/github-git-cheat-sheet.pdf
Normal file
BIN
git/files/github-git-cheat-sheet.pdf
Normal file
Binary file not shown.
BIN
git/img/arrow.png
Normal file
BIN
git/img/arrow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
git/img/branches.png
Normal file
BIN
git/img/branches.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
BIN
git/img/cheatsheet.png
Normal file
BIN
git/img/cheatsheet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
git/img/git-tower.png
Normal file
BIN
git/img/git-tower.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
git/img/trees.png
Normal file
BIN
git/img/trees.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
206
git/index.html
Normal file
206
git/index.html
Normal file
@@ -0,0 +1,206 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>git - the simple guide - no deep shit!</title>
|
||||
<link href='http://fonts.googleapis.com/css?family=Chelsea+Market' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/0/normalize.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/style.css" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="scrollblock block-title">
|
||||
<h1>git - the simple guide</h1>
|
||||
<p>just a simple guide for getting started with git. no deep shit ;)</p>
|
||||
<p class="meta">
|
||||
by <a href="https://www.arnaudmorin.fr">Arnaud Morin</a><br />
|
||||
Forked from <a href="http://www.twitter.com/rogerdudler">Roger Dudler</a>
|
||||
<br />credits to <a href="http://www.twitter.com/tfnico">@tfnico</a>, <a href="http://www.twitter.com/fhd">@fhd</a> and <a href="http://www.namics.com">Namics</a><br />
|
||||
</p>
|
||||
<img src="img/arrow.png" alt="" />
|
||||
</div>
|
||||
<a name="intro"></a>
|
||||
<div class="scrollblock block-merging">
|
||||
<h2>intro</h2>
|
||||
<p>
|
||||
Git is free open source software (the source code is public) written by Linus Torvalds who also wrote the Linux operating system's kernel.
|
||||
</p>
|
||||
<p>
|
||||
Git is a program for keeping track of changes over time, known in programming as version control. If you've used a track changes feature in a text editing software then you're already familiar with the concept!
|
||||
</p>
|
||||
</div>
|
||||
<a name="setup"></a>
|
||||
<div class="scrollblock block-setup">
|
||||
<h2>setup</h2>
|
||||
<p>
|
||||
<a href="http://git-scm.com/book/en/Getting-Started-Installing-Git">Download git for Linux</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://desktop.github.com/">Download git for OSX or Windows</a>
|
||||
</p>
|
||||
</div>
|
||||
<a name="create"></a>
|
||||
<div class="scrollblock block-create">
|
||||
<h2>create a new repository</h2>
|
||||
<p>
|
||||
create a new directory, open it and perform a <br />
|
||||
<code>git init</code><br />
|
||||
to create a new git repository.
|
||||
</p>
|
||||
</div>
|
||||
<a name="checkout"></a>
|
||||
<div class="scrollblock block-checkout">
|
||||
<h2>checkout a repository</h2>
|
||||
<p>
|
||||
create a working copy of a local repository by running the command<br />
|
||||
<code>git clone /path/to/repository</code><br />
|
||||
when using a remote server, your command will be<br />
|
||||
<code>git clone username@host:/path/to/repository</code>
|
||||
</p>
|
||||
</div>
|
||||
<a name="trees"></a>
|
||||
<div class="scrollblock block-trees">
|
||||
<h2>workflow</h2>
|
||||
<p>
|
||||
your local repository consists of three "trees" maintained by git.
|
||||
the first one is your <code>Working Directory</code> which holds the actual files.
|
||||
the second one is the <code>Index</code> which acts as a staging area and
|
||||
finally the <code>HEAD</code> which points to the last commit you've made.
|
||||
</p>
|
||||
<img src="img/trees.png" alt="" />
|
||||
</div>
|
||||
<a name="add"></a>
|
||||
<div class="scrollblock block-add">
|
||||
<h2>add & commit</h2>
|
||||
<p>
|
||||
You can propose changes (add it to the <b>Index</b>) using<br />
|
||||
<code>git add <filename></code><br />
|
||||
<code>git add *</code><br />
|
||||
This is the first step in the basic git workflow. To actually commit these changes use<br />
|
||||
<code>git commit -m "Commit message"</code><br />
|
||||
Now the file is committed to the <b>HEAD</b>, but not in your remote repository yet.
|
||||
</p>
|
||||
</div>
|
||||
<a name="push"></a>
|
||||
<div class="scrollblock block-remote">
|
||||
<h2>pushing changes</h2>
|
||||
<p>
|
||||
Your changes are now in the <b>HEAD</b> of your local working copy. To send those changes to your remote repository, execute <br />
|
||||
<code>git push origin master</code><br />
|
||||
Change <i>master</i> to whatever branch you want to push your changes to.
|
||||
<br /><br />
|
||||
If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with<br />
|
||||
<code>git remote add origin <server></code><br />
|
||||
Now you are able to push your changes to the selected remote server<br />
|
||||
|
||||
</p>
|
||||
</div>
|
||||
<a name="branching"></a>
|
||||
<div class="scrollblock block-branching">
|
||||
<h2>branching</h2>
|
||||
<p>
|
||||
Branches are used to develop features isolated from each other. The <i>master</i> branch is the "default" branch when you create a repository. Use other branches for development and merge them back to the master branch upon completion.
|
||||
</p>
|
||||
<img src="img/branches.png" alt="" />
|
||||
<p>
|
||||
create a new branch named "feature_x" and switch to it using<br />
|
||||
<code>git checkout -b feature_x</code><br />
|
||||
switch back to master<br />
|
||||
<code>git checkout master</code><br />
|
||||
and delete the branch again<br />
|
||||
<code>git branch -d feature_x</code><br />
|
||||
a branch is <i>not available to others</i> unless you push the branch to your remote repository<br />
|
||||
<code>git push origin <branch></code>
|
||||
</p>
|
||||
</div>
|
||||
<a name="update"></a>
|
||||
<div class="scrollblock block-merging">
|
||||
<h2>update & merge</h2>
|
||||
<p>
|
||||
to update your local repository to the newest commit, execute <br />
|
||||
<code>git pull</code><br />
|
||||
in your working directory to <i>fetch</i> and <i>merge</i> remote changes.<br />
|
||||
to merge another branch into your active branch (e.g. master), use<br />
|
||||
<code>git merge <branch></code><br />
|
||||
in both cases git tries to auto-merge changes. Unfortunately, this is not always possible and results in <i>conflicts</i>.
|
||||
You are responsible to merge those <i>conflicts</i>
|
||||
manually by editing the files shown by git. After changing, you need to mark them as merged with<br />
|
||||
<code>git add <filename></code><br />
|
||||
before merging changes, you can also preview them by using<br />
|
||||
<code>git diff <source_branch> <target_branch></code>
|
||||
</p>
|
||||
</div>
|
||||
<a name="tagging"></a>
|
||||
<div class="scrollblock block-tagging">
|
||||
<h2>tagging</h2>
|
||||
<p>
|
||||
it's recommended to create tags for software releases. this is a known concept, which also exists in SVN. You can create a new tag named <i>1.0.0</i> by executing<br />
|
||||
<code>git tag 1.0.0 1b2e1d63ff</code><br />
|
||||
the <i>1b2e1d63ff</i> stands for the first 10 characters of the commit id you want to reference with your tag. You can get the commit id by looking at the... <br />
|
||||
</p>
|
||||
</div>
|
||||
<a name="log"></a>
|
||||
<div class="scrollblock block-log">
|
||||
<h2>log</h2>
|
||||
<p>
|
||||
in its simplest form, you can study repository history using..
|
||||
<code>git log</code><br />
|
||||
You can add a lot of parameters to make the log look like what you want. To see only the commits of a certain author:<br />
|
||||
<code>git log --author=bob</code><br />
|
||||
To see a very compressed log where each commit is one line:<br />
|
||||
<code>git log --pretty=oneline</code><br />
|
||||
Or maybe you want to see an ASCII art tree of all the branches, decorated with the names of tags and branches: <br />
|
||||
<code>git log --graph --oneline --decorate --all</code><br />
|
||||
See only which files have changed: <br />
|
||||
<code>git log --name-status</code><br />
|
||||
These are just a few of the possible parameters you can use. For more, see
|
||||
<code>git log --help</code><br />
|
||||
</p>
|
||||
</div>
|
||||
<a name="checkout-replace"></a>
|
||||
<div class="scrollblock block-checkout-replace">
|
||||
<h2>replace local changes</h2>
|
||||
<p>
|
||||
In case you did something wrong, which for sure never happens ;), you can replace local changes using the command<br />
|
||||
<code>git checkout -- <filename></code><br />
|
||||
this replaces the changes in your working tree with the last content in HEAD. Changes already added to the index, as well as new files, will be kept.
|
||||
</p>
|
||||
<p>
|
||||
If you instead want to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it like this<br />
|
||||
<code>git fetch origin</code><br />
|
||||
<code>git reset --hard origin/master</code>
|
||||
</p>
|
||||
</div>
|
||||
<a name="hints"></a>
|
||||
<div class="scrollblock block-hints">
|
||||
<h2>useful hints</h2>
|
||||
<p>
|
||||
use colorful git output<br />
|
||||
<code>git config color.ui true</code><br />
|
||||
show log on just one line per commit<br />
|
||||
<code>git config format.pretty oneline</code><br />
|
||||
use interactive adding<br />
|
||||
<code>git add -i</code>
|
||||
</p>
|
||||
</div>
|
||||
<a name="resources"></a>
|
||||
<div class="scrollblock block-resources">
|
||||
<h2>guides</h2>
|
||||
<p>
|
||||
<ul>
|
||||
<li><a href="https://git-scm.com/docs/gittutorial">Introduction to Git</a></li>
|
||||
<li><a href="https://git-scm.com/book/en/v2">Pro Git: a free book to learn everything about Git and Github</a></li>
|
||||
<li><a href="https://github.com/jlord/git-it-electron#what-to-install">Git-it: an application to help you begin with Git</a></li>
|
||||
<li><a href="https://learngitbranching.js.org/">Learning Git branching with a browser interactive tool</a></li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
<a name="cheatsheet"></a>
|
||||
<div class="scrollblock block-setup">
|
||||
<h2>cheat sheet</h2>
|
||||
<p>
|
||||
<a href="files/github-git-cheat-sheet.pdf">Git cheat sheet</a>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
4
git/js/jquery-1.7.1.min.js
vendored
Normal file
4
git/js/jquery-1.7.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
git/js/jquery.lettering-0.6.1.min.js
vendored
Normal file
2
git/js/jquery.lettering-0.6.1.min.js
vendored
Normal 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);
|
||||
299
git/js/jquery.scrollorama.js
Normal file
299
git/js/jquery.scrollorama.js
Normal file
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
scrollorama - The jQuery plugin for doing cool scrolly stuff
|
||||
by John Polacek (@johnpolacek)
|
||||
|
||||
Dual licensed under MIT and GPL.
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
$.scrollorama = function(options) {
|
||||
|
||||
// PRIVATE VARS
|
||||
var blocks = [],
|
||||
browserPrefix = '',
|
||||
onBlockChange = function() {};
|
||||
|
||||
var scrollorama = this;
|
||||
|
||||
var defaults = {offset:0};
|
||||
|
||||
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() {
|
||||
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');
|
||||
|
||||
var i;
|
||||
for (i=0; i<scrollorama.settings.blocks.length; i++) {
|
||||
var block = scrollorama.settings.blocks.eq(i);
|
||||
blocks.push({
|
||||
block: block,
|
||||
top: block.offset().top,
|
||||
pin: 0,
|
||||
animations:[]
|
||||
});
|
||||
}
|
||||
|
||||
// convert block elements to absolute position
|
||||
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>");
|
||||
|
||||
var didScroll = false;
|
||||
$(window).scroll(function(){
|
||||
didScroll = true;
|
||||
});
|
||||
setInterval(function(){
|
||||
if(didScroll){
|
||||
onScrollorama();
|
||||
didScroll = false;
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
|
||||
function onScrollorama() {
|
||||
var scrollTop = $(window).scrollTop();
|
||||
var currBlockIndex = getCurrBlockIndex(scrollTop);
|
||||
|
||||
// update all animations
|
||||
for (var i=0; i<blocks.length; i++) {
|
||||
|
||||
// go through the animations for each block
|
||||
if (blocks[i].animations.length) {
|
||||
for (var j=0; j<blocks[i].animations.length; j++) {
|
||||
var 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
|
||||
var startAnimPos = blocks[i].top + anim.delay;
|
||||
if (anim.baseline == 'bottom') startAnimPos -= $(window).height();
|
||||
var 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
|
||||
var animPercent = (scrollTop - startAnimPos) / anim.duration;
|
||||
// then multiply the percent by the value range and calculate the new value
|
||||
var 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;
|
||||
for (var 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) {
|
||||
if (prop === 'rotate' || prop === 'zoom' || prop === 'scale') {
|
||||
if (prop === 'rotate') {
|
||||
target.css(browserPrefix+'transform', 'rotate('+val+'deg)');
|
||||
} else if (prop === 'zoom' || prop === 'scale') {
|
||||
var scaleCSS = 'scale('+val+')';
|
||||
if (browserPrefix !== '-ms-') {
|
||||
target.css(browserPrefix+'transform', scaleCSS);
|
||||
} else {
|
||||
target.css('zoom', scaleCSS);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
target.css(prop, val);
|
||||
}
|
||||
}
|
||||
|
||||
// PUBLIC FUNCTIONS
|
||||
scrollorama.animate = function(target) {
|
||||
/*
|
||||
target = animation target
|
||||
arguments = array of animation parameters
|
||||
|
||||
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)
|
||||
*/
|
||||
|
||||
// if string, convert to DOM object
|
||||
if (typeof target === 'string') target = $(target);
|
||||
|
||||
// find block of target
|
||||
var targetIndex;
|
||||
var targetBlock;
|
||||
for (var 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
|
||||
for (i=1; i<arguments.length; i++) {
|
||||
|
||||
var 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
|
||||
if (anim.start === undefined) anim.start = 0;
|
||||
else if (anim.end === undefined) anim.end = 0;
|
||||
}
|
||||
|
||||
// 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'
|
||||
});
|
||||
|
||||
if (anim.pin) {
|
||||
if (targetBlock.pin < anim.duration + anim.delay) {
|
||||
var offset = anim.duration + anim.delay - targetBlock.pin;
|
||||
targetBlock.pin += offset;
|
||||
|
||||
// adjust positions of blocks below target block
|
||||
for (var 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 = [];
|
||||
for (var 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 (var j=0; j<blocks[i].animations.length; j++) {
|
||||
var 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;
|
||||
};
|
||||
|
||||
|
||||
// INIT
|
||||
init();
|
||||
|
||||
return scrollorama;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user