Skip to content

Commit 2bd9ce5

Browse files
committed
Display sidebar ad when scrolled
There is a JS bug around ad display when linked directly to an anchor somewhat down the page. By default, we display an ad in the sidebar if it would be visible without scrolling the sidebar (who does that?) and put it in the footer otherwise. The math was slightly off on whether the bottom of the sidebar would be visible if the window was already scrolled.
1 parent dbd72aa commit 2bd9ce5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

readthedocs/core/static-src/core/js/doc-embed/sponsorship.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function create_ad_placement() {
5656
// If this is off screen, instead create an ad in the footer
5757
element = $("<div />").appendTo(selector);
5858
offset = element.offset();
59-
if (!offset || offset.top > $(window).height()) {
59+
if (!offset || (offset.top - $(window).scrollTop()) > $(window).height()) {
6060
if (rtd.is_rtd_like_theme()) {
6161
selector = $('<div />').insertAfter('footer hr');
6262
class_name = 'ethical-rtd';

0 commit comments

Comments
 (0)