Just another way to scroll the iframe - preparing v4 - advanced questions and solutions hints

Developing and fixes
User avatar
axew3
w3all User
w3all User
Posts: 1595
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Just another way to scroll the iframe - preparing v4 - advanced questions and solutions hints

Post by axew3 » Sun Mar 17, 2019 10:10 am

Preparing v4 code ...

Really SO Hard to explain the concept for me, but i will try, also searching for hints by cool guys.
This is another solution about how to workaround to the phpBB scroll, that should be correctly presented after the onlick action into any iframe link.
The phpBB smooth scroll solution works fine. But it scroll BEFORE the page load.

How to scroll, AFTER iframe loads?
The solution is simple for all events, except one that i've test:
when the link contain #anchor that make phpBB scroll down to the last post on topic (if order is descendant x example), then what i have not find the way to resolve easily, is that this event, make scroll to top the page anyway to top.
But the post on bottom should be presented instead.
I really have try out any possibility in mind to resolve with smooth scroll and get the right result, but i've fail until now.

So, the problem was (and still remain as it's origin) this:
how to scroll AFTER iframe loaded, to correct position?
At moment on this online example, the solution applied to the v3 iframe code and to get the AFTER re-position is this:

on overall_footer.html code:
where:

Code: Select all

if( /posting\.php\?mode=[reply|post|bump]/ig.exec(href) !== null || /mcp\.php\?/ig.exec(href) !== null ){
var w3allNOappend = true;
}
change into:

Code: Select all

if( /posting\.php\?mode=[reply|post|bump]/ig.exec(href) !== null || /mcp\.php\?/ig.exec(href) !== null ){
w3allappend = boardU;
}
now into your WP template page-forum(orWhateverYouNamedIt).php
immediately after this line:

Code: Select all

history.pushState({w3all_passed_url: w3all_passed_url}, \"Forum\", w3all_passed_url_push);
ADD this code:

Code: Select all

jQuery( '#w3all_phpbb_iframe' ).on( \"load\", function() {
jQuery('html, body').animate({
    scrollTop: jQuery('.site-content').offset().top
 }, 0);
});
NOTE that .site-content need to match the assigned class of the element that wrap the main WP page content.
That is. The page reposition AFTER iframe loads to correct position, the unique time that it isn't in this way as i experience at time of this post, is when you go to (for example) execute a sticky action (the popup display on top).
I will check how to work around this.

Note that here, is not possible for what i tested out, to smooth scroll:

Code: Select all

jQuery('html, body').animate({
    scrollTop: jQuery('.site-content').offset().top
 }, 300);
will not work. The page when on #anchor links will scroll to top by the way.
Any solution?

User avatar
axew3
w3all User
w3all User
Posts: 1595
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: Just another way to scroll the iframe - preparing v4 - advanced questions and solutions hints

Post by axew3 » Sun Mar 17, 2019 2:52 pm

resolved: all answer perfect after a further change, so the v4 code will be released soon as it is now working on this online example.
It scroll ever to right position, AFTER phpBB iframe reload positioning to requested post.
The solution works perfect on any test, and return correct results in any case, even with users preferences changed to display Ascendant or Descendant. Unfortunately it is not smooth, but may it is better because a smooth scroll could exists already into many WP themes.
So this is perfect as is to work on any scenario. See you soon with v4 code ... Cheers to all cool people!

Post Reply