Methodology

Principles

Q&A

Previous

*/

*/

*/

<!–

$(document).ready(function() {
/* open collapse if hash is a collapse */ if (location.hash) { var hashMatch = location.hash.match(/#[a-z0-9\-]*/i); var hash = hashMatch && hashMatch[0]; var fromMatch = location.hash.match(/from=([^&]+)/i); var from = fromMatch && fromMatch[1]; var $target = $(hash); if ($target.is(“.collapse”)) {
$target.collapse(“show”);
} window.scrollTo({ left: 0, top: $target.offset().top – 20, behavior: “smooth”
}); if (from) { var $toggle = $target.find(“[data-toggle]”); var $returnLink = $(

);
$returnLink.insertBefore($toggle);
$returnLink .find(“a”)
.html(
“Back to previous page ↪”
);
$toggle.remove();
}
}

/* add listener to scroll between collapse and toggles */
$(“.collapse”).on(“shown.bs.collapse”, function(e) { var $target = $(e.target).first(); window.scrollTo({ left: 0, top: $target.offset().top – 20, behavior: “smooth”
});
});

$(“.collapse”).on(“hide.bs.collapse”, function(e) { var $target = $(e.target).first(); var $id = $target.attr(“id”); var $scrollTarget = $(“a[href=’#” + $id + “‘]”).first(); window.scrollTo({ left: 0, top: $scrollTarget.offset().top – 20, behavior: “smooth”
});
});
});

//–>