Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Scroll improvements

* Load the next region when scroll reached half of the current
  region
* Fix the scroll sync with region highlight in both up and down
  scrolls
* Address Bug 39923 - Make scroll to next region more fluent
  • Loading branch information...
commit 9d988dbafe816f3d9eb1e055133f1dfcc583053d 1 parent e63aaf9
@santhoshtr santhoshtr authored
Showing with 24 additions and 10 deletions.
  1. +18 −3 src/jquery.uls.lcd.js
  2. +6 −7 src/jquery.uls.regionfilter.js
View
21 src/jquery.uls.lcd.js
@@ -241,7 +241,7 @@
this.$noResults.find( 'h2' ).after( $suggestions );
},
- listen: function() {
+ listen: function () {
var that = this;
if ( this.options.clickhandler ) {
this.$element.on( 'click', 'div.row li', function() {
@@ -251,11 +251,26 @@
// The region section need to be in sync with the map filter.
that.$element.scroll( function () {
- if ( this.offsetHeight + this.scrollTop >= this.scrollHeight ) {
+ var scrollTop = $( this ).position().top;
+ var scrollBottom = $( this ).height();
+ if ( this.offsetHeight + this.scrollTop >= this.scrollHeight/2 ) {
that.$element.trigger( 'scrollend' );
}
-
+ // The region section need to be in sync with the map filter.
+ var inviewRegion = 'WW';
+ that.$element.find( 'div.uls-lcd-region-section' ).each( function () {
+ var top = $( this ).position().top;
+ var height = $( this ).height();
+ if ( top < scrollTop && height > scrollBottom ) {
+ inviewRegion = $( this ).attr( 'id' );
+ return true;
+ }
+ } );
+ var inview = $.uls.data.regiongroups[inviewRegion];
+ $( '.regionselector' ).removeClass( 'active' );
+ $( '#uls-region-' + inview ).addClass( 'active' );
} );
+
}
};
View
13 src/jquery.uls.regionfilter.js
@@ -65,13 +65,6 @@
},
show: function() {
- // Make the selected region (and it only) active
- $( '.regionselector' ).removeClass( 'active' );
- if ( this.regionGroup ) {
- // if there is a region group, make it active.
- this.$element.addClass( 'active' );
- }
-
if ( this.cache ) {
// If the result cache is present, render the results from there.
var result = null;
@@ -141,6 +134,12 @@
// Re-populate the list of languages
this.options.$target.empty();
this.show();
+ // Make the selected region (and it only) active
+ $( '.regionselector' ).removeClass( 'active' );
+ if ( this.regionGroup ) {
+ // if there is a region group, make it active.
+ this.$element.addClass( 'active' );
+ }
}
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.