Skip to content

Commit

Permalink
PLANET-4811 Fix scrolling animation
Browse files Browse the repository at this point in the history
  • Loading branch information
mleray committed Aug 12, 2020
1 parent 9af7a0c commit b21b331
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions assets/src/blocks/Submenu/SubmenuItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ export const SubmenuItems = ({ menuItems }) => {
const onSubmenuLinkClick = id => {
const target = document.getElementById(id);
if (target) {
document.body.animate({
$('html, body').animate({
scrollTop: target.offsetTop - 100
}, 2000, () => {
const position = window.pageYOffset;
window.location.hash = `#${id}`;
window.scrollTop(position);
window.location.hash = id;
window.scrollTo(0, position);
});
}
}
Expand All @@ -20,7 +20,10 @@ export const SubmenuItems = ({ menuItems }) => {
<a
href={`#${id}`}
className="icon-link submenu-link"
onClick={() => onSubmenuLinkClick(id)}
onClick={event => {
event.preventDefault();
onSubmenuLinkClick(id);
}}
>
{text}
</a>
Expand Down

0 comments on commit b21b331

Please sign in to comment.