Ver Fonte

Fix issues #98 #99 : marquage lors du défilement

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)
Marien Fressinaud há 13 anos atrás
pai
commit
4a78d880b7
1 ficheiros alterados com 4 adições e 13 exclusões
  1. 4 13
      app/views/javascript/main.phtml

+ 4 - 13
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 ();
 	<?php if($this->conf->lazyload() == 'yes') { ?>
@@ -197,17 +196,9 @@ function init_posts () {
 	<?php } ?>
 
 	<?php if ($mark['scroll'] == 'yes') { ?>
-	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);
 			}