Show/hide the sidebar on hover

Closes #657.
pull/647/merge
Thibaut Courouble 8 years ago
parent ab875eec39
commit 6587b7d878

@ -27,16 +27,31 @@ class app.views.Sidebar extends app.View
@docList = new app.views.DocList
app.on 'ready', @onReady
$.on document.documentElement, 'mouseleave', (event) => @display() if event.clientX < 10
$.on document.documentElement, 'mouseenter', => @resetDisplay(forceNoHover: false)
return
display: ->
@addClass 'show'
return
resetDisplay: ->
resetDisplay: (options = {}) ->
return unless @hasClass 'show'
@removeClass 'show'
unless options.forceNoHover is false or @hasClass 'no-hover'
@addClass 'no-hover'
$.on window, 'mousemove', @resetHoverOnMouseMove
return
resetHoverOnMouseMove: =>
$.off window, 'mousemove', @resetHoverOnMouseMove
$.requestAnimationFrame @resetHover
resetHover: =>
@removeClass 'no-hover'
showView: (view) ->
unless @view is view
@hover?.hide()

@ -37,8 +37,17 @@
}
}
._sidebar-hidden & { display: none; }
&.show { display: block; }
._sidebar-hidden & {
transform: translateX(-95%);
transform: translateX(calc(.5rem - 100%));
opacity: 0;
}
&:hover:not(.no-hover),
&.show {
transform: none;
opacity: 1;
}
}
._resizer {

Loading…
Cancel
Save