Skip to content

Commit

Permalink
hotfix - after this I will fix all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rares-mihai-preda committed Aug 12, 2024
1 parent f7884f2 commit 6da493d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 266 deletions.
30 changes: 18 additions & 12 deletions modules/connatixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const DEFAULT_CURRENCY = 'USD';
* Get the bid floor value from the bid object, either using the getFloor function or by accessing the 'params.bidfloor' property.
* If the bid floor cannot be determined, return 0 as a fallback value.
*/
function getBidFloor(bid) {
export function getBidFloor(bid) {
if (!isFn(bid.getFloor)) {
return deepAccess(bid, 'params.bidfloor', 0);
}
Expand All @@ -47,7 +47,7 @@ function getBidFloor(bid) {
}
}

function validateBanner(mediaTypes) {
export function validateBanner(mediaTypes) {
if (!mediaTypes[BANNER]) {
return true;
}
Expand All @@ -56,7 +56,7 @@ function validateBanner(mediaTypes) {
return (Boolean(banner.sizes) && isArray(mediaTypes[BANNER].sizes) && mediaTypes[BANNER].sizes.length > 0);
}

function validateVideo(mediaTypes) {
export function validateVideo(mediaTypes) {
const video = mediaTypes[VIDEO];
if (!video) {
return true;
Expand All @@ -65,29 +65,35 @@ function validateVideo(mediaTypes) {
return video.context !== ADPOD;
}

function _getMinSize(bidParamSizes) {
return bidParamSizes.reduce((min, size) => size.h * size.w < min.h * min.w ? size : min)
export function _getMinSize(sizes) {
if (!sizes || sizes.length === 0) return undefined;
return sizes.reduce((minSize, currentSize) => {
const minArea = minSize.w * minSize.h;
const currentArea = currentSize.w * currentSize.h;
return currentArea < minArea ? currentSize : minSize;
});
}

function _isViewabilityMeasurable(element) {
return !_isIframe() && element !== null;
export function _isViewabilityMeasurable(element) {
if (!element) return false;
return !_isIframe(element);
}

function _isIframe() {
export function _isIframe() {
try {
return getWindowSelf() !== getWindowTop();
} catch (e) {
return true;
}
}

function _getViewability(element, topWin, { w, h } = {}) {
export function _getViewability(element, topWin, { w, h } = {}) {
return topWin.document.visibilityState === 'visible'
? _getPercentInView(element, topWin, { w, h })
: 0;
}

function _getPercentInView(element, topWin, { w, h } = {}) {
export function _getPercentInView(element, topWin, { w, h } = {}) {
const elementBoundingBox = _getBoundingBox(element, { w, h });

const elementInViewBoundingBox = _getIntersectionOfRects([ {
Expand All @@ -109,7 +115,7 @@ function _getPercentInView(element, topWin, { w, h } = {}) {
return 0;
}

function _getBoundingBox(element, { w, h } = {}) {
export function _getBoundingBox(element, { w, h } = {}) {
let { width, height, left, top, right, bottom } = element.getBoundingClientRect();

if ((width === 0 || height === 0) && w && h) {
Expand All @@ -122,7 +128,7 @@ function _getBoundingBox(element, { w, h } = {}) {
return { width, height, left, top, right, bottom };
}

function _getIntersectionOfRects(rects) {
export function _getIntersectionOfRects(rects) {
const bbox = {
left: rects[0].left,
right: rects[0].right,
Expand Down
Loading

0 comments on commit 6da493d

Please sign in to comment.