Advertisement
tomkiewicz

scrollmode

Apr 24th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.91 KB | None | 0 0
  1. diff --git a/pidgin/themes/Template.html b/pidgin/themes/Template.html
  2. --- a/pidgin/themes/Template.html
  3. +++ b/pidgin/themes/Template.html
  4. @@ -214,12 +214,41 @@
  5.             }
  6.         }
  7.  
  8. +       var SCROLLMODE_UNKNOWN = 0;
  9. +       var SCROLLMODE_WEBKIT1 = 1;
  10. +       var SCROLLMODE_WEBKIT2 = 2;
  11. +       var scroll_mode = SCROLLMODE_UNKNOWN;
  12. +
  13. +       function detectWebkitScrolling() {
  14. +           if (scroll_mode != SCROLLMODE_UNKNOWN)
  15. +               return scroll_mode;
  16. +           if (document.body.scrollTop > 0)
  17. +               return scroll_mode = SCROLLMODE_WEBKIT1;
  18. +           if (document.documentElement.scrollTop > 0)
  19. +               return scroll_mode = SCROLLMODE_WEBKIT2;
  20. +           return SCROLLMODE_UNKNOWN;
  21. +       }
  22. +
  23.         //Auto-scroll to bottom.  Use nearBottom to determine if a scrollToBottom is desired.
  24.         function nearBottom() {
  25. -           return ( document.body.scrollTop >= ( document.body.offsetHeight - ( window.innerHeight * 1.2 ) ) );
  26. +           var mode = detectWebkitScrolling();
  27. +           if (mode == SCROLLMODE_UNKNOWN || mode == SCROLLMODE_WEBKIT1) {
  28. +               return ( document.body.scrollTop >=
  29. +                   ( document.body.offsetHeight - (window.innerHeight * 1.2) ) );
  30. +           } else { /* SCROLLMODE_WEBKIT2 */
  31. +               return ( document.documentElement.scrollTop >=
  32. +                   ( document.documentElement.offsetHeight - (window.innerHeight * 1.2) ) );
  33. +           }
  34.         }
  35.         function scrollToBottom() {
  36. -           document.body.scrollTop = document.body.offsetHeight;
  37. +           var mode = detectWebkitScrolling();
  38. +           if (mode == SCROLLMODE_UNKNOWN || mode == SCROLLMODE_WEBKIT1) {
  39. +               document.body.scrollTop = document.body.offsetHeight;
  40. +           } else { /* SCROLLMODE_WEBKIT2 */
  41. +               document.documentElement.scrollTop =
  42. +                   document.documentElement.offsetHeight;
  43. +               window.scrollTo(0, document.body.scrollHeight);
  44. +           }
  45.         }
  46.  
  47.         //Dynamically exchange the active stylesheet
  48. @@ -272,7 +301,7 @@
  49.         }
  50.  
  51.         window.onresize = function windowDidResize(){
  52. -           alignChat(true/*nearBottom()*/); //nearBottom buggy with inactive tabs
  53. +           alignChat(nearBottom());
  54.         }
  55.  
  56.         function initStyle() {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement