-
Notifications
You must be signed in to change notification settings - Fork 42
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
base: master
Are you sure you want to change the base?
Conversation
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() { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
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: