mirror of
https://github.com/atom/atom.git
synced 2026-02-17 10:01:25 -05:00
Programmatically detect when mouse approaches the edge of a dock
Previously, we would assign dock elements a minimum width/height of 2 pixels so that we could detect when the mouse approached the edge of a hidden dock in order to show the chevron buttons. This, however, was causing confusion for users, who expected that extra space to be clickable in order to scroll editors located in the center dock. With this commit we will instead register a global `mousemove` event on the window right when attaching the workspace element to the DOM (the event handler is debounced, so this shouldn't have any performance consequence). Then, when mouse moves, we will programmatically detect when it is approaching to the edge of a dock and show the chevron button accordingly. This allows us to remove the `min-width` property from the dock container element, which eliminates the confusing behavior described above.
This commit is contained in:
@@ -327,12 +327,15 @@ module.exports = class Dock {
|
||||
// Include all panels that are closer to the edge than the dock in our calculations.
|
||||
switch (this.location) {
|
||||
case 'right':
|
||||
if (!this.isVisible()) bounds.left = bounds.right - 2
|
||||
bounds.right = Number.POSITIVE_INFINITY
|
||||
break
|
||||
case 'bottom':
|
||||
if (!this.isVisible()) bounds.top = bounds.bottom - 1
|
||||
bounds.bottom = Number.POSITIVE_INFINITY
|
||||
break
|
||||
case 'left':
|
||||
if (!this.isVisible()) bounds.right = bounds.left + 2
|
||||
bounds.left = Number.NEGATIVE_INFINITY
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user