Measure toggle button size instead of hardcoding it

This commit is contained in:
Matthew Dapena-Tretter
2017-03-23 11:04:52 -07:00
parent e01bc40a78
commit 37a3c9b59c

View File

@@ -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)