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
// Register keyboard events | |
$(document).keydown(function(e) { | |
if (e.keyCode === 37) { | |
// Previous | |
$(".carousel-control.left").click(); | |
return false; | |
} | |
if (e.keyCode === 39) { | |
// Next | |
$(".carousel-control.right").click(); |
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
// child: jquery object e.g $(".active .slide-caption") | |
// parent: jquery object e.g $(".active.slide") | |
// property (string): CSS property to change depending on your CSS positioning e.g. "top", "margin-top" or "bottom" | |
function centerVertical(child, parent, property) { | |
var parentHeight = parent.height(), | |
childHeight = child.height(); | |
// Handle edge cases with padding or margins affecting child.height() calculation | |
if (child.find("h1").length) { |
NewerOlder