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

feat(TDP-1577): key moments anchor points #2902

Merged
merged 1 commit into from
Apr 5, 2022
Merged
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
9 changes: 7 additions & 2 deletions packages/key-facts/src/key-facts-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const getTitle = data => {
};

const handleClickEventScrollTo = (event, url) => {
console.log("KEY MOMENTS handleClickEventScrollTo");
console.log("KEY MOMENTS url", url);

if (url.charAt(0) === "#") {
event.preventDefault();

Expand All @@ -21,7 +24,9 @@ const handleClickEventScrollTo = (event, url) => {
const article = target.parentElement.parentElement;
const container = article.parentElement;

console.log(container.offsetTop + article.offsetTop + target.offsetTop);
console.log("KEY MOMENTS container", container, container.offsetTop);
console.log("KEY MOMENTS article", article, article.offsetTop);
console.log("KEY MOMENTS target", target.offsetTop);

window.scroll({
top: container.offsetTop + article.offsetTop + target.offsetTop,
Expand Down Expand Up @@ -64,7 +69,7 @@ const KeyFactsText = ({ listIndex, keyFactItem, fireAnalyticsEvent }) => (
handleClickEventAnalytics(fireAnalyticsEvent, title);
handleClickEventScrollTo(event, url);
}}
href={url}
href={url.charAt(0) === "#" ? null : url}
>
{renderedChildren}
</KeyFactTextLink>
Expand Down