summaryrefslogtreecommitdiff
path: root/htroot/js
diff options
context:
space:
mode:
authorluccioman <luccioman@users.noreply.github.com>2017-09-14 09:36:55 +0200
committerluccioman <luccioman@users.noreply.github.com>2017-09-14 09:36:55 +0200
commit4e3c928d3159394e24594d2bba24bcc06c4d840f (patch)
treea00a53958d430a57bbda50139b39e04258fa7349 /htroot/js
parentfb6743e8f8a61bb3d5bbd8e0ae9f4f62b0e0ca92 (diff)
Do not animate unnecessarily when changing page on JS sorted results.
Diffstat (limited to 'htroot/js')
-rw-r--r--htroot/js/yacysort.js39
1 files changed, 29 insertions, 10 deletions
diff --git a/htroot/js/yacysort.js b/htroot/js/yacysort.js
index 325e9c08b..0d9948470 100644
--- a/htroot/js/yacysort.js
+++ b/htroot/js/yacysort.js
@@ -29,29 +29,48 @@ var logEnabled = false;
/* Indicates if the results feeders are running on the server */
var feedRunning = true;
-var displayPage = function() {
+/**
+ * Refresh the results page, checking each result CSS class depending on its position and ranking.
+ * @param isPageChange when true this refresh is done in response to a page change
+ */
+var displayPage = function(isPageChange) {
var offset = 1;
var totalcount = 0;
var itemscount = 0;
// For every search item that has already been displayed and sorted ...
$("#resultscontainer").find(".searchresults").each(function(i) {
+ var item = $(this);
+ var isFresh = item.hasClass("fresh");
+ if(isPageChange && isFresh) {
+ /* When changing page, remove the 'fresh' mark from all results,
+ * so that the related insertion/removal animations are not performed */
+ item.removeClass("fresh");
+ }
totalcount++;
- var earlierPage = parseFloat($(this).data("ranking")) > highestRanking;
+ var earlierPage = parseFloat(item.data("ranking")) > highestRanking;
// Apply the "earlierpage" class IFF the item is from an earlier page.
- $(this).toggleClass("earlierpage", earlierPage);
+ item.toggleClass("earlierpage", earlierPage);
if (earlierPage) {
- $(this).removeClass("currentpage");
+ item.removeClass("currentpage");
+ if(!isFresh) {
+ /* Use the "hidden" CSS class when this item has not been recently inserted to hide it without unnecessary animation */
+ item.addClass("hidden");
+ }
offset++;
itemscount++;
} else {
var laterPage = ((i - offset + 1) >= requestedResults);
- $(this).toggleClass("laterpage", laterPage);
+ item.toggleClass("laterpage", laterPage);
// If we now have too many results, hide the lowest-ranking ones.
if (laterPage) {
- $(this).removeClass("currentpage");
+ item.removeClass("currentpage");
+ if(!isFresh) {
+ /* Use the "hidden" CSS class when this item has not been recently inserted to hide it without unnecessary animation */
+ item.addClass("hidden");
+ }
} else {
- $(this).removeClass("hidden");
- $(this).addClass("currentpage");
+ item.removeClass("hidden");
+ item.addClass("currentpage");
itemscount++;
}
}
@@ -102,7 +121,7 @@ var numberedPage = function(pageNumber) {
}
// Update the display to show the new page.
- displayPage();
+ displayPage(true);
};
var processSidebarNavProtocols = function(navProtocolsOld, navProtocolsNew) {
@@ -292,7 +311,7 @@ var processLatestInfo = function(latestInfo) {
var processItem = function(data) {
var newItem = $(data);
- newItem.addClass("hidden");
+ newItem.addClass("hidden fresh");
/* If we didn't get a valid response from YaCy, wait a bit and check if the results feeders are still running on the server side */
if( ! newItem.data("ranking") ) {