Valerii Vasin (valerii) wrote in changelog,
Valerii Vasin
valerii
changelog

[livejournal] r23229: LJSUP-14127: Optimize $.fn.ljLikes() plu...

Committer: vvasin
LJSUP-14127: Optimize $.fn.ljLikes() plugin to perform parsing only likes that are currently on the page at once. Add threshold for the scroll event.
U   trunk/htdocs/js/jquery_fn.js
Modified: trunk/htdocs/js/jquery_fn.js
===================================================================
--- trunk/htdocs/js/jquery_fn.js	2012-10-31 13:03:24 UTC (rev 23228)
+++ trunk/htdocs/js/jquery_fn.js	2012-10-31 13:31:47 UTC (rev 23229)
@@ -470,8 +470,7 @@
 		var html = node.html();
 
 		html = $.trim( html.replace(/<!--([\s\S]*?)-->/mig, '$1') );
-		node.html(html);
-		LiveJournal.parseLikeButtons( node );
+		LiveJournal.parseLikeButtons( node.html(html) );
 
 		return node;
 	}
@@ -506,8 +505,12 @@
 		_likes = _likes.not(screenableLikes);
 	}
 
-	// handle scroll event
-	$(window).on('scroll', lazyLoad);
+	// after document ready, cuz LiveJournal namespace is not defined yet
+	$(function () {
+		// handle scroll event, for mobile devices we don't threshold lazyLoad
+		// because it fires only at the end of scrolling (iOS)
+		$(window).on('scroll', LJ.Support.touch ? lazyLoad : LJ.threshold(lazyLoad, 1000));
+	});
 
 	$.fn.ljLikes = function (opts) {
 		var likes = null;

Tags: invis89, js, livejournal, vvasin
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments