-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the source files.
- Loading branch information
Caio Tarifa
committed
Aug 26, 2015
0 parents
commit af209ea
Showing
7 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
### OSX ### | ||
.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Vanilla Raptorize | ||
|
||
This is a lightweight port from the original [Zurb Raptorize](http://zurb.com/playground/jquery-raptorize) made with modern technologies. | ||
|
||
## Usage | ||
|
||
First of all, you'll need instance that: | ||
|
||
```javascript | ||
var myRaptor = Raptorize(); | ||
``` | ||
|
||
Then, when you want to see El Raptor on your screen, just call him like this: | ||
|
||
```javascript | ||
myRaptor.go(); | ||
``` | ||
|
||
## Configurations | ||
|
||
These are our defaults: | ||
|
||
```javascript | ||
{ | ||
audioPath: ['assets/sounds/raptor.mp3', 'assets/sounds/raptor.ogg'], | ||
imagePath: 'assets/images/raptor.png', | ||
|
||
className: 'raptor', | ||
animationTime: 2000 | ||
} | ||
``` | ||
|
||
You can override any option: | ||
|
||
```javascript | ||
var myRaptor = Raptorize({ | ||
className: 'el-raptor', | ||
animationTime: 500 | ||
}); | ||
``` | ||
|
||
## Examples | ||
|
||
### Click Event | ||
|
||
```javascript | ||
var myRaptor = Raptorize(); | ||
|
||
// Without jQuery | ||
document.querySelector('my-selector').addEventListener('click', myRaptor.go); | ||
|
||
// With jQuery | ||
$('my-selector').on('click', myRaptor.go); | ||
|
||
``` | ||
|
||
### Konami Code | ||
|
||
```javascript | ||
var myRaptor, konamiIndex, konamiCode; | ||
|
||
myRaptor = Raptorize(); | ||
konamiIndex = 0; | ||
konamiCode = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13]; | ||
|
||
window.addEventListener('keydown', function(event) { | ||
if (event.keyCode === konamiCode[konamiIndex]) { | ||
konamiIndex++; | ||
if (konamiIndex == konamiCode.length) { myRaptor.go(); } | ||
} else { | ||
konamiIndex = 0; | ||
} | ||
}); | ||
|
||
``` | ||
|
||
--- | ||
|
||
That's all, folks. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@keyframes raptorGO { | ||
25% { | ||
transform: translateY(0); | ||
} | ||
35% { | ||
right: 0; | ||
transform: translateY(25%); | ||
} | ||
75% { | ||
opacity: 1; | ||
} | ||
100% { | ||
opacity: 0; | ||
right: 100%; | ||
transform: translateY(25%); | ||
} | ||
} | ||
|
||
.raptor { | ||
display: none; | ||
bottom: 0; | ||
position: fixed; | ||
transform: translateY(100%); | ||
right: 0; | ||
} | ||
|
||
.raptor-go { | ||
animation: raptorGO 2500ms; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
var Raptorize = (function(extended) { | ||
'use strict'; | ||
|
||
var body, defaults, options, | ||
audioTemplate, sourceAudioTemplate, imageTemplate, | ||
audio, image; | ||
|
||
body = document.body; | ||
options = {}; | ||
|
||
//--- OPTIONS ---// | ||
defaults = { | ||
audioPath: ['assets/sounds/raptor.mp3', 'assets/sounds/raptor.ogg'], | ||
imagePath: 'assets/images/raptor.png', | ||
|
||
className: 'raptor', | ||
animationTime: 2000 | ||
}; | ||
|
||
extend(options, defaults, extended); | ||
|
||
//--- SETUP ---// | ||
audioTemplate = document.createElement('audio'); | ||
audioTemplate.className = options.className + '-source'; | ||
|
||
for (var source in options.audioPath) { | ||
sourceAudioTemplate = document.createElement('source'); | ||
sourceAudioTemplate.src = options.audioPath[source]; | ||
audioTemplate.appendChild(sourceAudioTemplate); | ||
} | ||
|
||
imageTemplate = document.createElement('img'); | ||
imageTemplate.className = options.className; | ||
imageTemplate.src = options.imagePath; | ||
|
||
audio = body.appendChild(audioTemplate); | ||
image = body.appendChild(imageTemplate); | ||
|
||
image.style.display = 'none'; | ||
|
||
//--- THE HILARITY ---// | ||
function go() { | ||
setTimeout(function () { | ||
audio.play(); | ||
}, (options.animationTime / 3)); | ||
|
||
image.style.display = 'block'; | ||
image.classList.add(options.className + '-go'); | ||
|
||
setTimeout(function () { | ||
image.classList.remove(options.className + '-go'); | ||
}, options.animationTime); | ||
} | ||
|
||
//--- EXTEND (COMMON) ---// | ||
// Use Object.assign() for EcmaScript 6. | ||
function extend(out) { | ||
out = out || {}; | ||
|
||
for (var i = 1; i < arguments.length; i++) { | ||
if (!arguments[i]) { continue; } | ||
for (var key in arguments[i]) { | ||
if (arguments[i].hasOwnProperty(key)) { out[key] = arguments[i][key]; } | ||
} | ||
} | ||
|
||
return out; | ||
} | ||
|
||
return { go: go } | ||
}); | ||
|
||
|
||
|
||
//--- USAGE ---// | ||
var myRaptor = Raptorize({ | ||
audioPath: ['//zurb.com/playground/uploads/upload/upload/230/raptor-sound.mp3', | ||
'//zurb.com/playground/uploads/upload/upload/231/raptor-sound.ogg'], | ||
imagePath: '//zurb.com/playground/uploads/upload/upload/224/raptor.png', | ||
}); | ||
|
||
setTimeout(myRaptor.go, 3000); |