Last active
November 10, 2017 23:34
-
-
Save NathanQ/f102620ebb92ebe36a33f8730b00fb49 to your computer and use it in GitHub Desktop.
Bootstrap accordion, tabs, and carousel helpers so the site looks and acts better
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
// scroll to heading of open collapse item so content is presented on the screen | |
$(function() { | |
$('.panel-collapse').on('shown.bs.collapse', function (e) { | |
var $panel = $(this).closest('.panel'); | |
$('html,body').animate({ | |
scrollTop: $panel.offset().top | |
}, 250); | |
}); | |
}); | |
// make things in a group the same height | |
function sameHeightenate(groupToSameHeight, sameHeighters) { | |
$(groupToSameHeight).each(function() { | |
var tallest = 0; | |
$(sameHeighters, $(groupToSameHeight)).each(function() { | |
tallest = tallest > $(this).height() ? tallest: $(this).height(); | |
}); | |
$(sameHeighters, $(groupToSameHeight)).each(function() { | |
$(this).height(tallest); | |
}); | |
}); | |
} | |
$(function() { | |
// example | |
sameHeightenate('.card-group.row', '.card'); | |
sameHeightenate('.carousel.row', '.carousel-item'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment