From 784d1dc9bf805826689b85456f190562ba85be76 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Mon, 7 Apr 2014 22:14:01 +0000 Subject: [PATCH] Only show the media library loading spinner if we're scrolled toward the bottom. Prevents the spinner from flashing a second time when first loading the library due to a second query firing after initial load. props kovshenin. fixes #24859. git-svn-id: https://develop.svn.wordpress.org/trunk@28019 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-views.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 97dd232e7f..0964b96b09 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -4888,17 +4888,19 @@ scroll: function() { var view = this, - toolbar; + toolbar = this.views.parent.toolbar; - // @todo: is this still necessary? - if ( ! this.$el.is(':visible') ) { + // @todo: is :visible still necessary? + if ( ! this.$el.is(':visible') || ! this.collection.hasMore() ) { return; } - if ( this.collection.hasMore() && this.el.scrollHeight < this.el.scrollTop + ( this.el.clientHeight * this.options.refreshThreshold ) ) { - toolbar = this.views.parent.toolbar; + // Show the spinner only if we are close to the bottom. + if ( this.el.scrollHeight - ( this.el.scrollTop + this.el.clientHeight ) < this.el.clientHeight / 3 ) { toolbar.get('spinner').show(); + } + if ( this.el.scrollHeight < this.el.scrollTop + ( this.el.clientHeight * this.options.refreshThreshold ) ) { this.collection.more().done(function() { view.scroll(); toolbar.get('spinner').hide();