From 50bb4edd1c0d0b4e77d25ce163979316b435ce86 Mon Sep 17 00:00:00 2001 From: wmwragg Date: Sun, 4 Sep 2016 08:54:15 +0100 Subject: [PATCH] Small refactor, to make it clearer whats happening --- src/components/views/rooms/RoomTooltip.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/views/rooms/RoomTooltip.js b/src/components/views/rooms/RoomTooltip.js index 4cd87a62..1c1baa66 100644 --- a/src/components/views/rooms/RoomTooltip.js +++ b/src/components/views/rooms/RoomTooltip.js @@ -60,19 +60,21 @@ module.exports = React.createClass({ _renderTooltip: function() { var label = this.props.room ? this.props.room.name : this.props.label; - var style = {}; - if (this.props.top) { style.top = this.props.top; } - if (this.props.left) { style.left = this.props.left; } // Add the parent's position to the tooltips, so it's correctly // positioned, also taking into account any window zoom // NOTE: The additional 6 pixels for the left position, is to take account of the // tooltips chevron var parent = ReactDOM.findDOMNode(this).parentElement; - style.top = (+style.top || 0) + parent.getBoundingClientRect().top + window.pageYOffset; - style.left = (+style.left || 0) + 6 + parent.getBoundingClientRect().right + window.pageXOffset; + var style = {}; + style.top = parent.getBoundingClientRect().top + window.pageYOffset; + style.left = 6 + parent.getBoundingClientRect().right + window.pageXOffset; style.display = "block"; + // Add any additional positional tweaks passed in to the tooltip + if (this.props.top) { style.top += this.props.top; } + if (this.props.left) { style.left += this.props.left; } + var tooltip = (