From 4a78d880b7f12426ead42fc352e5f2c2d0d04f9d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Fri, 26 Jul 2013 18:03:20 +0200 Subject: Fix issues #98 #99 : marquage lors du défilement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modification de la zone du viewport qui faisait toute la taille de l'écran. Désormais le viewport va du haut de l'écran jusqu'à sa moitié Modification de la zone de marquage en la réduisant : début au 3/4 de l'article et fin 50px plus loin (ou bas de l'article si dépasse) --- app/views/javascript/main.phtml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'app/views/javascript') diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml index 9226efe63..5eb4aaa99 100644 --- a/app/views/javascript/main.phtml +++ b/app/views/javascript/main.phtml @@ -144,15 +144,14 @@ function inMarkViewport(flux) { var top = flux.position().top; var height = flux.height(); var begin = top + 3 * height / 4; - var bot = top + height; + var bot = Math.min(begin + 75, top + height); var windowTop = $(window).scrollTop(); - var windowBot = windowTop + $(window).height(); + var windowBot = windowTop + $(window).height() / 2; return (windowBot >= begin && windowBot <= bot); } -var lastScroll = 0; function init_posts () { init_img (); conf->lazyload() == 'yes') { ?> @@ -197,17 +196,9 @@ function init_posts () { - var flux = $('.flux'); $(window).scroll(function() { - var windowTop = $(this).scrollTop(); - if(Math.abs(windowTop - lastScroll) <= 50) { - return; - } - lastScroll = windowTop; - - flux.each(function() { - if($(this).hasClass('not_read') && - $(this).children(".flux_content").is(':visible') && + $('.flux.not_read:visible').each(function() { + if($(this).children(".flux_content").is(':visible') && inMarkViewport($(this))) { mark_read($(this), true); } -- cgit v1.2.3