From cfdfd0908b7c2de6bad303808f97de447fa39123 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 29 Nov 2013 05:13:25 +0000 Subject: [PATCH] Themes: Use _.throttle() instead of a custom one. Props matveb. Fixes #25981 git-svn-id: https://develop.svn.wordpress.org/trunk@26467 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/theme.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/wp-admin/js/theme.js b/src/wp-admin/js/theme.js index 040015c5a1..80dcee5e22 100644 --- a/src/wp-admin/js/theme.js +++ b/src/wp-admin/js/theme.js @@ -29,21 +29,12 @@ themes.view.Appearance = wp.Backbone.View.extend({ // Sets up a throttler for binding to 'scroll' initialize: function() { - var self = this; + // Scroller checks how far the scroll position is + _.bindAll( this, 'scroller' ); - // Keep a boolean check so that we don't run - // too much code on every event trigger - this.window.bind( 'scroll.themes', function() { - this.throttle = true; - }); - - setInterval( function() { - if ( this.throttle ) { - // Once the case is the case, the action occurs and the fact is no more - this.throttle = false; - self.scroller(); - } - }, 300 ); + // Bind to the scroll event and throttle + // the results from this.scroller + this.window.bind( 'scroll', _.throttle( this.scroller, 300 ) ); }, // Main render control