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

Allow use of breakpoints instead of user-agent sniffing #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tdukart
Copy link

@tdukart tdukart commented Jul 24, 2019

Some publishers use only breakpoints to determine whether a device is mobile or desktop. This option allows those companies to more closely align device detection with their own policies.

This came up during testing of an unrelated issue. The Chrome developer tools device toolbar will modify the user-agent to appear like an Android device, even at widescreen values, preventing our right-rail ad from loading.

On this branch

Adds option to ArcAds initialization to specify a desktop breakpoint using the desktopBreakpoint property. If present, that overrides the user-agent-based device detection.

Verify

  • Confirm that cross browser testing has been completed.

  • Verify that no errors are present in the GPT console window.googletag.openConsole().

Comments

Sample initialization code:

const arcAds = new ArcAds({
  dfp: {
    id: dfpPublisherID,
    collapseEmptyDivs: true,
  },
  desktopBreakpoint: 960,
});

tdukart added 2 commits July 23, 2019 16:46
Some companies use only breakpoints to determine whether a device is mobile or desktop. This option allows those companies to more closely align device detection with their own policies.
/**
* @desc Determines if the user is using a Retina display.
**/
Retina() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you adding a retina option if you don't use it anywhere?

* @desc Determines if the user is using a mobile device.
**/
any() {
return (window.innerWidth < this.desktopBreakpoint);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a more descriptive function name. Also what happens if the window isn't available -- you should check for the window !== undefined.

@@ -12,7 +13,11 @@ export class ArcAds {
this.positions = [];
this.collapseEmptyDivs = options.dfp.collapseEmptyDivs;

window.isMobile = MobileDetection;
if (options.desktopBreakpoint) {
window.isMobile = new BreakpointDetection(options.desktopBreakpoint);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also have support for tablet/mobile breakpoints in order to be considered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants