@folklore/ads 0.0.60 → 0.0.62
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/dist/cjs.js +21 -0
- package/dist/es.js +21 -0
- package/package.json +3 -3
package/dist/cjs.js
CHANGED
|
@@ -209,6 +209,7 @@ class AdSlot extends EventEmitter__default["default"] {
|
|
|
209
209
|
this.displayed = false;
|
|
210
210
|
this.renderEvent = null;
|
|
211
211
|
this.destroyed = true;
|
|
212
|
+
this.emit('destroy', this);
|
|
212
213
|
}
|
|
213
214
|
getElementId() {
|
|
214
215
|
return this.elementId;
|
|
@@ -576,6 +577,7 @@ class AdsManager extends EventEmitter__default["default"] {
|
|
|
576
577
|
googletag.destroySlots([adSlot]);
|
|
577
578
|
});
|
|
578
579
|
}
|
|
580
|
+
this.emit('destroy:slot', slot);
|
|
579
581
|
}
|
|
580
582
|
refreshSlot(id) {
|
|
581
583
|
const {
|
|
@@ -854,6 +856,7 @@ function useAd(path, size) {
|
|
|
854
856
|
refreshInterval = null,
|
|
855
857
|
alwaysRender = false,
|
|
856
858
|
onRender = null,
|
|
859
|
+
onDestroy = null,
|
|
857
860
|
disabled = false,
|
|
858
861
|
disableTracking = false,
|
|
859
862
|
rootMargin = '300px'
|
|
@@ -988,6 +991,20 @@ function useAd(path, size) {
|
|
|
988
991
|
return () => slot.off('render', onSlotRender);
|
|
989
992
|
}, [slot, disabled, setRenderEvent, onRender, track]);
|
|
990
993
|
|
|
994
|
+
// Listen to destroy event
|
|
995
|
+
React.useEffect(() => {
|
|
996
|
+
if (slot === null) {
|
|
997
|
+
return () => {};
|
|
998
|
+
}
|
|
999
|
+
const onSlotDestroy = destroySlot => {
|
|
1000
|
+
if (onDestroy !== null) {
|
|
1001
|
+
onDestroy(destroySlot);
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
slot.on('destroy', onSlotDestroy);
|
|
1005
|
+
return () => slot.off('destroy', onSlotDestroy);
|
|
1006
|
+
}, [slot, onDestroy]);
|
|
1007
|
+
|
|
991
1008
|
// Destroy slot
|
|
992
1009
|
// useEffect(
|
|
993
1010
|
// () => () => {
|
|
@@ -1031,6 +1048,7 @@ const propTypes = {
|
|
|
1031
1048
|
emptyClassName: PropTypes__default["default"].string,
|
|
1032
1049
|
adClassName: PropTypes__default["default"].string,
|
|
1033
1050
|
onRender: PropTypes__default["default"].func,
|
|
1051
|
+
onDestroy: PropTypes__default["default"].func,
|
|
1034
1052
|
slotRef: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object])
|
|
1035
1053
|
};
|
|
1036
1054
|
const defaultProps = {
|
|
@@ -1049,6 +1067,7 @@ const defaultProps = {
|
|
|
1049
1067
|
emptyClassName: null,
|
|
1050
1068
|
adClassName: null,
|
|
1051
1069
|
onRender: null,
|
|
1070
|
+
onDestroy: null,
|
|
1052
1071
|
slotRef: null
|
|
1053
1072
|
};
|
|
1054
1073
|
function Ad(_ref) {
|
|
@@ -1069,6 +1088,7 @@ function Ad(_ref) {
|
|
|
1069
1088
|
emptyClassName,
|
|
1070
1089
|
adClassName,
|
|
1071
1090
|
onRender,
|
|
1091
|
+
onDestroy,
|
|
1072
1092
|
slotRef
|
|
1073
1093
|
} = _ref;
|
|
1074
1094
|
const {
|
|
@@ -1162,6 +1182,7 @@ function Ad(_ref) {
|
|
|
1162
1182
|
refreshInterval: finalAdTargeting.refreshInterval,
|
|
1163
1183
|
alwaysRender,
|
|
1164
1184
|
onRender: onAdRender,
|
|
1185
|
+
onDestroy,
|
|
1165
1186
|
disabled: finalDisabled,
|
|
1166
1187
|
disableTracking
|
|
1167
1188
|
});
|
package/dist/es.js
CHANGED
|
@@ -191,6 +191,7 @@ class AdSlot extends EventEmitter {
|
|
|
191
191
|
this.displayed = false;
|
|
192
192
|
this.renderEvent = null;
|
|
193
193
|
this.destroyed = true;
|
|
194
|
+
this.emit('destroy', this);
|
|
194
195
|
}
|
|
195
196
|
getElementId() {
|
|
196
197
|
return this.elementId;
|
|
@@ -558,6 +559,7 @@ class AdsManager extends EventEmitter {
|
|
|
558
559
|
googletag.destroySlots([adSlot]);
|
|
559
560
|
});
|
|
560
561
|
}
|
|
562
|
+
this.emit('destroy:slot', slot);
|
|
561
563
|
}
|
|
562
564
|
refreshSlot(id) {
|
|
563
565
|
const {
|
|
@@ -836,6 +838,7 @@ function useAd(path, size) {
|
|
|
836
838
|
refreshInterval = null,
|
|
837
839
|
alwaysRender = false,
|
|
838
840
|
onRender = null,
|
|
841
|
+
onDestroy = null,
|
|
839
842
|
disabled = false,
|
|
840
843
|
disableTracking = false,
|
|
841
844
|
rootMargin = '300px'
|
|
@@ -970,6 +973,20 @@ function useAd(path, size) {
|
|
|
970
973
|
return () => slot.off('render', onSlotRender);
|
|
971
974
|
}, [slot, disabled, setRenderEvent, onRender, track]);
|
|
972
975
|
|
|
976
|
+
// Listen to destroy event
|
|
977
|
+
useEffect(() => {
|
|
978
|
+
if (slot === null) {
|
|
979
|
+
return () => {};
|
|
980
|
+
}
|
|
981
|
+
const onSlotDestroy = destroySlot => {
|
|
982
|
+
if (onDestroy !== null) {
|
|
983
|
+
onDestroy(destroySlot);
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
slot.on('destroy', onSlotDestroy);
|
|
987
|
+
return () => slot.off('destroy', onSlotDestroy);
|
|
988
|
+
}, [slot, onDestroy]);
|
|
989
|
+
|
|
973
990
|
// Destroy slot
|
|
974
991
|
// useEffect(
|
|
975
992
|
// () => () => {
|
|
@@ -1013,6 +1030,7 @@ const propTypes = {
|
|
|
1013
1030
|
emptyClassName: PropTypes.string,
|
|
1014
1031
|
adClassName: PropTypes.string,
|
|
1015
1032
|
onRender: PropTypes.func,
|
|
1033
|
+
onDestroy: PropTypes.func,
|
|
1016
1034
|
slotRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
1017
1035
|
};
|
|
1018
1036
|
const defaultProps = {
|
|
@@ -1031,6 +1049,7 @@ const defaultProps = {
|
|
|
1031
1049
|
emptyClassName: null,
|
|
1032
1050
|
adClassName: null,
|
|
1033
1051
|
onRender: null,
|
|
1052
|
+
onDestroy: null,
|
|
1034
1053
|
slotRef: null
|
|
1035
1054
|
};
|
|
1036
1055
|
function Ad(_ref) {
|
|
@@ -1051,6 +1070,7 @@ function Ad(_ref) {
|
|
|
1051
1070
|
emptyClassName,
|
|
1052
1071
|
adClassName,
|
|
1053
1072
|
onRender,
|
|
1073
|
+
onDestroy,
|
|
1054
1074
|
slotRef
|
|
1055
1075
|
} = _ref;
|
|
1056
1076
|
const {
|
|
@@ -1144,6 +1164,7 @@ function Ad(_ref) {
|
|
|
1144
1164
|
refreshInterval: finalAdTargeting.refreshInterval,
|
|
1145
1165
|
alwaysRender,
|
|
1146
1166
|
onRender: onAdRender,
|
|
1167
|
+
onDestroy,
|
|
1147
1168
|
disabled: finalDisabled,
|
|
1148
1169
|
disableTracking
|
|
1149
1170
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@folklore/ads",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62",
|
|
4
4
|
"description": "Ads library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "db9d1c6c7ec6018ab00e67f5992bfd1544770c12",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@folklore/hooks": "^0.0.
|
|
55
|
+
"@folklore/hooks": "^0.0.58",
|
|
56
56
|
"@folklore/tracking": "^0.0.23",
|
|
57
57
|
"classnames": "^2.5.1",
|
|
58
58
|
"debug": "^4.3.4",
|