@aarhus-university/au-lib-react-components 8.83.0 → 8.84.0

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "@aarhus-university/au-lib-react-components",
4
- "version": "8.83.0",
4
+ "version": "8.84.0",
5
5
  "description": "Library for shared React components for various applications on au.dk",
6
6
  "scripts": {
7
7
  "build": "webpack --config ./webpack.config.js"
@@ -1,5 +1,5 @@
1
1
  /* eslint-env browser */
2
- import React, { useEffect, FC } from 'react';
2
+ import React, { useState, useEffect, FC } from 'react';
3
3
  import { isElementInViewport } from '../lib/helpers';
4
4
 
5
5
  const AUSpinnerComponent: FC<AUSpinnerComponentProps> = ({
@@ -13,12 +13,15 @@ const AUSpinnerComponent: FC<AUSpinnerComponentProps> = ({
13
13
  init,
14
14
  onLoad,
15
15
  }: AUSpinnerComponentProps) => {
16
+ const [loading, setLoading] = useState<boolean>(true);
16
17
  const lazyLoad = (): void => {
17
18
  const element = document.getElementById(domID as string);
18
19
  if (element
19
20
  && !loaded
21
+ && loading
20
22
  && loadingCondition
21
23
  && (visible || isElementInViewport(element))) {
24
+ setLoading(false);
22
25
  onLoad();
23
26
  }
24
27
  };
@@ -27,7 +30,7 @@ const AUSpinnerComponent: FC<AUSpinnerComponentProps> = ({
27
30
  window.addEventListener('scroll', () => {
28
31
  lazyLoad();
29
32
  });
30
- }, []);
33
+ });
31
34
 
32
35
  useEffect(() => {
33
36
  lazyLoad();