1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Simpler detection whether the user scrolled

This commit is contained in:
Tim Düsterhus 2012-01-28 16:37:27 +01:00
parent dfdfedc7fa
commit cca83a596f

View File

@ -25,7 +25,7 @@ TimWolla.WCF ?= {}
autocompleteValue: null autocompleteValue: null
# Autoscroll # Autoscroll
scrollHeightTopDiff: null oldScrollTop: null
# Events # Events
events: events:
@ -204,8 +204,8 @@ TimWolla.WCF ?= {}
top = Math.random() * 100 - 50 top = Math.random() * 100 - 50
fish = $('#fish') fish = $('#fish')
left *= -1 unless fish.width() < (fish.position().left + left) < ($(document).width() - fish.width())) 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())) 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
fish.text('<\u00B0))))><') if left < 0 fish.text('<\u00B0))))><') if left < 0
@ -233,8 +233,8 @@ TimWolla.WCF ?= {}
### ###
handleMessages: (messages) -> handleMessages: (messages) ->
# Disable scrolling automagically when user manually scrolled # Disable scrolling automagically when user manually scrolled
unless @scrollHeightTopDiff is null unless @oldScrollTop is null
if $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() isnt @scrollHeighTopDiff if $('.chatMessageContainer').scrollTop() isnt @oldScrollTop
if $('#chatAutoscroll').data('status') is 1 if $('#chatAutoscroll').data('status') is 1
$('#chatAutoscroll').click() $('#chatAutoscroll').click()
$('#chatAutoscroll').addClass('hot').fadeOut('slow').fadeIn('slow') $('#chatAutoscroll').addClass('hot').fadeOut('slow').fadeIn('slow')
@ -254,7 +254,7 @@ TimWolla.WCF ?= {}
# Autoscroll down # Autoscroll down
if $('#chatAutoscroll').data('status') is 1 if $('#chatAutoscroll').data('status') is 1
$('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height() $('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height()
@scrollHeightTopDiff = $('.chatMessageContainer ul').height() - $('.chatMessageContainer').scrollTop() @oldScrollTop = $('.chatMessageContainer').scrollTop()
### ###
# Builds the userlist. # Builds the userlist.
# #