@reuters-graphics/graphics-components 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script>import ResponsiveAd from './ResponsiveAd.svelte';
|
|
2
|
+
import { onMount } from 'svelte';
|
|
2
3
|
/** Add an ID to target with SCSS. */
|
|
3
4
|
export let id = '';
|
|
4
5
|
/** Add a class to target with SCSS. */
|
|
@@ -7,12 +8,40 @@ export { cls as class };
|
|
|
7
8
|
let windowWidth = 1200;
|
|
8
9
|
$: adSize = windowWidth < 1024 ? 110 : 275;
|
|
9
10
|
const desktopPlacementName = 'reuters_desktop_leaderboard_atf';
|
|
11
|
+
let sticky = false;
|
|
12
|
+
// Handles transition out... somewhat dumb, but here we are...
|
|
13
|
+
let unstick = false;
|
|
14
|
+
onMount(() => {
|
|
15
|
+
const handleScroll = () => {
|
|
16
|
+
const scrollTop = window.scrollY;
|
|
17
|
+
if (scrollTop >= adSize * 1.1) {
|
|
18
|
+
sticky = true;
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
unstick = true;
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
sticky = false;
|
|
23
|
+
}, 800);
|
|
24
|
+
}, 3000);
|
|
25
|
+
window.removeEventListener('scroll', handleScroll);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
window.addEventListener('scroll', handleScroll);
|
|
29
|
+
return () => {
|
|
30
|
+
window.removeEventListener('scroll', handleScroll);
|
|
31
|
+
};
|
|
32
|
+
});
|
|
10
33
|
</script>
|
|
11
34
|
|
|
12
35
|
<svelte:window bind:innerWidth="{windowWidth}" />
|
|
13
36
|
|
|
14
37
|
<!-- @component `LeaderboardAd` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-LeaderboardAd--default) -->
|
|
15
|
-
<div
|
|
38
|
+
<div
|
|
39
|
+
class="leaderboard__sticky {cls}"
|
|
40
|
+
class:sticky="{sticky}"
|
|
41
|
+
class:unstick="{unstick}"
|
|
42
|
+
id="{id}"
|
|
43
|
+
style="--height: {adSize}px;"
|
|
44
|
+
>
|
|
16
45
|
<div class="ad-block">
|
|
17
46
|
<div class="ad-slot__container">
|
|
18
47
|
<div class="ad-slot__inner">
|
|
@@ -25,12 +54,18 @@ const desktopPlacementName = 'reuters_desktop_leaderboard_atf';
|
|
|
25
54
|
</div>
|
|
26
55
|
|
|
27
56
|
<style>.leaderboard__sticky {
|
|
28
|
-
position: sticky;
|
|
29
57
|
position: initial;
|
|
30
|
-
top:
|
|
58
|
+
top: -275px;
|
|
31
59
|
transition: top 0.8s ease-in-out;
|
|
32
60
|
z-index: 1030;
|
|
33
61
|
}
|
|
62
|
+
.leaderboard__sticky.sticky {
|
|
63
|
+
position: sticky;
|
|
64
|
+
top: 0px;
|
|
65
|
+
}
|
|
66
|
+
.leaderboard__sticky.unstick {
|
|
67
|
+
top: -275px;
|
|
68
|
+
}
|
|
34
69
|
|
|
35
70
|
div.ad-block {
|
|
36
71
|
width: 100%;
|