Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop the document from jumping to the hash when a token is clicked. #352

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

##### Bug Fixes

* None.
* Expanding a token no longer causes the document to 'jump' to the hash.
[Jeff Verkoeyen](https://github.com/jverkoey)
[#352](https://github.com/realm/jazzy/issues/352)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI we only include links to issues, not PRs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good to know - will fix.


## 0.4.0

Expand Down
11 changes: 10 additions & 1 deletion lib/jazzy/assets/js/jazzy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $(document).ready(function() {
});

// On token click, toggle its discussion and animate token.marginLeft
$(".token").click(function() {
$(".token").click(function(event) {
if (window.jazzy.docset) {
return;
}
Expand All @@ -28,4 +28,13 @@ $(".token").click(function() {
link.animate({'margin-left':original ? "0px" : tokenOffset}, animationDuration);
$content = link.parent().parent().next();
$content.slideToggle(animationDuration);

// Keeps the document from jumping to the hash.
var href = $(this).attr('href');
if (history.pushState) {
history.pushState({}, '', href);
} else {
location.hash = href;
}
event.preventDefault();
});