Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/pidgin/themes/Template.html b/pidgin/themes/Template.html
- --- a/pidgin/themes/Template.html
- +++ b/pidgin/themes/Template.html
- @@ -156,6 +156,7 @@
- // Only call nearBottom() if should scroll is undefined.
- if(undefined === coalescedHTML.shouldScroll) {
- + console.log('appendMessage');
- shouldScroll = nearBottom();
- } else {
- shouldScroll = coalescedHTML.shouldScroll;
- @@ -172,6 +173,7 @@
- function appendNextMessage(html){
- var shouldScroll;
- if(undefined === coalescedHTML.shouldScroll) {
- + console.log('appendNextMessage');
- shouldScroll = nearBottom();
- } else {
- shouldScroll = coalescedHTML.shouldScroll;
- @@ -190,12 +192,14 @@
- // only replace messages if we're already coalescing
- if(coalescedHTML.isCoalescing){
- if(undefined === coalescedHTML.shouldScroll) {
- + console.log('replaceLastMessage 1');
- shouldScroll = nearBottom();
- } else {
- shouldScroll = coalescedHTML.shouldScroll;
- }
- coalescedHTML.replaceLast(html, shouldScroll);
- } else {
- + console.log('replaceLastMessage 2');
- shouldScroll = nearBottom();
- //Retrieve the current insertion point, then remove it
- //This requires that there have been an insertion point... is there a better way to retrieve the last element? -evands
- @@ -214,12 +218,89 @@
- }
- }
- + var SCROLLMODE_UNKNOWN = 0;
- + var SCROLLMODE_WEBKIT1 = 1;
- + var SCROLLMODE_WEBKIT2 = 2;
- + var scroll_mode = SCROLLMODE_UNKNOWN;
- +
- + function detectWebkitScrolling() {
- + if (scroll_mode != SCROLLMODE_UNKNOWN)
- + return scroll_mode;
- + if (document.body.scrollTop > 0)
- + scroll_mode = SCROLLMODE_WEBKIT1;
- + if (document.documentElement.scrollTop > 0)
- + scroll_mode = SCROLLMODE_WEBKIT2;
- + return scroll_mode;
- + }
- +
- + var stickyscroll_just_scrolled = false;
- + var stickyscroll_just_scrolled_more = false;
- + var stickyscroll_to_bottom = true;
- + var stickyscroll_to_bottom_new = true;
- +
- + function windowDidScroll(ev) {
- + if (stickyscroll_just_scrolled) {
- + stickyscroll_just_scrolled_more = true;
- + return;
- + }
- +
- + console.log('windowDidScroll()');
- +
- + stickyscroll_just_scrolled = true;
- + var update_to_bottom = function() {
- + console.log('update_to_bottom: ' + stickyscroll_to_bottom_new);
- + stickyscroll_to_bottom = stickyscroll_to_bottom_new;
- + stickyscroll_to_bottom_new = nearBottom2();
- +
- + if (stickyscroll_just_scrolled_more) {
- + stickyscroll_just_scrolled_more = false;
- + setTimeout(update_to_bottom, 10);
- + } else {
- + stickyscroll_just_scrolled = false;
- + }
- + };
- + setTimeout(update_to_bottom, 10);
- + }
- +
- + function nearBottom() {
- + return stickyscroll_to_bottom;
- + }
- +
- //Auto-scroll to bottom. Use nearBottom to determine if a scrollToBottom is desired.
- - function nearBottom() {
- - return ( document.body.scrollTop >= ( document.body.offsetHeight - ( window.innerHeight * 1.2 ) ) );
- + function nearBottom2() {
- + var mode = detectWebkitScrolling();
- + console.log('nearBottom: mode=' + mode);
- + if (mode == SCROLLMODE_UNKNOWN || mode == SCROLLMODE_WEBKIT1) {
- + x = ( document.body.scrollTop >=
- + ( document.body.offsetHeight - (window.innerHeight + 20) ) );
- + } else { /* SCROLLMODE_WEBKIT2 */
- + x = ( document.documentElement.scrollTop >=
- + ( document.documentElement.offsetHeight - (window.innerHeight + 20) ) );
- + }
- + console.log('is near bottom: ' + x);
- + return x;
- }
- function scrollToBottom() {
- - document.body.scrollTop = document.body.offsetHeight;
- + var mode = detectWebkitScrolling();
- + console.log('scrollToBottom: mode=' + mode);
- +
- + var scrollfunc;
- + if (mode == SCROLLMODE_UNKNOWN || mode == SCROLLMODE_WEBKIT1) {
- + scrollfunc = function() {
- + console.log('scroll!');
- + document.body.scrollTop = document.body.offsetHeight;
- + };
- + } else { /* SCROLLMODE_WEBKIT2 */
- + scrollfunc = function() {
- + document.documentElement.scrollTop =
- + document.documentElement.offsetHeight;
- + window.scrollTo(0, document.body.scrollHeight);
- + };
- + }
- +
- + scrollfunc();
- + /* wait for content to load and scroll again */
- + setTimeout(scrollfunc, 10);
- }
- //Dynamically exchange the active stylesheet
- @@ -242,11 +323,10 @@
- return;
- scrollToBottom();
- - /* wait for images to load and scroll again */
- - setTimeout(scrollToBottom, 10);
- }
- function remoteImageIsReady(id) {
- + console.log('remoteImageIsReady');
- var shouldScroll = nearBottom();
- var emoticons;
- @@ -272,13 +352,16 @@
- }
- window.onresize = function windowDidResize(){
- - alignChat(true/*nearBottom()*/); //nearBottom buggy with inactive tabs
- + console.log('window.onresize');
- + alignChat(nearBottom());
- }
- function initStyle() {
- alignChat(true);
- if(!coalescedHTML)
- coalescedHTML = new CoalescedHTML();
- +
- + window.addEventListener('scroll', windowDidScroll);
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement