Update jquery.uls from upstream
Change-Id: Id91d0551ec329fb6645d3e6c3610ca5f3e8670b4
This commit is contained in:
committed by
Gerrit Code Review
parent
84355a422d
commit
b057531602
@@ -181,7 +181,7 @@
|
|||||||
$( '.uls-menu' ).hide();
|
$( '.uls-menu' ).hide();
|
||||||
|
|
||||||
this.$menu.show();
|
this.$menu.show();
|
||||||
this.$menu[0].scrollIntoView();
|
this.$menu.scrollIntoView();
|
||||||
this.shown = true;
|
this.shown = true;
|
||||||
|
|
||||||
if ( !this.isMobile() ) {
|
if ( !this.isMobile() ) {
|
||||||
@@ -423,5 +423,34 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Simple scrollIntoView plugin.
|
||||||
|
* Scrolls the element to the viewport smoothly if it is not already.
|
||||||
|
*/
|
||||||
|
$.fn.scrollIntoView = function () {
|
||||||
|
return this.each( function () {
|
||||||
|
var scrollPosition,
|
||||||
|
$window = $( window ),
|
||||||
|
windowHeight = $window.height(),
|
||||||
|
windowScrollTop = $window.scrollTop(),
|
||||||
|
windowBottom = windowScrollTop + windowHeight,
|
||||||
|
$element = $( this ),
|
||||||
|
panelHeight = $element.height(),
|
||||||
|
panelTop = $element.offset().top,
|
||||||
|
panelBottom = panelTop + panelHeight;
|
||||||
|
|
||||||
|
if ( ( panelTop < windowScrollTop ) || ( panelBottom > windowBottom ) ) {
|
||||||
|
if ( panelHeight > windowHeight ) {
|
||||||
|
scrollPosition = panelTop;
|
||||||
|
} else {
|
||||||
|
scrollPosition = panelBottom - windowHeight;
|
||||||
|
}
|
||||||
|
$( 'html, body' ).stop().animate( {
|
||||||
|
scrollTop: scrollPosition
|
||||||
|
}, 500 );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
$.fn.uls.Constructor = ULS;
|
$.fn.uls.Constructor = ULS;
|
||||||
} ( jQuery ) );
|
} ( jQuery ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user