mirror of
https://github.com/danpros/htmly.git
synced 2026-04-19 12:06:22 +05:30
Fix twentyfifteen sidebar
Using theia-sticky-sidebar script instead of the original script.
This commit is contained in:
parent
c93d66fb13
commit
6149e42f46
3 changed files with 5 additions and 59 deletions
|
|
@ -75,62 +75,7 @@
|
|||
}
|
||||
} );
|
||||
} )();
|
||||
|
||||
/**
|
||||
* Add or remove ARIA attributes.
|
||||
*
|
||||
* Uses jQuery's width() function to determine the size of the window and add
|
||||
* the default ARIA attributes for the menu toggle if it's visible.
|
||||
*
|
||||
* @since Twenty Fifteen 1.1
|
||||
*/
|
||||
function onResizeARIA() {
|
||||
if ( 955 > $window.width() ) {
|
||||
button.attr( 'aria-expanded', 'false' );
|
||||
secondary.attr( 'aria-expanded', 'false' );
|
||||
button.attr( 'aria-controls', 'secondary' );
|
||||
} else {
|
||||
button.removeAttr( 'aria-expanded' );
|
||||
secondary.removeAttr( 'aria-expanded' );
|
||||
button.removeAttr( 'aria-controls' );
|
||||
}
|
||||
}
|
||||
|
||||
// Sidebar scrolling.
|
||||
function resizeAndScroll() {
|
||||
var windowPos = $window.scrollTop(),
|
||||
windowHeight = $window.height(),
|
||||
sidebarHeight = $sidebar.height(),
|
||||
pageHeight = $( '#page' ).height();
|
||||
|
||||
if ( 955 < $window.width() && pageHeight > sidebarHeight && ( windowPos + windowHeight ) >= sidebarHeight ) {
|
||||
$sidebar.css({
|
||||
position: 'fixed',
|
||||
bottom: sidebarHeight > windowHeight ? 0 : 'auto'
|
||||
});
|
||||
} else {
|
||||
$sidebar.css('position', 'relative');
|
||||
}
|
||||
}
|
||||
|
||||
$( function() {
|
||||
$body = $( document.body );
|
||||
$window = $( window );
|
||||
$sidebar = $( '#sidebar' ).first();
|
||||
|
||||
$window
|
||||
.on( 'scroll.twentyfifteen', resizeAndScroll )
|
||||
.on( 'load.twentyfifteen', onResizeARIA )
|
||||
.on( 'resize.twentyfifteen', function() {
|
||||
clearTimeout( resizeTimer );
|
||||
resizeTimer = setTimeout( resizeAndScroll, 500 );
|
||||
onResizeARIA();
|
||||
} );
|
||||
$sidebar.on( 'click.twentyfifteen keydown.twentyfifteen', 'button', resizeAndScroll );
|
||||
|
||||
for ( var i = 0; i < 6; i++ ) {
|
||||
setTimeout( resizeAndScroll, 100 * i );
|
||||
}
|
||||
} );
|
||||
|
||||
$('#sidebar, #content').theiaStickySidebar();
|
||||
|
||||
} )( jQuery );
|
||||
|
|
|
|||
1
themes/twentyfifteen/js/theia-sticky-sidebar.min.js
vendored
Normal file
1
themes/twentyfifteen/js/theia-sticky-sidebar.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue