From 5c6c24d314bfec341ec658f8bf51bfeb9acb0cd0 Mon Sep 17 00:00:00 2001 From: MatmaRex Date: Fri, 14 Jun 2013 01:47:03 +0200 Subject: [PATCH] RegionSelector: Scroll to appropriate area instead of rebuilding the list This has been suggested on bug 39925. --- src/jquery.uls.regionfilter.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/jquery.uls.regionfilter.js b/src/jquery.uls.regionfilter.js index abc633d..33087b4 100644 --- a/src/jquery.uls.regionfilter.js +++ b/src/jquery.uls.regionfilter.js @@ -35,7 +35,7 @@ this.options = $.extend( {}, $.fn.regionselector.defaults, options ); this.$element.addClass( 'regionselector' ); this.regions = []; - this.cache= null; + this.cache = null; this.regionGroup = this.$element.data( 'regiongroup' ); this.init(); this.listen(); @@ -149,9 +149,12 @@ return; } - // Re-populate the list of languages - this.options.$target.empty(); - this.show(); + // Scroll to appropriate area + this.options.$target.$element + .find( '#' + this.regions[0] ) + .get( 0 ) + .scrollIntoView( true, { behavior: 'smooth' } ); + // Make the selected region (and it only) active $( '.regionselector' ).removeClass( 'active' );