Sfoglia il codice sorgente

Merge pull request #224 from Alkarex/manualLazyload

LazyLoad manuel pour les articles repliés
Alexandre Alapetite 12 anni fa
parent
commit
fb07117b78
2 ha cambiato i file con 9 aggiunte e 6 eliminazioni
  1. 1 1
      app/App_FrontController.php
  2. 8 5
      public/scripts/main.js

+ 1 - 1
app/App_FrontController.php

@@ -62,7 +62,7 @@ class App_FrontController extends FrontController {
 			View::appendScript ('https://login.persona.org/include.js');
 		}
 		View::appendScript (Url::display ('/scripts/jquery.min.js'));
-		if ($this->conf->lazyload () === 'yes') {
+		if ($this->conf->lazyload () === 'yes' && ($this->conf->displayPosts () === 'yes' || Request::param ('output') === 'reader')) {
 			View::appendScript (Url::display ('/scripts/jquery.lazyload.min.js'));
 		}
 	}

+ 8 - 5
public/scripts/main.js

@@ -24,6 +24,13 @@ function redirect (url, new_tab) {
 }
 
 function toggleContent (new_active, old_active) {
+	if (does_lazyload) {
+		new_active.find('img[data-original]').each(function() {
+			this.setAttribute('src', this.getAttribute('data-original'));
+			this.removeAttribute('data-original');
+		});
+	}
+
 	old_active.removeClass ("active");
 	if (old_active[0] != new_active[0]) {
 		new_active.addClass ("active");
@@ -62,10 +69,6 @@ function toggleContent (new_active, old_active) {
 		new_scroll = $(box_to_move).scrollTop (new_pos).scrollTop ();
 	}
 
-	if ((new_scroll === old_scroll) && $.fn.lazyload) {
-		$(window).trigger ("scroll");	//When no scroll was done, generate fake scroll event for LazyLoad to load images
-	}
-
 	if (auto_mark_article) {
 		mark_read(new_active, true);
 	}
@@ -226,7 +229,7 @@ function inMarkViewport(flux, box_to_follow, relative_follow) {
 
 function init_posts () {
 	init_img ();
-	if (does_lazyload) {
+	if ($.fn.lazyload) {
 		if (is_global_mode()) {
 			$(".flux .content img").lazyload({
 				container: $("#panel")