added animation @mixin; refactored post-viewer binding calls
This commit is contained in:
parent
2815885bcf
commit
ca8e8ac0c2
2 changed files with 72 additions and 10 deletions
|
|
@ -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 */
|
||||
$(document).keydown(function(e){
|
||||
if (e.keyCode == 37 && nextPostLocation) {
|
||||
window.location = nextPostLocation
|
||||
var nextPostLocation = this.model.get("next_post");
|
||||
var previousPostLocation = this.model.get("previous_post");
|
||||
|
||||
}else if(e.keyCode == 39 && previousPostLocation) {
|
||||
window.location = previousPostLocation
|
||||
$(document).keydown(function(e){
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue