diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-03-17 08:09:24 +1100 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-03-17 08:09:24 +1100 |
| commit | a2ac54e01ee8a9176ba5054d453fc5f2a3662908 (patch) | |
| tree | 6a4a419cb6490f6c341585745a745913f2903794 /js/post-hover.js | |
| parent | ce25db62ea6064069414d0f5b2bb53132a51c328 (diff) | |
Check if post is below viewable region.
Diffstat (limited to 'js/post-hover.js')
| -rw-r--r-- | js/post-hover.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/js/post-hover.js b/js/post-hover.js index e8b0c9b0..808570c5 100644 --- a/js/post-hover.js +++ b/js/post-hover.js @@ -21,9 +21,15 @@ $(document).ready(function(){ } var post = false; + var hovering = false; $(this).hover(function(e) { + hovering = true; + var start_hover = function(link) { - if(post.is(':visible') && $(window).scrollTop() <= post.offset().top + post.height()) { + if(post.is(':visible') && + post.offset().top + post.height() >= $(window).scrollTop() && + post.offset().top <= $(window).scrollTop() + $(window).height() + ) { // post is in view post.attr('style', 'border-style: none dashed dashed none; background: ' + post.css('border-right-color')); } else { @@ -44,6 +50,7 @@ $(document).ready(function(){ }; post = $('div.post#reply_' + id); + console.log(post); if(post.length > 0) { start_hover(this); } else { @@ -63,13 +70,16 @@ $(document).ready(function(){ .find('div.post#reply_' + id); if(typeof window.enable_fa == 'function' && localStorage['forcedanon']) enable_fa(); - start_hover(link); + if(hovering) + start_hover(link); } }); } }, function() { + hovering = false; if(!post) return; + post.attr('style', ''); if(post.hasClass('hidden')) post.css('display', 'none'); |
