Line 48: | Line 48: | ||
}); | }); | ||
}); | }); | ||
+ | |||
+ | // The function actually applying the offset | ||
+ | function offsetAnchor() { | ||
+ | if (location.hash.length !== 0) { | ||
+ | window.scrollTo(window.scrollX, window.scrollY - 100); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // Captures click events of all <a> elements with href starting with # | ||
+ | $(document).on('click', 'a[href^="#"]', function(event) { | ||
+ | // Click events are captured before hashchanges. Timeout | ||
+ | // causes offsetAnchor to be called after the page jump. | ||
+ | window.setTimeout(function() { | ||
+ | offsetAnchor(); | ||
+ | }, 0); | ||
+ | }); | ||
+ | |||
+ | // Set the offset when entering page with hash present in the url | ||
+ | window.setTimeout(offsetAnchor, 0); | ||
+ | |||
+ | |||
</script> | </script> | ||
<body> | <body> |
Revision as of 19:21, 13 October 2018
- Judging Form
- About Us
- Judging
- For Judges (this page)
- Team
- Attributions
- Medal
- Judging
- Project
- Judging
- Parts
- Modeling
- Judging
- Enzyme Model
- Lignin Model
- Tools
- Drylab
- Judging
- Engineering
- Human Practices
- Notebook