Browse Source

Amélioration du marquage au défilement

Ne marque plus que lorsqu'on s'est déplacé de plus de 50px (évite de
checker à chaque fois)
De plus, lorsque les articles sont repliés, le marquage ne marche plus
(évite donc de marquer des articles non lus)
Marien Fressinaud 12 years ago
parent
commit
9758d1d736
2 changed files with 11 additions and 1 deletions
  1. 10 1
      app/views/javascript/main.phtml
  2. 1 0
      public/theme/freshrss.css

+ 10 - 1
app/views/javascript/main.phtml

@@ -152,6 +152,7 @@ function inMarkViewport(flux) {
 	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') { ?>
@@ -196,8 +197,16 @@ function init_posts () {
 	<?php if ($mark['scroll'] == 'yes') { ?>
 	<?php if ($mark['scroll'] == 'yes') { ?>
 	var flux = $('.flux');
 	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() {
 		flux.each(function() {
-			if($(this).hasClass('not_read') && inMarkViewport($(this))) {
+			if($(this).hasClass('not_read') &&
+			   $(this).children(".flux_content").is(':visible') &&
+			   inMarkViewport($(this))) {
 				mark_read($(this), true);
 				mark_read($(this), true);
 			}
 			}
 		});
 		});

+ 1 - 0
public/theme/freshrss.css

@@ -337,6 +337,7 @@
 			}
 			}
 
 
 .content {
 .content {
+	min-height: 300px;
 	max-width: 550px;
 	max-width: 550px;
 	margin: 0 auto;
 	margin: 0 auto;
 	padding: 20px 10px;
 	padding: 20px 10px;