Merge pull request #123 from amire80/bug-59175

When clicking a region, scroll only the list and not the whole page
This commit is contained in:
Kartik Mistry
2014-01-06 04:01:50 -08:00

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