Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewability #14

Merged
merged 4 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function _createServerRequest(bidRequest, gdprConsent) {
const minSize = _getMinSize(sizes);

const contributeViewability = ViewabilityContributor(
_getPercentInView(element, window.top, minSize)
_getPercentInView(element, spec.getTopWindowSize(), minSize)
);

/*
Expand Down Expand Up @@ -168,15 +168,15 @@ function _getIntersectionOfRects(rects) {
return bbox;
}

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

// Obtain the intersection of the element and the viewport
const elementInViewBoundingBox = _getIntersectionOfRects([ {
left: 0,
top: 0,
right: topWin.innerWidth,
bottom: topWin.innerHeight
right: topWinSize.width,
bottom: topWinSize.height
}, elementBoundingBox ]);

let elementInViewArea, elementTotalArea;
Expand Down Expand Up @@ -213,6 +213,15 @@ function ViewabilityContributor(viewabilityAmount) {
return contributeViewability;
}

function getTopWindowSize() {
const topWin = utils.getWindowTop();

return {
width: topWin.innerWidth,
height: topWin.innerHeight,
}
}

function isBidRequestValid(bid) {
if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') {
return false;
Expand Down Expand Up @@ -261,14 +270,13 @@ function getUserSyncs(syncOptions, responses, gdprConsent) {
}
}

const spec = {
export const spec = {
code: BIDDER_CODE,
isBidRequestValid,
buildRequests,
interpretResponse,
getTopWindowSize,
getUserSyncs
};

registerBidder(spec);

module.exports = spec;
Loading