Skip to content

Commit

Permalink
Realvu Analytics Adapter: improve flagging of 'display:none' containe…
Browse files Browse the repository at this point in the history
…rs (#7182)

* Remove _ps in _f=conf request

* Replace "

* realvuAnalyticsAdapter_spec updated

* Update realvuAnalyticsAdapter.js

* Update realvuAnalyticsAdapter.js

Improve value returned by addUnitById()

* Update realvuAnalyticsAdapter.js

improve flagging of 'display:none' containers

* Update realvuAnalyticsAdapter.js

Co-authored-by: Igor Tchibirev <igor@realvu.com>
  • Loading branch information
tchibirev and Igor Tchibirev authored Jul 21, 2021
1 parent b39e27b commit 1381f34
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions modules/realvuAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,28 +306,46 @@ export let lib = {
if (!restored) {
a.target = z.questA(a.div);
let target = (a.target !== null) ? a.target : a.div;
a.box.w = Math.max(target.offsetWidth, a.w);
a.box.h = Math.max(target.offsetHeight, a.h);
let q = z.findPosG(target);
let pad = {};
pad.t = z.padd(target, 'Top');
pad.l = z.padd(target, 'Left');
pad.r = z.padd(target, 'Right');
pad.b = z.padd(target, 'Bottom');
let ax = q.x + pad.l;
let ay = q.y + pad.t;
a.box.x = ax;
a.box.y = ay;
if (a.box.w > a.w && a.box.w > 1) {
ax += (a.box.w - a.w - pad.l - pad.r) / 2;
}
if (a.box.h > a.h && a.box.h > 1) {
ay += (a.box.h - a.h - pad.t - pad.b) / 2;
}
if ((ax > 0 && ay > 0) && (a.x != ax || a.y != ay)) {
a.x = ax;
a.y = ay;
z.writePos(a);
if (window.getComputedStyle(target).display == 'none') {
let targSibl = target.previousElementSibling; // for 'none' containers on mobile define y as previous sibling y+h
if (targSibl) {
let q = z.findPosG(targSibl);
a.x = q.x;
a.y = q.y + targSibl.offsetHeight;
} else {
target = target.parentNode;
let q = z.findPosG(target);
a.x = q.x;
a.y = q.y;
}
a.box.x = a.x;
a.box.y = a.y;
a.box.w = a.w;
a.box.h = a.h;
} else {
a.box.w = Math.max(target.offsetWidth, a.w);
a.box.h = Math.max(target.offsetHeight, a.h);
let q = z.findPosG(target);
let pad = {};
pad.t = z.padd(target, 'Top');
pad.l = z.padd(target, 'Left');
pad.r = z.padd(target, 'Right');
pad.b = z.padd(target, 'Bottom');
let ax = q.x + pad.l;
let ay = q.y + pad.t;
a.box.x = ax;
a.box.y = ay;
if (a.box.w > a.w && a.box.w > 1) {
ax += (a.box.w - a.w - pad.l - pad.r) / 2;
}
if (a.box.h > a.h && a.box.h > 1) {
ay += (a.box.h - a.h - pad.t - pad.b) / 2;
}
if ((ax > 0 && ay > 0) && (a.x != ax || a.y != ay)) {
a.x = ax;
a.y = ay;
z.writePos(a);
}
}
}
let vtr = ((a.box.w * a.box.h) < 242500) ? 49 : 29; // treashfold more then 49% and more then 29% for "oversized"
Expand Down

0 comments on commit 1381f34

Please sign in to comment.