When clicking a region, scroll only the list and not the whole page

Bug: 59175
Change-Id: I7b6b53ac01b99c6172830513f25ab51c6a83d919
This commit is contained in:
Amir E. Aharoni
2014-01-06 13:33:19 +02:00
committed by Amire80
parent 44a2f4b01c
commit ce9b6c8dbd

View File

@@ -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' );