# A tela salta no mobile com o adplugin quando são exibidos anúncios de post \>2 nth

**URL:** https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926
**Category:** Support
**Tags:** advertising
**Created:** [Março 6, 2019, 11:34pm UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926 "2019-03-06T23:34:40Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [Março 6, 2019, 11:34pm UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926/1 "2019-03-06T23:34:40Z")

</div>

I’m having an issue that I can reliably reproduce on the latest iOS on an iPhone 6 and an iPhone XR. I’ve narrowed it down to the adplugin by testing in [safe mode](https://meta.discourse.org/t/53504?silent=true). It does not reproduce on a desktop emulator, like Safari\> User agent \> iPhone.

v2.3.0.beta3 +20

When two or more `dfp nth post code` ads are displayed the screen will jump around:

[https://global.discourse-cdn.com/meta/original/3X/a/2/a20c654a30c5d2cc11d3d2aee789202dd14c79ae.MP4](https://global.discourse-cdn.com/meta/original/3X/a/2/a20c654a30c5d2cc11d3d2aee789202dd14c79ae.MP4)

In the case above, `dfp nth post code` is set to 7.

Scrolling to the very bottom will make the screen jump and the **Suggested Topics** heading will be centered on the screen moving the **Want to read more…** text down after approximately 1 second.

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [Março 7, 2019, 12:34am UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926/2 "2019-03-07T00:34:21Z")

</div>

It looks like the content moves up. Is it because the ad unit is being collapsed? For example, the ad unit started out as 300x250 (your “dfp mobile post bottom ad size” setting), but was resized to something smaller (DFP loaded smaller creative)?

It’s hard to get anything out of that video since it doesn’t show the ad unit.

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [Março 7, 2019, 12:46am UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926/3 "2019-03-07T00:46:29Z")

</div>

The ads are not collapsed, and it reproduces even when all of them are ads that were sold directly - at 600x500 (@2x) and displayed at 300x250 - known sizes.

I realize it’s hard to figure out what’s happening from the screen recording because you can’t exactly see what is me scrolling and what is the jump.

Here is an example that shows what happens when an ad is in view, and how the screen jumps when the ad is scrolled out of view:

[https://global.discourse-cdn.com/meta/original/3X/0/0/00f3850edc7aa9505323f082334955782bfe9f6a.mov](https://global.discourse-cdn.com/meta/original/3X/0/0/00f3850edc7aa9505323f082334955782bfe9f6a.mov)

---

<div class="post-metadata">

### Author: ![eesty](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@eesty](https://meta.discourse.org/u/eesty)
#### Post date: [Março 10, 2019, 11:26am UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926/8 "2019-03-10T11:26:11Z")

</div>

I’ve this exact experience and I’ve not been able to get to the bottom of it, even after lots of testing and changing of settings.

I’ve tried setting the ad unit size both within Adsense (eg. 300x250) and within the plugin (300x250) and then even using CSS to force the block to be the correct hight, but it still occurs.

---

<div class="post-metadata">

### Author: ![eesty](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@eesty](https://meta.discourse.org/u/eesty)
#### Post date: [Março 28, 2019, 9:39pm UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926/9 "2019-03-28T21:39:24Z")

</div>

Sorry to bump, but I’ve still had no luck with this.  
It’s at the point where I’m getting quite critical feedback from users.

☹

Has anyone else had any luck?

---

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [Março 28, 2019, 9:46pm UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926/10 "2019-03-28T21:46:02Z")

</div>

I haven’t, so as a temporary measure I’ve removed the `dfp mobile post bottom code`.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [Março 28, 2019, 10:03pm UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926/11 "2019-03-28T22:03:52Z")

</div>

This is something @neil and @j.jaffeux looked at in detail today but deemed unfixable without major engineering time.

---

<div class="post-metadata">

### Author: ![eesty](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@eesty](https://meta.discourse.org/u/eesty)
#### Post date: [Março 30, 2019, 8:17am UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926/12 "2019-03-30T08:17:17Z")

</div>

I did some more testing of my own.

I created a blank 300px high DIV and appended it to every 6th post. It made no difference if it was post:before or post:after

```
api.decorateWidget('post:after', helper => {
  let post = helper.getModel();
  if (post.get('post_number') % 6 === 0) { 
      return helper.rawHtml('<div class="my_mobile_below_nth_post">300px div</div>');       
  };
});

```

Even with a blank div, the jumpiness still occurred on mobiles.  
Now i’m not in any way an expert, but my suspicion is that the when the server tries to server a new batch of posts it calculates post heights before rendering.

It seems that only once the posts are delivered that the api.decorateWidget script kicks in, adding another 300px to the height of the content that was appended to the post stream. The browser then tries to compensate for this overall extra height, jumping the “view” forward an additional 300px.

Some other interesting notes:

- the issue does not seem to happen in the Chrome iPhone simulator.
- increasing the Nth number to something above around 15 seems to give the browser time to compensate for the new div height of the batch of posts that are loaded. In some threads that I tested, significantly reducing the jumpiness.

It would seem the only real solution would be for a dedicated post container to be added instead of relying on post.decorateWidget. This, as @codinghorror alludes to, is probably what requires major engineering time.

I’ve analysed traffic to my site and about 55% is from mobile phones; not being able to serve ads to them is obviously having a significant effect on revenue and therefore the viability of the community. My 15+ post workaround helps and I’m going to try to server GPT ads that refresh themselves.

Thankyou @neil and @j.jaffeux for looking into it, it’s appreciated.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [Março 30, 2019, 10:26am UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926/13 "2019-03-30T10:26:27Z")

</div>

We would like to fix this, thank you for the detailed research!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [Julho 11, 2019, 7:48am UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926/14 "2019-07-11T07:48:00Z")

</div>

Isso foi corrigido, @eviltrout descobriu a causa. Obrigado a todos pela ajuda, foi uma tarefa difícil.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [Julho 11, 2019, 7:48am UTC](https://meta.discourse.org/t/screen-jumps-around-on-mobile-with-adplugin-when-2-nth-post-ads-are-shown/110926/15 "2019-07-11T07:48:02Z")

</div>


