@folklore/ads 0.0.14 → 0.0.16

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.
Files changed (3) hide show
  1. package/dist/cjs.js +16 -1
  2. package/dist/es.js +16 -1
  3. package/package.json +2 -2
package/dist/cjs.js CHANGED
@@ -864,6 +864,9 @@ function useAd(path, size) {
864
864
  // Listen to render event
865
865
  React.useEffect(() => {
866
866
  if (slot === null) {
867
+ if (renderEvent !== null) {
868
+ setRenderEvent(null);
869
+ }
867
870
  return () => {};
868
871
  }
869
872
  const onSlotRender = event => {
@@ -1013,6 +1016,18 @@ function Ad(_ref) {
1013
1016
  });
1014
1017
  }
1015
1018
  }, [onRender, shouldKeepSize, disabled]);
1019
+ React.useEffect(() => {
1020
+ if (!disabled) {
1021
+ return;
1022
+ }
1023
+ const keepSize = shouldKeepSize && lastRenderedSize.current !== null;
1024
+ if (onRender !== null) {
1025
+ onRender({
1026
+ isEmpty: true,
1027
+ keepSize
1028
+ });
1029
+ }
1030
+ }, [disabled]);
1016
1031
 
1017
1032
  // Create ad
1018
1033
  const {
@@ -1051,7 +1066,7 @@ function Ad(_ref) {
1051
1066
  }
1052
1067
  const waitingNextRender = wasDisabled.current && !isRendered;
1053
1068
  const keepSize = shouldKeepSize && (disabled || waitingNextRender) && lastRenderedSize.current !== null;
1054
- if (id === null) {
1069
+ if (id === null && !keepSize) {
1055
1070
  return null;
1056
1071
  }
1057
1072
  let adStyle = null;
package/dist/es.js CHANGED
@@ -846,6 +846,9 @@ function useAd(path, size) {
846
846
  // Listen to render event
847
847
  useEffect(() => {
848
848
  if (slot === null) {
849
+ if (renderEvent !== null) {
850
+ setRenderEvent(null);
851
+ }
849
852
  return () => {};
850
853
  }
851
854
  const onSlotRender = event => {
@@ -995,6 +998,18 @@ function Ad(_ref) {
995
998
  });
996
999
  }
997
1000
  }, [onRender, shouldKeepSize, disabled]);
1001
+ useEffect(() => {
1002
+ if (!disabled) {
1003
+ return;
1004
+ }
1005
+ const keepSize = shouldKeepSize && lastRenderedSize.current !== null;
1006
+ if (onRender !== null) {
1007
+ onRender({
1008
+ isEmpty: true,
1009
+ keepSize
1010
+ });
1011
+ }
1012
+ }, [disabled]);
998
1013
 
999
1014
  // Create ad
1000
1015
  const {
@@ -1033,7 +1048,7 @@ function Ad(_ref) {
1033
1048
  }
1034
1049
  const waitingNextRender = wasDisabled.current && !isRendered;
1035
1050
  const keepSize = shouldKeepSize && (disabled || waitingNextRender) && lastRenderedSize.current !== null;
1036
- if (id === null) {
1051
+ if (id === null && !keepSize) {
1037
1052
  return null;
1038
1053
  }
1039
1054
  let adStyle = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@folklore/ads",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Ads library",
5
5
  "keywords": [
6
6
  "javascript",
@@ -50,7 +50,7 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "979144c5a475f77dbfb74a4f351166fec318c6c2",
53
+ "gitHead": "581e11b92d31eb0f5f50f810c6347a4b478832d1",
54
54
  "dependencies": {
55
55
  "@folklore/hooks": "^0.0.41",
56
56
  "@folklore/tracking": "^0.0.16",