{"action":"created","comment":{"url":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/comments/45684094","id":45684094,"diff_hunk":"@@ -1103,41 +1115,66 @@ InfoBubble.prototype.panToView = function() {\n     // No Bubble yet so do nothing\n     return;\n   }\n-\n+  // get the edge margin from options (or default)\n+  var autopanMargin = this.get('autopanMargin');\n+  // height of the marker icon - pixels\n   var anchorHeight = this.getAnchorHeight_();\n-  var height = this.bubble_.offsetHeight + anchorHeight;\n+  // height of the infobubble bottom arrow - pixels\n+  var arrowHeight = this.getArrowSize_();\n+  // height of the infobubble - pixels\n+  var infobubbleHeight = this.bubble_.offsetHeight;\n+  // width of the infobubble - pixels\n+  var infobubbleWidth = this.bubble_.offsetWidth;\n+\n   var map = this.get('map');\n+  // the div containing the map\n   var mapDiv = map.getDiv();\n+  // height of the div containing the map - pixels\n   var mapHeight = mapDiv.offsetHeight;\n-\n-  var latLng = this.getPosition();\n-  var centerPos = projection.fromLatLngToContainerPixel(map.getCenter());\n-  var pos = projection.fromLatLngToContainerPixel(latLng);\n-\n-  // Find out how much space at the top is free\n-  var spaceTop = centerPos.y - height;\n-\n-  // Fine out how much space at the bottom is free\n-  var spaceBottom = mapHeight - centerPos.y;\n-\n-  var needsTop = spaceTop < 0;\n-  var deltaY = 0;\n-\n-  if (needsTop) {\n-    spaceTop *= -1;\n-    deltaY = (spaceTop + spaceBottom) / 2;\n-  }\n-\n-  pos.y -= deltaY;\n-  latLng = projection.fromContainerPixelToLatLng(pos);\n-\n-  if (map.getCenter() != latLng) {\n-    map.panTo(latLng);\n+  // height of the div containing the map - pixels\n+  var mapWidth = mapDiv.offsetWidth;\n+\n+  // coordinate of the marker - lat/lng\n+  var markerLatLng = this.getPosition();\n+  // the marker position - pixels\n+  var markerPosition = projection.fromLatLngToContainerPixel(markerLatLng);\n+\n+  // centre of the map - pixels\n+  var mapCenter = projection.fromLatLngToContainerPixel(map.getCenter());\n+  // calculate top free space or overrun (incl autopan margin) - pixels\n+  var spaceTop = markerPosition.y - infobubbleHeight - arrowHeight - anchorHeight - autopanMargin;","path":"src/infobubble.js","position":null,"original_position":90,"commit_id":"2d961e17aa0659bb8c40ec60bebe2d19a33b28d2","original_commit_id":"fc08a18adf918e5079daa99a642b78c6bfa49fb9","user":{"login":"gigmaps","id":5176547,"avatar_url":"https://avatars.githubusercontent.com/u/5176547?v=3","gravatar_id":"","url":"https://api.github.com/users/gigmaps","html_url":"https://github.com/gigmaps","followers_url":"https://api.github.com/users/gigmaps/followers","following_url":"https://api.github.com/users/gigmaps/following{/other_user}","gists_url":"https://api.github.com/users/gigmaps/gists{/gist_id}","starred_url":"https://api.github.com/users/gigmaps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gigmaps/subscriptions","organizations_url":"https://api.github.com/users/gigmaps/orgs","repos_url":"https://api.github.com/users/gigmaps/repos","events_url":"https://api.github.com/users/gigmaps/events{/privacy}","received_events_url":"https://api.github.com/users/gigmaps/received_events","type":"User","site_admin":false},"body":"updated","created_at":"2015-11-24T00:49:40Z","updated_at":"2015-11-24T00:49:40Z","html_url":"https://github.com/googlemaps/js-info-bubble/pull/14#discussion_r45684094","pull_request_url":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/comments/45684094"},"html":{"href":"https://github.com/googlemaps/js-info-bubble/pull/14#discussion_r45684094"},"pull_request":{"href":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/14","id":48948267,"html_url":"https://github.com/googlemaps/js-info-bubble/pull/14","diff_url":"https://github.com/googlemaps/js-info-bubble/pull/14.diff","patch_url":"https://github.com/googlemaps/js-info-bubble/pull/14.patch","issue_url":"https://api.github.com/repos/googlemaps/js-info-bubble/issues/14","number":14,"state":"open","locked":false,"title":"update the infobubble autopan functionality:","user":{"login":"gigmaps","id":5176547,"avatar_url":"https://avatars.githubusercontent.com/u/5176547?v=3","gravatar_id":"","url":"https://api.github.com/users/gigmaps","html_url":"https://github.com/gigmaps","followers_url":"https://api.github.com/users/gigmaps/followers","following_url":"https://api.github.com/users/gigmaps/following{/other_user}","gists_url":"https://api.github.com/users/gigmaps/gists{/gist_id}","starred_url":"https://api.github.com/users/gigmaps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gigmaps/subscriptions","organizations_url":"https://api.github.com/users/gigmaps/orgs","repos_url":"https://api.github.com/users/gigmaps/repos","events_url":"https://api.github.com/users/gigmaps/events{/privacy}","received_events_url":"https://api.github.com/users/gigmaps/received_events","type":"User","site_admin":false},"body":"this updates the autopan functionality to bring it inline with (ahead of ?)  the standard `google.maps.InfoWindow()` autopan:\r\n- so map is only panned enough for the `infobubble` window to be visible with an edge margin - as per \r\n- add an `autopanMargin` option to set the margin between the map edge and the infobubble window (with default = 10px)\r\n- better variable naming & comments in `panToView()` function\r\n\r\nremove comment about the use of `anchorPoint` being a hack - since `pixelBounds` has been deprecated","created_at":"2015-10-27T23:45:58Z","updated_at":"2015-11-24T00:49:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"27cf68cbd2fef4de060550889d4dc26d131541c4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/14/commits","review_comments_url":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/14/comments","review_comment_url":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/comments{/number}","comments_url":"https://api.github.com/repos/googlemaps/js-info-bubble/issues/14/comments","statuses_url":"https://api.github.com/repos/googlemaps/js-info-bubble/statuses/2d961e17aa0659bb8c40ec60bebe2d19a33b28d2","head":{"label":"gigmaps:autopan-update","ref":"autopan-update","sha":"2d961e17aa0659bb8c40ec60bebe2d19a33b28d2","user":{"login":"gigmaps","id":5176547,"avatar_url":"https://avatars.githubusercontent.com/u/5176547?v=3","gravatar_id":"","url":"https://api.github.com/users/gigmaps","html_url":"https://github.com/gigmaps","followers_url":"https://api.github.com/users/gigmaps/followers","following_url":"https://api.github.com/users/gigmaps/following{/other_user}","gists_url":"https://api.github.com/users/gigmaps/gists{/gist_id}","starred_url":"https://api.github.com/users/gigmaps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gigmaps/subscriptions","organizations_url":"https://api.github.com/users/gigmaps/orgs","repos_url":"https://api.github.com/users/gigmaps/repos","events_url":"https://api.github.com/users/gigmaps/events{/privacy}","received_events_url":"https://api.github.com/users/gigmaps/received_events","type":"User","site_admin":false},"repo":{"id":44987376,"name":"js-info-bubble","full_name":"gigmaps/js-info-bubble","owner":{"login":"gigmaps","id":5176547,"avatar_url":"https://avatars.githubusercontent.com/u/5176547?v=3","gravatar_id":"","url":"https://api.github.com/users/gigmaps","html_url":"https://github.com/gigmaps","followers_url":"https://api.github.com/users/gigmaps/followers","following_url":"https://api.github.com/users/gigmaps/following{/other_user}","gists_url":"https://api.github.com/users/gigmaps/gists{/gist_id}","starred_url":"https://api.github.com/users/gigmaps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gigmaps/subscriptions","organizations_url":"https://api.github.com/users/gigmaps/orgs","repos_url":"https://api.github.com/users/gigmaps/repos","events_url":"https://api.github.com/users/gigmaps/events{/privacy}","received_events_url":"https://api.github.com/users/gigmaps/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gigmaps/js-info-bubble","description":"A library for customizable CSS3 InfoWindows in the Google Maps JavaScript API v3","fork":true,"url":"https://api.github.com/repos/gigmaps/js-info-bubble","forks_url":"https://api.github.com/repos/gigmaps/js-info-bubble/forks","keys_url":"https://api.github.com/repos/gigmaps/js-info-bubble/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gigmaps/js-info-bubble/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gigmaps/js-info-bubble/teams","hooks_url":"https://api.github.com/repos/gigmaps/js-info-bubble/hooks","issue_events_url":"https://api.github.com/repos/gigmaps/js-info-bubble/issues/events{/number}","events_url":"https://api.github.com/repos/gigmaps/js-info-bubble/events","assignees_url":"https://api.github.com/repos/gigmaps/js-info-bubble/assignees{/user}","branches_url":"https://api.github.com/repos/gigmaps/js-info-bubble/branches{/branch}","tags_url":"https://api.github.com/repos/gigmaps/js-info-bubble/tags","blobs_url":"https://api.github.com/repos/gigmaps/js-info-bubble/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gigmaps/js-info-bubble/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gigmaps/js-info-bubble/git/refs{/sha}","trees_url":"https://api.github.com/repos/gigmaps/js-info-bubble/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gigmaps/js-info-bubble/statuses/{sha}","languages_url":"https://api.github.com/repos/gigmaps/js-info-bubble/languages","stargazers_url":"https://api.github.com/repos/gigmaps/js-info-bubble/stargazers","contributors_url":"https://api.github.com/repos/gigmaps/js-info-bubble/contributors","subscribers_url":"https://api.github.com/repos/gigmaps/js-info-bubble/subscribers","subscription_url":"https://api.github.com/repos/gigmaps/js-info-bubble/subscription","commits_url":"https://api.github.com/repos/gigmaps/js-info-bubble/commits{/sha}","git_commits_url":"https://api.github.com/repos/gigmaps/js-info-bubble/git/commits{/sha}","comments_url":"https://api.github.com/repos/gigmaps/js-info-bubble/comments{/number}","issue_comment_url":"https://api.github.com/repos/gigmaps/js-info-bubble/issues/comments{/number}","contents_url":"https://api.github.com/repos/gigmaps/js-info-bubble/contents/{+path}","compare_url":"https://api.github.com/repos/gigmaps/js-info-bubble/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gigmaps/js-info-bubble/merges","archive_url":"https://api.github.com/repos/gigmaps/js-info-bubble/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gigmaps/js-info-bubble/downloads","issues_url":"https://api.github.com/repos/gigmaps/js-info-bubble/issues{/number}","pulls_url":"https://api.github.com/repos/gigmaps/js-info-bubble/pulls{/number}","milestones_url":"https://api.github.com/repos/gigmaps/js-info-bubble/milestones{/number}","notifications_url":"https://api.github.com/repos/gigmaps/js-info-bubble/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gigmaps/js-info-bubble/labels{/name}","releases_url":"https://api.github.com/repos/gigmaps/js-info-bubble/releases{/id}","created_at":"2015-10-26T18:02:25Z","updated_at":"2015-10-26T18:02:26Z","pushed_at":"2015-11-24T00:48:34Z","git_url":"git://github.com/gigmaps/js-info-bubble.git","ssh_url":"git@github.com:gigmaps/js-info-bubble.git","clone_url":"https://github.com/gigmaps/js-info-bubble.git","svn_url":"https://github.com/gigmaps/js-info-bubble","homepage":"","size":224,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"autopan-update"}},"base":{"label":"googlemaps:gh-pages","ref":"gh-pages","sha":"d398f62f68cf5477eb8a617777cb8b16cb031def","user":{"login":"googlemaps","id":3717923,"avatar_url":"https://avatars.githubusercontent.com/u/3717923?v=3","gravatar_id":"","url":"https://api.github.com/users/googlemaps","html_url":"https://github.com/googlemaps","followers_url":"https://api.github.com/users/googlemaps/followers","following_url":"https://api.github.com/users/googlemaps/following{/other_user}","gists_url":"https://api.github.com/users/googlemaps/gists{/gist_id}","starred_url":"https://api.github.com/users/googlemaps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googlemaps/subscriptions","organizations_url":"https://api.github.com/users/googlemaps/orgs","repos_url":"https://api.github.com/users/googlemaps/repos","events_url":"https://api.github.com/users/googlemaps/events{/privacy}","received_events_url":"https://api.github.com/users/googlemaps/received_events","type":"Organization","site_admin":false},"repo":{"id":23977099,"name":"js-info-bubble","full_name":"googlemaps/js-info-bubble","owner":{"login":"googlemaps","id":3717923,"avatar_url":"https://avatars.githubusercontent.com/u/3717923?v=3","gravatar_id":"","url":"https://api.github.com/users/googlemaps","html_url":"https://github.com/googlemaps","followers_url":"https://api.github.com/users/googlemaps/followers","following_url":"https://api.github.com/users/googlemaps/following{/other_user}","gists_url":"https://api.github.com/users/googlemaps/gists{/gist_id}","starred_url":"https://api.github.com/users/googlemaps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googlemaps/subscriptions","organizations_url":"https://api.github.com/users/googlemaps/orgs","repos_url":"https://api.github.com/users/googlemaps/repos","events_url":"https://api.github.com/users/googlemaps/events{/privacy}","received_events_url":"https://api.github.com/users/googlemaps/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/googlemaps/js-info-bubble","description":"A library for customizable CSS3 InfoWindows in the Google Maps JavaScript API v3","fork":false,"url":"https://api.github.com/repos/googlemaps/js-info-bubble","forks_url":"https://api.github.com/repos/googlemaps/js-info-bubble/forks","keys_url":"https://api.github.com/repos/googlemaps/js-info-bubble/keys{/key_id}","collaborators_url":"https://api.github.com/repos/googlemaps/js-info-bubble/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/googlemaps/js-info-bubble/teams","hooks_url":"https://api.github.com/repos/googlemaps/js-info-bubble/hooks","issue_events_url":"https://api.github.com/repos/googlemaps/js-info-bubble/issues/events{/number}","events_url":"https://api.github.com/repos/googlemaps/js-info-bubble/events","assignees_url":"https://api.github.com/repos/googlemaps/js-info-bubble/assignees{/user}","branches_url":"https://api.github.com/repos/googlemaps/js-info-bubble/branches{/branch}","tags_url":"https://api.github.com/repos/googlemaps/js-info-bubble/tags","blobs_url":"https://api.github.com/repos/googlemaps/js-info-bubble/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/googlemaps/js-info-bubble/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/googlemaps/js-info-bubble/git/refs{/sha}","trees_url":"https://api.github.com/repos/googlemaps/js-info-bubble/git/trees{/sha}","statuses_url":"https://api.github.com/repos/googlemaps/js-info-bubble/statuses/{sha}","languages_url":"https://api.github.com/repos/googlemaps/js-info-bubble/languages","stargazers_url":"https://api.github.com/repos/googlemaps/js-info-bubble/stargazers","contributors_url":"https://api.github.com/repos/googlemaps/js-info-bubble/contributors","subscribers_url":"https://api.github.com/repos/googlemaps/js-info-bubble/subscribers","subscription_url":"https://api.github.com/repos/googlemaps/js-info-bubble/subscription","commits_url":"https://api.github.com/repos/googlemaps/js-info-bubble/commits{/sha}","git_commits_url":"https://api.github.com/repos/googlemaps/js-info-bubble/git/commits{/sha}","comments_url":"https://api.github.com/repos/googlemaps/js-info-bubble/comments{/number}","issue_comment_url":"https://api.github.com/repos/googlemaps/js-info-bubble/issues/comments{/number}","contents_url":"https://api.github.com/repos/googlemaps/js-info-bubble/contents/{+path}","compare_url":"https://api.github.com/repos/googlemaps/js-info-bubble/compare/{base}...{head}","merges_url":"https://api.github.com/repos/googlemaps/js-info-bubble/merges","archive_url":"https://api.github.com/repos/googlemaps/js-info-bubble/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/googlemaps/js-info-bubble/downloads","issues_url":"https://api.github.com/repos/googlemaps/js-info-bubble/issues{/number}","pulls_url":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls{/number}","milestones_url":"https://api.github.com/repos/googlemaps/js-info-bubble/milestones{/number}","notifications_url":"https://api.github.com/repos/googlemaps/js-info-bubble/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/googlemaps/js-info-bubble/labels{/name}","releases_url":"https://api.github.com/repos/googlemaps/js-info-bubble/releases{/id}","created_at":"2014-09-12T21:11:37Z","updated_at":"2015-11-22T21:53:17Z","pushed_at":"2015-11-24T00:48:34Z","git_url":"git://github.com/googlemaps/js-info-bubble.git","ssh_url":"git@github.com:googlemaps/js-info-bubble.git","clone_url":"https://github.com/googlemaps/js-info-bubble.git","svn_url":"https://github.com/googlemaps/js-info-bubble","homepage":"","size":301,"stargazers_count":68,"watchers_count":68,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":29,"mirror_url":null,"open_issues_count":11,"forks":29,"open_issues":11,"watchers":68,"default_branch":"gh-pages"}},"_links":{"self":{"href":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/14"},"html":{"href":"https://github.com/googlemaps/js-info-bubble/pull/14"},"issue":{"href":"https://api.github.com/repos/googlemaps/js-info-bubble/issues/14"},"comments":{"href":"https://api.github.com/repos/googlemaps/js-info-bubble/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/googlemaps/js-info-bubble/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/googlemaps/js-info-bubble/statuses/2d961e17aa0659bb8c40ec60bebe2d19a33b28d2"}}}}