From cca83a596fb19810d681c64712ad49e26aa7e7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 28 Jan 2012 16:37:27 +0100 Subject: [PATCH] Simpler detection whether the user scrolled --- file/js/TimWolla.WCF.Chat.coffee | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index 0ef01dc..08ae58f 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -25,7 +25,7 @@ TimWolla.WCF ?= {} autocompleteValue: null # Autoscroll - scrollHeightTopDiff: null + oldScrollTop: null # Events events: @@ -204,8 +204,8 @@ TimWolla.WCF ?= {} top = Math.random() * 100 - 50 fish = $('#fish') - left *= -1 unless fish.width() < (fish.position().left + left) < ($(document).width() - fish.width())) - top *= -1 unless fish.height() < (fish.position().top + top) < ($(document).height() - fish.height())) + left *= -1 unless fish.width() < (fish.position().left + left) < ($(document).width() - fish.width()) + top *= -1 unless fish.height() < (fish.position().top + top) < ($(document).height() - fish.height()) fish.text('><((((\u00B0>') if left > 0 fish.text('<\u00B0))))><') if left < 0 @@ -233,8 +233,8 @@ TimWolla.WCF ?= {} ### handleMessages: (messages) -> # Disable scrolling automagically when user manually scrolled - unless @scrollHeightTopDiff is null - if $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() isnt @scrollHeighTopDiff + unless @oldScrollTop is null + if $('.chatMessageContainer').scrollTop() isnt @oldScrollTop if $('#chatAutoscroll').data('status') is 1 $('#chatAutoscroll').click() $('#chatAutoscroll').addClass('hot').fadeOut('slow').fadeIn('slow') @@ -254,7 +254,7 @@ TimWolla.WCF ?= {} # Autoscroll down if $('#chatAutoscroll').data('status') is 1 $('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height() - @scrollHeightTopDiff = $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() + @oldScrollTop = $('.chatMessageContainer').scrollTop() ### # Builds the userlist. #