mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Measure toggle button size instead of hardcoding it
This commit is contained in:
15
src/dock.js
15
src/dock.js
@@ -290,16 +290,16 @@ module.exports = class Dock {
|
||||
// The area used when detecting "leave" events is actually larger than when detecting entrances.
|
||||
if (includeButtonWidth) {
|
||||
const hoverMargin = 20
|
||||
const toggleButtonSize = 50 / 2 // This needs to match the value in the CSS.
|
||||
const {width, height} = this.toggleButton.getSize()
|
||||
switch (this.location) {
|
||||
case 'right':
|
||||
bounds.left -= toggleButtonSize + hoverMargin
|
||||
bounds.left -= width + hoverMargin
|
||||
break
|
||||
case 'bottom':
|
||||
bounds.top -= toggleButtonSize + hoverMargin
|
||||
bounds.top -= height + hoverMargin
|
||||
break
|
||||
case 'left':
|
||||
bounds.right += toggleButtonSize + hoverMargin
|
||||
bounds.right += width + hoverMargin
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -481,6 +481,13 @@ class DockToggleButton {
|
||||
return this.element
|
||||
}
|
||||
|
||||
getSize () {
|
||||
if (this.size == null) {
|
||||
this.size = this.element.getBoundingClientRect()
|
||||
}
|
||||
return this.size
|
||||
}
|
||||
|
||||
destroy () {
|
||||
this.innerElement.removeEventListener('click', this.handleClick)
|
||||
this.innerElement.removeEventListener('dragenter', this.handleDragEnter)
|
||||
|
||||
Reference in New Issue
Block a user