Skip to content

Commit 8e5dc00

Browse files
authored
Examples: Fix sidebar scrolling to selected example (mrdoob#33023)
1 parent 023e967 commit 8e5dc00

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

examples/index.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ <h1><a href="https://threejs.org">three.js</a></h1>
103103
if ( validRedirects.has( file ) === true ) {
104104

105105
selectFile( file );
106-
links[ file ].scrollIntoView( { block: 'center' } );
106+
updateLinkScroll();
107107
viewer.src = validRedirects.get( file );
108108
viewer.style.display = 'unset';
109109

@@ -171,6 +171,7 @@ <h1><a href="https://threejs.org">three.js</a></h1>
171171

172172
event.preventDefault();
173173
panel.classList.toggle( 'open' );
174+
updateLinkScroll();
174175

175176
} );
176177

@@ -385,6 +386,17 @@ <h1><a href="https://threejs.org">three.js</a></h1>
385386

386387
}
387388

389+
function updateLinkScroll() {
390+
391+
if ( selected !== null ) {
392+
393+
const link = links[ selected ];
394+
content.scrollTop = link.offsetTop - content.offsetTop - ( content.clientHeight - link.offsetHeight ) / 2;
395+
396+
}
397+
398+
}
399+
388400
</script>
389401
<template id="PlaceholderHTML">
390402
<!DOCTYPE html>

0 commit comments

Comments
 (0)