Skip to content

Commit

Permalink
feat(TDP-1577): key moments anchor points (newsuk#2902)
Browse files Browse the repository at this point in the history
  • Loading branch information
flashcheeks committed Apr 5, 2022
1 parent 28df092 commit fa8c45c
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit fa8c45c

Please sign in to comment.