From ce9b6c8dbddceeffe5be19869227bff99c60995a Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Mon, 6 Jan 2014 13:33:19 +0200 Subject: [PATCH] When clicking a region, scroll only the list and not the whole page Bug: 59175 Change-Id: I7b6b53ac01b99c6172830513f25ab51c6a83d919 --- lib/jquery.uls/src/jquery.uls.regionfilter.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/jquery.uls/src/jquery.uls.regionfilter.js b/lib/jquery.uls/src/jquery.uls.regionfilter.js index a97a11fb..305e9bb2 100644 --- a/lib/jquery.uls/src/jquery.uls.regionfilter.js +++ b/lib/jquery.uls/src/jquery.uls.regionfilter.js @@ -144,16 +144,20 @@ }, click: function () { + var $list, $firstTargetRegion; + // Don't do anything if a region is selected already if ( this.$element.hasClass( 'active' ) ) { return; } + $list = this.options.$target.$element; + $firstTargetRegion = $list.find( '#' + this.regions[0] ); + // Scroll to appropriate area - this.options.$target.$element - .find( '#' + this.regions[0] ) - .get( 0 ) - .scrollIntoView( true, { behavior: 'smooth' } ); + $list.scrollTop( + $firstTargetRegion.offset().top - $list.offset().top + $list.scrollTop() + ); // Make the selected region (and it only) active $( '.regionselector' ).removeClass( 'active' );