@reuters-graphics/graphics-components 1.0.10 → 1.0.12

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.
@@ -2,6 +2,35 @@
2
2
  import { onMount } from 'svelte';
3
3
  import { loadBootstrap } from './adScripts/bootstrap';
4
4
  import { loadScript } from './adScripts/loadScript';
5
+ import { throttle } from 'lodash-es';
6
+
7
+ let lastScroll = 0;
8
+ let showManagePreferences = false;
9
+
10
+ const togglePrefs = (on = true) => {
11
+ const btn = document.getElementById('ot-sdk-btn-floating');
12
+ if (!btn) return;
13
+ if (on) {
14
+ btn.style.bottom = '';
15
+ } else {
16
+ btn.style.bottom = '-5rem';
17
+ }
18
+ };
19
+
20
+ const handleScroll = () => {
21
+ if (lastScroll > window.scrollY) {
22
+ if (!showManagePreferences) {
23
+ showManagePreferences = true;
24
+ togglePrefs(true);
25
+ }
26
+ } else {
27
+ if (showManagePreferences && window.scrollY > 250) {
28
+ showManagePreferences = false;
29
+ togglePrefs(false);
30
+ }
31
+ }
32
+ lastScroll = window.scrollY;
33
+ };
5
34
 
6
35
  onMount(() => {
7
36
  window.graphicsAdQueue = window.graphicsAdQueue || [];
@@ -9,6 +38,9 @@
9
38
  'https://graphics.thomsonreuters.com/cdn/js/bootstrap.static.js',
10
39
  loadBootstrap
11
40
  );
41
+ window.addEventListener('scroll', throttle(handleScroll, 250), {
42
+ passive: true,
43
+ });
12
44
  });
13
45
  </script>
14
46
 
@@ -96,4 +96,10 @@ div.ad-block div.ad-container div.ad-slot__inner {
96
96
  }
97
97
  div.ad-block div.ad-container div.ad-slot__inner > div {
98
98
  display: block;
99
+ }
100
+ div.ad-block div.ad-container div.ad-slot__inner > div div[data-freestar-ad] {
101
+ display: flex;
102
+ flex-direction: column;
103
+ justify-content: center;
104
+ align-items: center;
99
105
  }</style>
@@ -60,7 +60,9 @@
60
60
  lastScroll = window.scrollY;
61
61
  }
62
62
  onMount(() => {
63
- window.addEventListener('scroll', throttle(handleScroll, 250));
63
+ window.addEventListener('scroll', throttle(handleScroll, 250), {
64
+ passive: true,
65
+ });
64
66
  });
65
67
  </script>
66
68
 
@@ -91,7 +93,7 @@
91
93
  position: fixed;
92
94
  bottom: -5rem;
93
95
  right: 10px;
94
- transition: all 0.2s;
96
+ transition: all 300ms ease;
95
97
  z-index: 9999;
96
98
  }
97
99
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reuters-graphics/graphics-components",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://reuters-graphics.github.io/graphics-components",