@folklore/ads 0.0.105 → 0.0.106
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 +8 -20
- package/dist/es.js +8 -20
- package/package.json +2 -2
package/dist/cjs.js
CHANGED
|
@@ -1250,24 +1250,18 @@ function Ad(_ref) {
|
|
|
1250
1250
|
targeting: otherProps || {}
|
|
1251
1251
|
};
|
|
1252
1252
|
}, [slotName, contextTargeting, providedTargeting, ads, providedRefreshInterval, providedDisabled, providedViewport, contextViewport]);
|
|
1253
|
-
const lastRenderedSize = React.
|
|
1254
|
-
const wasDisabled = React.useRef(disabled);
|
|
1255
|
-
React.useEffect(() => {}, []);
|
|
1253
|
+
const [lastRenderedSize, setLastRenderedSize] = React.useState(null);
|
|
1256
1254
|
const onAdRender = React.useCallback(event => {
|
|
1257
1255
|
const {
|
|
1258
1256
|
isEmpty: newIsEmpty = true,
|
|
1259
1257
|
width: newWidth,
|
|
1260
1258
|
height: newHeight
|
|
1261
1259
|
} = event || {};
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
} else if (!disabled && !newIsEmpty) {
|
|
1265
|
-
wasDisabled.current = false;
|
|
1266
|
-
}
|
|
1267
|
-
lastRenderedSize.current = !newIsEmpty ? {
|
|
1260
|
+
const isRendered = !newIsEmpty;
|
|
1261
|
+
setLastRenderedSize(isRendered ? {
|
|
1268
1262
|
width: newWidth,
|
|
1269
1263
|
height: newHeight
|
|
1270
|
-
} : null;
|
|
1264
|
+
} : null);
|
|
1271
1265
|
if (onRender !== null) {
|
|
1272
1266
|
onRender(event);
|
|
1273
1267
|
}
|
|
@@ -1317,13 +1311,7 @@ function Ad(_ref) {
|
|
|
1317
1311
|
// eslint-disable-next-line no-param-reassign
|
|
1318
1312
|
slotRef.current = slotObject;
|
|
1319
1313
|
}
|
|
1320
|
-
|
|
1321
|
-
wasDisabled.current = true;
|
|
1322
|
-
} else if (!disabled && isRendered) {
|
|
1323
|
-
wasDisabled.current = false;
|
|
1324
|
-
}
|
|
1325
|
-
const waitingNextRender = wasDisabled.current && !isRendered;
|
|
1326
|
-
const keepSize = shouldKeepSize && (disabled || waitingNextRender) && lastRenderedSize.current !== null;
|
|
1314
|
+
const keepSize = shouldKeepSize && lastRenderedSize !== null && !isRendered;
|
|
1327
1315
|
if (id === null && !keepSize) {
|
|
1328
1316
|
return null;
|
|
1329
1317
|
}
|
|
@@ -1333,8 +1321,8 @@ function Ad(_ref) {
|
|
|
1333
1321
|
width,
|
|
1334
1322
|
height
|
|
1335
1323
|
} : null;
|
|
1336
|
-
} else if (
|
|
1337
|
-
adStyle = lastRenderedSize
|
|
1324
|
+
} else if (keepSize) {
|
|
1325
|
+
adStyle = lastRenderedSize;
|
|
1338
1326
|
} else if (!withoutMinimumSize) {
|
|
1339
1327
|
adStyle = minimumSize;
|
|
1340
1328
|
}
|
|
@@ -1355,7 +1343,7 @@ function Ad(_ref) {
|
|
|
1355
1343
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1356
1344
|
id: id !== null ? `${id}-container` : null,
|
|
1357
1345
|
className: classNames([className, {
|
|
1358
|
-
[emptyClassName]: emptyClassName !== null && isEmpty
|
|
1346
|
+
[emptyClassName]: emptyClassName !== null && isEmpty && !keepSize
|
|
1359
1347
|
}]),
|
|
1360
1348
|
style: !withoutStyle ? containerStyle : null,
|
|
1361
1349
|
ref: refObserver,
|
package/dist/es.js
CHANGED
|
@@ -1248,24 +1248,18 @@ function Ad(_ref) {
|
|
|
1248
1248
|
targeting: otherProps || {}
|
|
1249
1249
|
};
|
|
1250
1250
|
}, [slotName, contextTargeting, providedTargeting, ads, providedRefreshInterval, providedDisabled, providedViewport, contextViewport]);
|
|
1251
|
-
const lastRenderedSize =
|
|
1252
|
-
const wasDisabled = useRef(disabled);
|
|
1253
|
-
useEffect(() => {}, []);
|
|
1251
|
+
const [lastRenderedSize, setLastRenderedSize] = useState(null);
|
|
1254
1252
|
const onAdRender = useCallback(event => {
|
|
1255
1253
|
const {
|
|
1256
1254
|
isEmpty: newIsEmpty = true,
|
|
1257
1255
|
width: newWidth,
|
|
1258
1256
|
height: newHeight
|
|
1259
1257
|
} = event || {};
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
} else if (!disabled && !newIsEmpty) {
|
|
1263
|
-
wasDisabled.current = false;
|
|
1264
|
-
}
|
|
1265
|
-
lastRenderedSize.current = !newIsEmpty ? {
|
|
1258
|
+
const isRendered = !newIsEmpty;
|
|
1259
|
+
setLastRenderedSize(isRendered ? {
|
|
1266
1260
|
width: newWidth,
|
|
1267
1261
|
height: newHeight
|
|
1268
|
-
} : null;
|
|
1262
|
+
} : null);
|
|
1269
1263
|
if (onRender !== null) {
|
|
1270
1264
|
onRender(event);
|
|
1271
1265
|
}
|
|
@@ -1315,13 +1309,7 @@ function Ad(_ref) {
|
|
|
1315
1309
|
// eslint-disable-next-line no-param-reassign
|
|
1316
1310
|
slotRef.current = slotObject;
|
|
1317
1311
|
}
|
|
1318
|
-
|
|
1319
|
-
wasDisabled.current = true;
|
|
1320
|
-
} else if (!disabled && isRendered) {
|
|
1321
|
-
wasDisabled.current = false;
|
|
1322
|
-
}
|
|
1323
|
-
const waitingNextRender = wasDisabled.current && !isRendered;
|
|
1324
|
-
const keepSize = shouldKeepSize && (disabled || waitingNextRender) && lastRenderedSize.current !== null;
|
|
1312
|
+
const keepSize = shouldKeepSize && lastRenderedSize !== null && !isRendered;
|
|
1325
1313
|
if (id === null && !keepSize) {
|
|
1326
1314
|
return null;
|
|
1327
1315
|
}
|
|
@@ -1331,8 +1319,8 @@ function Ad(_ref) {
|
|
|
1331
1319
|
width,
|
|
1332
1320
|
height
|
|
1333
1321
|
} : null;
|
|
1334
|
-
} else if (
|
|
1335
|
-
adStyle = lastRenderedSize
|
|
1322
|
+
} else if (keepSize) {
|
|
1323
|
+
adStyle = lastRenderedSize;
|
|
1336
1324
|
} else if (!withoutMinimumSize) {
|
|
1337
1325
|
adStyle = minimumSize;
|
|
1338
1326
|
}
|
|
@@ -1353,7 +1341,7 @@ function Ad(_ref) {
|
|
|
1353
1341
|
return /*#__PURE__*/jsx("div", {
|
|
1354
1342
|
id: id !== null ? `${id}-container` : null,
|
|
1355
1343
|
className: classNames([className, {
|
|
1356
|
-
[emptyClassName]: emptyClassName !== null && isEmpty
|
|
1344
|
+
[emptyClassName]: emptyClassName !== null && isEmpty && !keepSize
|
|
1357
1345
|
}]),
|
|
1358
1346
|
style: !withoutStyle ? containerStyle : null,
|
|
1359
1347
|
ref: refObserver,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@folklore/ads",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.106",
|
|
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": "
|
|
53
|
+
"gitHead": "5dcc85d03e017aecc2d19a4fa174382ece4a3225",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@folklore/hooks": "^0.0.72",
|
|
56
56
|
"@folklore/tracking": "^0.0.29",
|