The definitive scroll fix for iframe on 1.6.6

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

If you wish to attach one or more files enter the details below.

Maximum filesize per attachment: 1 MiB.

Expand view Topic review: The definitive scroll fix for iframe on 1.6.6

The definitive scroll fix for iframe on 1.6.6

by axew3 » Sat Mar 18, 2017 12:15 am

Also if there are few differences between custom code added to scroll iframe on 1.6.5, and the new one applied on my tests using/through native iframe js code (applied into phpBB overall_footer.html, and running here right now at axew3.com) there are better behaviors when scroll is done, so the new one (and i think definitive at moment) here below will be used.

To who interested on change on fly before 1.6.6 as definitive scroll fix, the changes to do are just these two steps:

1) Open your overall_footer.html file and substitute/replace the old added wp_w3all code with this new code:

Code: Select all

<script type="text/javascript">
// TO ACTIVATE phpBB lightbox events remove /* and */ here below
/* 
$(document).on('mouseup', '.postimage', function(){
 //var w3allappend = "getw3all_lightbox";
 if ('parentIFrame' in window) window.parentIFrame.scrollToOffset(0,0);
 //if ('parentIFrame' in window) window.parentIFrame.sendMessage(w3allappend);
});
*/

  $(document).on("click", "a", function() {
   var href = $(this).attr("href");
   var w3allappend = href;
   var w3all_onview_topic  = (href.indexOf('viewtopic.php') > -1);
   var w3all_onview_attach  = (href.indexOf('file.php') > -1);
   var w3all_onview_post = /#p[0-9]+/ig.exec(href);
   var w3all_ck_quickmod  = (href.indexOf('quickmod') > -1);
 if ( w3all_ck_quickmod == true || w3all_onview_topic == false && w3all_onview_attach == false && w3all_onview_post == null ) {

  if ('parentIFrame' in window) window.parentIFrame.scrollToOffset(0,0);
}
  if ('parentIFrame' in window) window.parentIFrame.sendMessage(w3allappend);
});
 
$(document).on('click', '.quick-login', function(){ 
var w3allappend = "phpbb_quick_login";
if ('parentIFrame' in window) window.parentIFrame.scrollToOffset(0,0);
if ('parentIFrame' in window) window.parentIFrame.sendMessage(w3allappend);
});
 
 $('form').on('submit', function() {
 var href = $(this).attr("action");
 var ckr = (href.indexOf('#preview') > -1);
 if(ckr == true){
 var w3allappend = href;
  if ('parentIFrame' in window) window.parentIFrame.scrollToOffset(0,0);
  if ('parentIFrame' in window) window.parentIFrame.sendMessage(w3allappend);
 }
});
</script>
<script type="text/javascript" src="iframeResizer.contentWindow.min.js" defer></script>
recompile phpBB template.

now open page-forum.php and search for this code:

Code: Select all

window.scrollTo(0, 200);
change it into

Code: Select all

//window.scrollTo(0, 200);
OR remove completely all this code (better)

Code: Select all

// avoid scroll, for certain actions

   var w3all_onview_topic  = (w3all_passed_url.indexOf('viewtopic.php') > -1);
   var w3all_onview_attach  = (w3all_passed_url.indexOf('file.php') > -1);
   var w3all_onview_post = /#p[0-9]+/ig.exec(w3all_passed_url);
   var w3all_ck_lightbox  = (w3all_passed_url.indexOf('getw3all_lightbox') > -1); // maybe it is not more necessary
   var w3all_ck_quickmod  = (w3all_passed_url.indexOf('quickmod') > -1);
  
   if ( w3all_ck_lightbox == true || w3all_ck_quickmod == true || w3all_onview_topic == false && w3all_onview_attach == false && w3all_onview_post == null ) {
    window.scrollTo(0, 200);
  }
save. Reload page on browser.

This change will return a better iframe scroll experience, in any test i've try out.
Now work fine.
Wp template page-forum.php (or whatever you had name it) will result more clean and easy to understand in this way.

Top