{"action":"created","comment":{"url":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/comments/58417688","id":58417688,"diff_hunk":"@@ -4,91 +4,173 @@ import ReactDOM from 'react-dom';\n \n import BindMixin from '../Mixin/BindMixin';\n import DOMUtil from '../Util/DOMUtil';\n+import Portal from '../Portal/Portal';\n import Util from '../Util/Util';\n \n+const ARROW_SIZE = 7;\n+\n class Tooltip extends Util.mixin(BindMixin) {\n   get methodsToBind() {\n     return [\n+      'dismissTooltip',\n       'getIdealLocation',\n       'handleMouseEnter',\n-      'handleMouseLeave'\n+      'handleMouseLeave',\n+      'handleTooltipMouseEnter',\n+      'handleTooltipMouseLeave'\n     ];\n   }\n \n   constructor() {\n-    super();\n-\n+    super(...arguments);\n     this.state = {isOpen: false};\n   }\n \n-  getAnchor(anchor, position, renderedPosition, viewportWidth, viewportHeight) {\n-    // Change the anchor if the tooltip will be rendered off the screen.\n-    if (position === 'right' || position === 'left') {\n-      if (renderedPosition.top < 0) {\n-        anchor = 'start';\n-      } else if (renderedPosition.bottom > viewportHeight) {\n-        anchor = 'end';\n-      }\n-    } else if (position === 'top' || position === 'bottom') {\n-      if (renderedPosition.right > viewportWidth) {\n-        anchor = 'end';\n-      } else if (renderedPosition.left < 0) {\n-        anchor = 'start';\n-      }\n+  componentWillUnmount() {\n+    this.removeScrollListener();\n+  }\n+\n+  handleMouseEnter(currentAnchor, currentPosition) {\n+    let {anchor, position, coordinates} = this.getIdealLocation(currentAnchor,\n+      currentPosition);\n+    this.setState({anchor, isOpen: true, position, coordinates});\n+    this.addScrollListener();\n+  }\n+\n+  handleMouseLeave() {\n+    this.dismissTooltip();\n+  }\n+\n+  handleTooltipMouseEnter() {\n+    if (this.props.interactive) {\n+      this.setState({isOpen: true});","path":"src/Tooltip/Tooltip.js","position":60,"original_position":60,"commit_id":"8500daa236f7a786590400e5211c90f969e895dd","original_commit_id":"e341e7e00447c4e62f28749b5e0e5a33b88234b5","user":{"login":"jfurrow","id":1134755,"avatar_url":"https://avatars.githubusercontent.com/u/1134755?v=3","gravatar_id":"","url":"https://api.github.com/users/jfurrow","html_url":"https://github.com/jfurrow","followers_url":"https://api.github.com/users/jfurrow/followers","following_url":"https://api.github.com/users/jfurrow/following{/other_user}","gists_url":"https://api.github.com/users/jfurrow/gists{/gist_id}","starred_url":"https://api.github.com/users/jfurrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfurrow/subscriptions","organizations_url":"https://api.github.com/users/jfurrow/orgs","repos_url":"https://api.github.com/users/jfurrow/repos","events_url":"https://api.github.com/users/jfurrow/events{/privacy}","received_events_url":"https://api.github.com/users/jfurrow/received_events","type":"User","site_admin":false},"body":"Yeah it should be here also. Done!","created_at":"2016-04-04T17:52:33Z","updated_at":"2016-04-04T17:52:33Z","html_url":"https://github.com/mesosphere/reactjs-components/pull/237#discussion_r58417688","pull_request_url":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/237","_links":{"self":{"href":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/comments/58417688"},"html":{"href":"https://github.com/mesosphere/reactjs-components/pull/237#discussion_r58417688"},"pull_request":{"href":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/237"}}},"pull_request":{"url":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/237","id":64874547,"html_url":"https://github.com/mesosphere/reactjs-components/pull/237","diff_url":"https://github.com/mesosphere/reactjs-components/pull/237.diff","patch_url":"https://github.com/mesosphere/reactjs-components/pull/237.patch","issue_url":"https://api.github.com/repos/mesosphere/reactjs-components/issues/237","number":237,"state":"open","locked":false,"title":"Use Portal for Tooltip","user":{"login":"jfurrow","id":1134755,"avatar_url":"https://avatars.githubusercontent.com/u/1134755?v=3","gravatar_id":"","url":"https://api.github.com/users/jfurrow","html_url":"https://github.com/jfurrow","followers_url":"https://api.github.com/users/jfurrow/followers","following_url":"https://api.github.com/users/jfurrow/following{/other_user}","gists_url":"https://api.github.com/users/jfurrow/gists{/gist_id}","starred_url":"https://api.github.com/users/jfurrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfurrow/subscriptions","organizations_url":"https://api.github.com/users/jfurrow/orgs","repos_url":"https://api.github.com/users/jfurrow/repos","events_url":"https://api.github.com/users/jfurrow/events{/privacy}","received_events_url":"https://api.github.com/users/jfurrow/received_events","type":"User","site_admin":false},"body":"This uses the portal and will work everywhere (even inside a container with `overflow: scroll`). That introduced a fair amount of additional logic to determine the position of the tooltip trigger and the ideal location for the tooltip content.","created_at":"2016-03-31T23:19:23Z","updated_at":"2016-04-04T17:52:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2736a2932669b32cae69e14359e4964289d382c0","assignee":{"login":"daiyiwhale","id":1589186,"avatar_url":"https://avatars.githubusercontent.com/u/1589186?v=3","gravatar_id":"","url":"https://api.github.com/users/daiyiwhale","html_url":"https://github.com/daiyiwhale","followers_url":"https://api.github.com/users/daiyiwhale/followers","following_url":"https://api.github.com/users/daiyiwhale/following{/other_user}","gists_url":"https://api.github.com/users/daiyiwhale/gists{/gist_id}","starred_url":"https://api.github.com/users/daiyiwhale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daiyiwhale/subscriptions","organizations_url":"https://api.github.com/users/daiyiwhale/orgs","repos_url":"https://api.github.com/users/daiyiwhale/repos","events_url":"https://api.github.com/users/daiyiwhale/events{/privacy}","received_events_url":"https://api.github.com/users/daiyiwhale/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/237/commits","review_comments_url":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/237/comments","review_comment_url":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mesosphere/reactjs-components/issues/237/comments","statuses_url":"https://api.github.com/repos/mesosphere/reactjs-components/statuses/8500daa236f7a786590400e5211c90f969e895dd","head":{"label":"mesosphere:bug/fix-tooltip","ref":"bug/fix-tooltip","sha":"8500daa236f7a786590400e5211c90f969e895dd","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":37925854,"name":"reactjs-components","full_name":"mesosphere/reactjs-components","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/reactjs-components","description":":art: A library of reusable React components","fork":false,"url":"https://api.github.com/repos/mesosphere/reactjs-components","forks_url":"https://api.github.com/repos/mesosphere/reactjs-components/forks","keys_url":"https://api.github.com/repos/mesosphere/reactjs-components/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/reactjs-components/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/reactjs-components/teams","hooks_url":"https://api.github.com/repos/mesosphere/reactjs-components/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/reactjs-components/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/reactjs-components/events","assignees_url":"https://api.github.com/repos/mesosphere/reactjs-components/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/reactjs-components/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/reactjs-components/tags","blobs_url":"https://api.github.com/repos/mesosphere/reactjs-components/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/reactjs-components/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/reactjs-components/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/reactjs-components/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/reactjs-components/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/reactjs-components/languages","stargazers_url":"https://api.github.com/repos/mesosphere/reactjs-components/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/reactjs-components/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/reactjs-components/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/reactjs-components/subscription","commits_url":"https://api.github.com/repos/mesosphere/reactjs-components/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/reactjs-components/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/reactjs-components/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/reactjs-components/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/reactjs-components/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/reactjs-components/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/reactjs-components/merges","archive_url":"https://api.github.com/repos/mesosphere/reactjs-components/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/reactjs-components/downloads","issues_url":"https://api.github.com/repos/mesosphere/reactjs-components/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/reactjs-components/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/reactjs-components/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/reactjs-components/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/reactjs-components/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/reactjs-components/releases{/id}","deployments_url":"https://api.github.com/repos/mesosphere/reactjs-components/deployments","created_at":"2015-06-23T15:01:45Z","updated_at":"2016-04-02T09:22:45Z","pushed_at":"2016-04-04T17:46:31Z","git_url":"git://github.com/mesosphere/reactjs-components.git","ssh_url":"git@github.com:mesosphere/reactjs-components.git","clone_url":"https://github.com/mesosphere/reactjs-components.git","svn_url":"https://github.com/mesosphere/reactjs-components","homepage":"http://mesosphere.github.io/reactjs-components","size":1964,"stargazers_count":37,"watchers_count":37,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":7,"forks":2,"open_issues":7,"watchers":37,"default_branch":"master"}},"base":{"label":"mesosphere:master","ref":"master","sha":"5f77f125da62723be7cf76995db1a3ee87a65bd0","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":37925854,"name":"reactjs-components","full_name":"mesosphere/reactjs-components","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/reactjs-components","description":":art: A library of reusable React components","fork":false,"url":"https://api.github.com/repos/mesosphere/reactjs-components","forks_url":"https://api.github.com/repos/mesosphere/reactjs-components/forks","keys_url":"https://api.github.com/repos/mesosphere/reactjs-components/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/reactjs-components/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/reactjs-components/teams","hooks_url":"https://api.github.com/repos/mesosphere/reactjs-components/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/reactjs-components/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/reactjs-components/events","assignees_url":"https://api.github.com/repos/mesosphere/reactjs-components/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/reactjs-components/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/reactjs-components/tags","blobs_url":"https://api.github.com/repos/mesosphere/reactjs-components/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/reactjs-components/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/reactjs-components/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/reactjs-components/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/reactjs-components/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/reactjs-components/languages","stargazers_url":"https://api.github.com/repos/mesosphere/reactjs-components/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/reactjs-components/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/reactjs-components/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/reactjs-components/subscription","commits_url":"https://api.github.com/repos/mesosphere/reactjs-components/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/reactjs-components/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/reactjs-components/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/reactjs-components/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/reactjs-components/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/reactjs-components/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/reactjs-components/merges","archive_url":"https://api.github.com/repos/mesosphere/reactjs-components/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/reactjs-components/downloads","issues_url":"https://api.github.com/repos/mesosphere/reactjs-components/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/reactjs-components/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/reactjs-components/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/reactjs-components/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/reactjs-components/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/reactjs-components/releases{/id}","deployments_url":"https://api.github.com/repos/mesosphere/reactjs-components/deployments","created_at":"2015-06-23T15:01:45Z","updated_at":"2016-04-02T09:22:45Z","pushed_at":"2016-04-04T17:46:31Z","git_url":"git://github.com/mesosphere/reactjs-components.git","ssh_url":"git@github.com:mesosphere/reactjs-components.git","clone_url":"https://github.com/mesosphere/reactjs-components.git","svn_url":"https://github.com/mesosphere/reactjs-components","homepage":"http://mesosphere.github.io/reactjs-components","size":1964,"stargazers_count":37,"watchers_count":37,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":7,"forks":2,"open_issues":7,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/237"},"html":{"href":"https://github.com/mesosphere/reactjs-components/pull/237"},"issue":{"href":"https://api.github.com/repos/mesosphere/reactjs-components/issues/237"},"comments":{"href":"https://api.github.com/repos/mesosphere/reactjs-components/issues/237/comments"},"review_comments":{"href":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/237/comments"},"review_comment":{"href":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mesosphere/reactjs-components/pulls/237/commits"},"statuses":{"href":"https://api.github.com/repos/mesosphere/reactjs-components/statuses/8500daa236f7a786590400e5211c90f969e895dd"}}}}