@financial-times/n-myft-ui 28.2.5 → 28.2.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,8 @@ const csrfToken = getToken();
|
|
10
10
|
let lists = [];
|
11
11
|
let haveLoadedLists = false;
|
12
12
|
let createListOverlay;
|
13
|
+
let scrolledOnOpen;
|
14
|
+
let listOverlayBottom;
|
13
15
|
|
14
16
|
export default async function openSaveArticleToListVariant (contentId, options = {}) {
|
15
17
|
const { name, showPublicToggle = false } = options;
|
@@ -118,6 +120,7 @@ export default async function openSaveArticleToListVariant (contentId, options =
|
|
118
120
|
}
|
119
121
|
|
120
122
|
createListOverlay.open();
|
123
|
+
scrolledOnOpen = window.scrollY;
|
121
124
|
|
122
125
|
const scrollHandler = getScrollHandler(createListOverlay.wrapper);
|
123
126
|
const resizeHandler = getResizeHandler(createListOverlay.wrapper);
|
@@ -130,6 +133,8 @@ export default async function openSaveArticleToListVariant (contentId, options =
|
|
130
133
|
|
131
134
|
positionOverlay(data.currentTarget);
|
132
135
|
|
136
|
+
listOverlayBottom = document.querySelector('.myft-ui-create-list-variant').getBoundingClientRect().bottom;
|
137
|
+
|
133
138
|
restoreFormHandler();
|
134
139
|
|
135
140
|
document.querySelector('.article-content').addEventListener('click', outsideClickHandler);
|
@@ -306,6 +311,7 @@ function ContentElement (hasDescription, onClick) {
|
|
306
311
|
|
307
312
|
const contentElement = stringToHTMLElement(content);
|
308
313
|
|
314
|
+
contentElement.querySelector('.myft-ui-create-list-variant-add').addEventListener('click', checkScrollToAdd);
|
309
315
|
contentElement.querySelector('.myft-ui-create-list-variant-add').addEventListener('click', triggerAddToNewListEvent);
|
310
316
|
|
311
317
|
function removeDescription () {
|
@@ -590,3 +596,19 @@ function triggerCancelEvent () {
|
|
590
596
|
bubbles: true
|
591
597
|
}));
|
592
598
|
}
|
599
|
+
|
600
|
+
//Temporary event to determine whether users need to scroll to add to a list
|
601
|
+
function checkScrollToAdd () {
|
602
|
+
//if the bottom of the overlay was not showing and scrolling has occurred since it was opened
|
603
|
+
if(listOverlayBottom > window.innerHeight && window.scrollY > scrolledOnOpen) {
|
604
|
+
document.body.dispatchEvent(new CustomEvent('oTracking.event', {
|
605
|
+
detail: {
|
606
|
+
category: 'publicToggle',
|
607
|
+
action: 'scrollToAdd',
|
608
|
+
teamName: 'customer-products-us-growth',
|
609
|
+
amplitudeExploratory: true
|
610
|
+
},
|
611
|
+
bubbles: true
|
612
|
+
}));
|
613
|
+
}
|
614
|
+
}
|