Skip to content

Instantly share code, notes, and snippets.

@oschmid
Last active March 8, 2021 20:53
Show Gist options
  • Save oschmid/0a86ab875a9e11f6f4416435cc7abbbf to your computer and use it in GitHub Desktop.
Save oschmid/0a86ab875a9e11f6f4416435cc7abbbf to your computer and use it in GitHub Desktop.
Makes the left sidebar expand on mouse over. THIS CODE IS OUT OF DATE! For latest go to https://github.com/oschmid/roam-plugins
var leftExpander = document.querySelector('#left-expander');
if (leftExpander != null) {
leftExpander.parentNode.removeChild(leftExpander);
}
function getEventHandlers(element) {
for (var prop in element) {
if (prop.includes('reactEventHandlers')) {
return element[prop];
}
}
}
leftExpander = document.createElement('span');
leftExpander.id = 'left-expander';
leftExpander.style.height = '100%';
leftExpander.style.width = '1em';
leftExpander.style.position = 'absolute';
leftExpander.addEventListener('mouseenter', function(e) {
const leftMenu = document.querySelector('.bp3-icon-menu');
if (!leftMenu) { return; }
getEventHandlers(leftMenu).onMouseEnter();
});
document.querySelector('.roam-body-main').prepend(leftExpander);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment