added animation @mixin; refactored post-viewer binding calls

This commit is contained in:
danielgrippi 2012-02-19 21:26:50 -08:00
parent 2815885bcf
commit ca8e8ac0c2
2 changed files with 72 additions and 10 deletions

View file

@ -26,28 +26,43 @@ app.pages.PostViewer = app.views.Base.extend({
},
postRenderTemplate : function() {
this.setKeyMappings();
this.bindNavHooks();
},
setKeyMappings : function() {
var nextPostLocation = this.model.get("next_post");
var previousPostLocation = this.model.get("previous_post");
bindQuickCommenting : function() {
/* focus modal */
// doc.keypress(function(){
// $('#text').focus();
// $('#comment').modal();
// });
},
bindNavHooks : function() {
/* navagation hooks */
var nextPostLocation = this.model.get("next_post");
var previousPostLocation = this.model.get("previous_post");
$(document).keydown(function(e){
if (e.keyCode == 37 && nextPostLocation) {
window.location = nextPostLocation
}else if(e.keyCode == 39 && previousPostLocation) {
window.location = previousPostLocation
switch(e.keyCode) {
case 37:
navigate(nextPostLocation, "left"); break;
case 39:
navigate(previousPostLocation, "right"); break;
default:
break;
}
})
function navigate(loc, direction) {
loc ? window.location = loc : bump(direction)
}
function bump(direction) {
$(".backdrop").addClass("bump-" + direction)
setTimeout( function(){
$(".backdrop").removeClass("bump-" + direction)
}, 200)
}
}
})

View file

@ -45,8 +45,55 @@ $light-grey: #999;
transition: $type $speed;
}
@mixin animation($name, $speed:0.2s, $easing:ease-in-out) {
-webkit-animation: $name $speed $easing;
-moz-animation: $name $speed $easing;
-ms-animation: $name $speed $easing;
}
/* keyframes */
@-webkit-keyframes bump-left {
0% { left: 0; }
40% { left: 20px; }
100% { left: 0; }
}
@-moz-keyframes bump-left {
0% { left: 0; }
40% { left: 20px; }
100% { left: 0; }
}
@-ms-keyframes bump-left {
0% { left: 0; }
40% { left: 20px; }
100% { left: 0; }
}
@-webkit-keyframes bump-right {
0% { left: 0; }
40% { left: -20px; }
100% { left: 0; }
}
@-moz-keyframes bump-right {
0% { left: 0; }
40% { left: -20px; }
100% { left: 0; }
}
@-ms-keyframes bump-right {
0% { left: 0; }
40% { left: 20px; }
100% { left: 0; }
}
/* styles */
.bump-left { @include animation(bump-left) }
.bump-right { @include animation(bump-right) }
.multi-photo {
.img-bounding-box {
@include center(horizontal);