Просмотр исходного кода

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 13 лет назад
Родитель
Сommit
4a78d880b7
1 измененных файлов с 4 добавлено и 13 удалено
  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 top = flux.position().top;
 	var height = flux.height();
 	var height = flux.height();
 	var begin = top + 3 * height / 4;
 	var begin = top + 3 * height / 4;
-	var bot = top + height;
+	var bot = Math.min(begin + 75, top + height);
 
 
 	var windowTop = $(window).scrollTop();
 	var windowTop = $(window).scrollTop();
-	var windowBot = windowTop + $(window).height();
+	var windowBot = windowTop + $(window).height() / 2;
 
 
 	return (windowBot >= begin && windowBot <= bot);
 	return (windowBot >= begin && windowBot <= bot);
 }
 }
 
 
-var lastScroll = 0;
 function init_posts () {
 function init_posts () {
 	init_img ();
 	init_img ();
 	<?php if($this->conf->lazyload() == 'yes') { ?>
 	<?php if($this->conf->lazyload() == 'yes') { ?>
@@ -197,17 +196,9 @@ function init_posts () {
 	<?php } ?>
 	<?php } ?>
 
 
 	<?php if ($mark['scroll'] == 'yes') { ?>
 	<?php if ($mark['scroll'] == 'yes') { ?>
-	var flux = $('.flux');
 	$(window).scroll(function() {
 	$(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))) {
 			   inMarkViewport($(this))) {
 				mark_read($(this), true);
 				mark_read($(this), true);
 			}
 			}