-
-
Save benatkin/1090210 to your computer and use it in GitHub Desktop.
Refactored the API for sauce.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head></head> | |
<body> | |
<div id="container"> | |
<header> | |
<h1 id="sauce">Sauce.js</h1> | |
<h2 id="tagline">Add some flavor to the web!</h2> | |
</header> | |
</div> | |
<script type="text/javascript" src="http://raw.github.com/jimjeffers/Sauce/master/src/easie.js"></script> | |
<script type="text/javascript" src="http://raw.github.com/jimjeffers/Sauce/master/src/sauce.js"></script> | |
<script type="text/javascript" src="newSauce.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make a sauce for the headline... | |
var headlineSauce = new Sauce(); | |
headlineSauce.recipe(function(element){ | |
element.change("y").from(-200).using(Easie.bounceOut); | |
element.change("scale").from(0).using(Easie.circOut); | |
}); | |
headlineSauce.duration(1).delay(1).putOn("sauce"); | |
// Make a sauce for the tagline... | |
var taglineSauce = new Sauce(); | |
taglineSauce.recipe(function(element){ | |
element.change("x").from(-200).to(-10).using(Easie.backInOut); | |
element.change("opacity").from(0).using(Easie.circOut).endingOnFrame(45) | |
}); | |
taglineSauce.delay(2).putOn("tagline"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// don't run | |
function() { | |
// Define the flavors... | |
var spicyBounce = new Flavor("spicyBounce", { | |
equation: Easie.bounceOut, | |
from: -200, | |
to: 0 | |
}); | |
var sourScale = new Flavor("sourScale", { | |
equation: Easie.circOut, | |
from: 0, | |
to: 1, | |
startFrame:0, | |
endFrame: 45 | |
}); | |
var tangySlide = new Flavor("tangySlide", { | |
equation: Easie.backInOut, | |
from: -100, | |
to: 0 | |
}); | |
// Create some sauces... | |
var marinara = new Sauce().addFlavor(spicyBounce).addFlavor(sourScale); | |
marinara.stirWith( | |
function(flavors,ingredient) { | |
ingredient.y = flavors.spicyBounce.value; | |
ingredient.scale = flavors.sourScale.value; | |
}); | |
var pesto = new Sauce().addFlavor(tangySlide).addFlavor(sourScale); | |
pesto.stirWith( | |
function(flavors,ingredient) { | |
ingredient.x = flavors.tangySlide.value; | |
ingredient.setRule("opacity",flavors.sourScale.value) | |
}); | |
// Apply the sauce. | |
marinara.applyTo("sauce",1).onComplete(function(element,flavors,browser) { | |
pesto.pour(1); | |
}).pour(1); | |
pesto.applyTo("tagline"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment