{"action":"created","comment":{"url":"https://api.github.com/repos/theonion/bulbs-elements/pulls/comments/66821142","id":66821142,"diff_hunk":"@@ -0,0 +1,174 @@\n+import invariant from 'invariant';\n+import { BulbsHTMLElement, registerElement } from 'bulbs-elements/register';\n+import { moveChildren } from 'bulbs-elements/util';\n+\n+import './bulbs-carousel.scss';\n+\n+export const supportsCalcInTransform = (() => {\n+  let div = document.createElement('div');\n+  div.style.transform = 'translateX(calc(100% - 10px))';\n+  return div.style.transform !== '';\n+})();\n+\n+export default class BulbsCarousel extends BulbsHTMLElement {\n+  createdCallback () {\n+    invariant(\n+      this.slider = this.querySelector('bulbs-carousel-slider'),\n+      '<bulbs-carousel> MUST contain a <bulbs-carousel-slider> element.'\n+    );\n+\n+    this.currentIndex = 0;\n+\n+    this.handleClick = this.handleClick.bind(this);\n+    this.addEventListener('click', this.handleClick);\n+\n+    this.track = document.createElement('bulbs-carousel-track');\n+\n+    moveChildren(this.slider, this.track);\n+\n+    this.slider.appendChild(this.track);\n+\n+    this.previousButtons = this.getElementsByTagName('bulbs-carousel-previous');\n+    this.nextButtons = this.getElementsByTagName('bulbs-carousel-next');\n+  }\n+\n+  attachedCallback () {\n+    this.pageToCarouselItem(this.getActiveCarouselItem());\n+    this.applyState();\n+  }\n+\n+  handleClick (event) {\n+    if (event.target.closest('bulbs-carousel-previous')) {\n+      this.slideToPrevious();\n+      this.applyState();\n+    }\n+\n+    if (event.target.closest('bulbs-carousel-next')) {\n+      this.slideToNext();\n+      this.applyState();\n+    }\n+  }\n+\n+  applyState () {\n+    let currentPage = this.getCurrentPage();\n+    let onFirstPage = this.isOnfirstPage();\n+    let onLastPage = this.isOnLastPage();\n+    let translate = -100 * currentPage;\n+    let itemMargin = this.getItemMargin();\n+    let marginCorrection = itemMargin * currentPage;\n+\n+    // some IE browsers do not support css calc() in the transform property.\n+    // For those browsers one uses multiple translateX() declarations.\n+    //      Be sad.\n+    if (supportsCalcInTransform) {\n+      this.track.style.transform = `translateX(calc(${translate}% - ${marginCorrection}px))`;\n+    }\n+    else {\n+      this.track.style.transform = `translateX(${translate}%) translateX(-${marginCorrection}px)`;\n+    }\n+\n+    function toggleAttribute (collection, attribute, toggle) {\n+      Array.prototype.forEach.call(collection, (item) => {\n+        toggle ? item.setAttribute(attribute, '') : item.removeAttribute(attribute);\n+      });\n+    }\n+\n+    toggleAttribute(this.previousButtons, 'disabled', onFirstPage);\n+    toggleAttribute(this.nextButtons, 'disabled', onLastPage);\n+  }\n+\n+  get carouselItems () {\n+    return this.track.children;\n+  }\n+\n+  get firstItem () {\n+    return this.carouselItems[0];\n+  }\n+\n+  getActiveCarouselItem () {","path":"elements/bulbs-carousel/bulbs-carousel.js","position":88,"original_position":88,"commit_id":"74d8975c76f3dc174267636478a1fc3f20ac581d","original_commit_id":"bace757aa7d832ab4822fbaa87a8598a451ca2b1","user":{"login":"collin","id":7783,"avatar_url":"https://avatars.githubusercontent.com/u/7783?v=3","gravatar_id":"","url":"https://api.github.com/users/collin","html_url":"https://github.com/collin","followers_url":"https://api.github.com/users/collin/followers","following_url":"https://api.github.com/users/collin/following{/other_user}","gists_url":"https://api.github.com/users/collin/gists{/gist_id}","starred_url":"https://api.github.com/users/collin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/collin/subscriptions","organizations_url":"https://api.github.com/users/collin/orgs","repos_url":"https://api.github.com/users/collin/repos","events_url":"https://api.github.com/users/collin/events{/privacy}","received_events_url":"https://api.github.com/users/collin/received_events","type":"User","site_admin":false},"body":"I  waffled around on these ones.\r\n\r\nI'm a fan of getters. I felt that `get caruselItems` and `get firstItem` were obvious cases for getters because they are merely accessing properties. The methods I've prefixed as `getThing` I wasn't so sure about. They are doing potentially more heavy lifting/DOM access.\r\n\r\nI'm on the fence, could be pushed either way.","created_at":"2016-06-13T16:14:44Z","updated_at":"2016-06-13T16:14:44Z","html_url":"https://github.com/theonion/bulbs-elements/pull/87#discussion_r66821142","pull_request_url":"https://api.github.com/repos/theonion/bulbs-elements/pulls/87","_links":{"self":{"href":"https://api.github.com/repos/theonion/bulbs-elements/pulls/comments/66821142"},"html":{"href":"https://github.com/theonion/bulbs-elements/pull/87#discussion_r66821142"},"pull_request":{"href":"https://api.github.com/repos/theonion/bulbs-elements/pulls/87"}}},"pull_request":{"url":"https://api.github.com/repos/theonion/bulbs-elements/pulls/87","id":73115898,"html_url":"https://github.com/theonion/bulbs-elements/pull/87","diff_url":"https://github.com/theonion/bulbs-elements/pull/87.diff","patch_url":"https://github.com/theonion/bulbs-elements/pull/87.patch","issue_url":"https://api.github.com/repos/theonion/bulbs-elements/issues/87","number":87,"state":"open","locked":false,"title":"[WIP] video carousel refactor","user":{"login":"collin","id":7783,"avatar_url":"https://avatars.githubusercontent.com/u/7783?v=3","gravatar_id":"","url":"https://api.github.com/users/collin","html_url":"https://github.com/collin","followers_url":"https://api.github.com/users/collin/followers","following_url":"https://api.github.com/users/collin/following{/other_user}","gists_url":"https://api.github.com/users/collin/gists{/gist_id}","starred_url":"https://api.github.com/users/collin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/collin/subscriptions","organizations_url":"https://api.github.com/users/collin/orgs","repos_url":"https://api.github.com/users/collin/repos","events_url":"https://api.github.com/users/collin/events{/privacy}","received_events_url":"https://api.github.com/users/collin/received_events","type":"User","site_admin":false},"body":"@kand @daytonn Here's a pass at extracting the carousel stuff into it's own namespace and having a top-level video-carousel wrapper. Works like this:\r\n\r\n```html\r\n<bulbs-video-carousel>                                       \r\n  <bulbs-video></bulbs-video>                                \r\n                                                             \r\n  <bulbs-carousel>\r\n    <bulbs-carousel-previous></bulbs-carousel-previous>                           \r\n    <bulbs-carousel-next></bulbs-carousel-next>                           \r\n    <bulbs-carousel-slider>                                  \r\n      <bulbs-carousel-item id='first'></bulbs-carousel-item> \r\n      <bulbs-carousel-item id='second'></bulbs-carousel-item>\r\n    </bulbs-carousel-slider>                                 \r\n  </bulbs-carousel>                                          \r\n</bulbs-video-carousel>                                      \r\n```","created_at":"2016-06-08T20:37:20Z","updated_at":"2016-06-13T16:14:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8deb7b22530389e4db1a6094cbb50c85d67f5aad","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/theonion/bulbs-elements/pulls/87/commits","review_comments_url":"https://api.github.com/repos/theonion/bulbs-elements/pulls/87/comments","review_comment_url":"https://api.github.com/repos/theonion/bulbs-elements/pulls/comments{/number}","comments_url":"https://api.github.com/repos/theonion/bulbs-elements/issues/87/comments","statuses_url":"https://api.github.com/repos/theonion/bulbs-elements/statuses/74d8975c76f3dc174267636478a1fc3f20ac581d","head":{"label":"theonion:video-carousel-refactor","ref":"video-carousel-refactor","sha":"74d8975c76f3dc174267636478a1fc3f20ac581d","user":{"login":"theonion","id":61816,"avatar_url":"https://avatars.githubusercontent.com/u/61816?v=3","gravatar_id":"","url":"https://api.github.com/users/theonion","html_url":"https://github.com/theonion","followers_url":"https://api.github.com/users/theonion/followers","following_url":"https://api.github.com/users/theonion/following{/other_user}","gists_url":"https://api.github.com/users/theonion/gists{/gist_id}","starred_url":"https://api.github.com/users/theonion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theonion/subscriptions","organizations_url":"https://api.github.com/users/theonion/orgs","repos_url":"https://api.github.com/users/theonion/repos","events_url":"https://api.github.com/users/theonion/events{/privacy}","received_events_url":"https://api.github.com/users/theonion/received_events","type":"Organization","site_admin":false},"repo":{"id":50066847,"name":"bulbs-elements","full_name":"theonion/bulbs-elements","owner":{"login":"theonion","id":61816,"avatar_url":"https://avatars.githubusercontent.com/u/61816?v=3","gravatar_id":"","url":"https://api.github.com/users/theonion","html_url":"https://github.com/theonion","followers_url":"https://api.github.com/users/theonion/followers","following_url":"https://api.github.com/users/theonion/following{/other_user}","gists_url":"https://api.github.com/users/theonion/gists{/gist_id}","starred_url":"https://api.github.com/users/theonion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theonion/subscriptions","organizations_url":"https://api.github.com/users/theonion/orgs","repos_url":"https://api.github.com/users/theonion/repos","events_url":"https://api.github.com/users/theonion/events{/privacy}","received_events_url":"https://api.github.com/users/theonion/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/theonion/bulbs-elements","description":"<web-components> for the onion and sites","fork":false,"url":"https://api.github.com/repos/theonion/bulbs-elements","forks_url":"https://api.github.com/repos/theonion/bulbs-elements/forks","keys_url":"https://api.github.com/repos/theonion/bulbs-elements/keys{/key_id}","collaborators_url":"https://api.github.com/repos/theonion/bulbs-elements/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/theonion/bulbs-elements/teams","hooks_url":"https://api.github.com/repos/theonion/bulbs-elements/hooks","issue_events_url":"https://api.github.com/repos/theonion/bulbs-elements/issues/events{/number}","events_url":"https://api.github.com/repos/theonion/bulbs-elements/events","assignees_url":"https://api.github.com/repos/theonion/bulbs-elements/assignees{/user}","branches_url":"https://api.github.com/repos/theonion/bulbs-elements/branches{/branch}","tags_url":"https://api.github.com/repos/theonion/bulbs-elements/tags","blobs_url":"https://api.github.com/repos/theonion/bulbs-elements/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/theonion/bulbs-elements/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/theonion/bulbs-elements/git/refs{/sha}","trees_url":"https://api.github.com/repos/theonion/bulbs-elements/git/trees{/sha}","statuses_url":"https://api.github.com/repos/theonion/bulbs-elements/statuses/{sha}","languages_url":"https://api.github.com/repos/theonion/bulbs-elements/languages","stargazers_url":"https://api.github.com/repos/theonion/bulbs-elements/stargazers","contributors_url":"https://api.github.com/repos/theonion/bulbs-elements/contributors","subscribers_url":"https://api.github.com/repos/theonion/bulbs-elements/subscribers","subscription_url":"https://api.github.com/repos/theonion/bulbs-elements/subscription","commits_url":"https://api.github.com/repos/theonion/bulbs-elements/commits{/sha}","git_commits_url":"https://api.github.com/repos/theonion/bulbs-elements/git/commits{/sha}","comments_url":"https://api.github.com/repos/theonion/bulbs-elements/comments{/number}","issue_comment_url":"https://api.github.com/repos/theonion/bulbs-elements/issues/comments{/number}","contents_url":"https://api.github.com/repos/theonion/bulbs-elements/contents/{+path}","compare_url":"https://api.github.com/repos/theonion/bulbs-elements/compare/{base}...{head}","merges_url":"https://api.github.com/repos/theonion/bulbs-elements/merges","archive_url":"https://api.github.com/repos/theonion/bulbs-elements/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/theonion/bulbs-elements/downloads","issues_url":"https://api.github.com/repos/theonion/bulbs-elements/issues{/number}","pulls_url":"https://api.github.com/repos/theonion/bulbs-elements/pulls{/number}","milestones_url":"https://api.github.com/repos/theonion/bulbs-elements/milestones{/number}","notifications_url":"https://api.github.com/repos/theonion/bulbs-elements/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/theonion/bulbs-elements/labels{/name}","releases_url":"https://api.github.com/repos/theonion/bulbs-elements/releases{/id}","deployments_url":"https://api.github.com/repos/theonion/bulbs-elements/deployments","created_at":"2016-01-20T23:06:45Z","updated_at":"2016-06-13T15:01:59Z","pushed_at":"2016-06-13T16:07:31Z","git_url":"git://github.com/theonion/bulbs-elements.git","ssh_url":"git@github.com:theonion/bulbs-elements.git","clone_url":"https://github.com/theonion/bulbs-elements.git","svn_url":"https://github.com/theonion/bulbs-elements","homepage":"","size":15929,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"theonion:master","ref":"master","sha":"49915331b1ceb8b0dc65761527cb87e19049e4d8","user":{"login":"theonion","id":61816,"avatar_url":"https://avatars.githubusercontent.com/u/61816?v=3","gravatar_id":"","url":"https://api.github.com/users/theonion","html_url":"https://github.com/theonion","followers_url":"https://api.github.com/users/theonion/followers","following_url":"https://api.github.com/users/theonion/following{/other_user}","gists_url":"https://api.github.com/users/theonion/gists{/gist_id}","starred_url":"https://api.github.com/users/theonion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theonion/subscriptions","organizations_url":"https://api.github.com/users/theonion/orgs","repos_url":"https://api.github.com/users/theonion/repos","events_url":"https://api.github.com/users/theonion/events{/privacy}","received_events_url":"https://api.github.com/users/theonion/received_events","type":"Organization","site_admin":false},"repo":{"id":50066847,"name":"bulbs-elements","full_name":"theonion/bulbs-elements","owner":{"login":"theonion","id":61816,"avatar_url":"https://avatars.githubusercontent.com/u/61816?v=3","gravatar_id":"","url":"https://api.github.com/users/theonion","html_url":"https://github.com/theonion","followers_url":"https://api.github.com/users/theonion/followers","following_url":"https://api.github.com/users/theonion/following{/other_user}","gists_url":"https://api.github.com/users/theonion/gists{/gist_id}","starred_url":"https://api.github.com/users/theonion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theonion/subscriptions","organizations_url":"https://api.github.com/users/theonion/orgs","repos_url":"https://api.github.com/users/theonion/repos","events_url":"https://api.github.com/users/theonion/events{/privacy}","received_events_url":"https://api.github.com/users/theonion/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/theonion/bulbs-elements","description":"<web-components> for the onion and sites","fork":false,"url":"https://api.github.com/repos/theonion/bulbs-elements","forks_url":"https://api.github.com/repos/theonion/bulbs-elements/forks","keys_url":"https://api.github.com/repos/theonion/bulbs-elements/keys{/key_id}","collaborators_url":"https://api.github.com/repos/theonion/bulbs-elements/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/theonion/bulbs-elements/teams","hooks_url":"https://api.github.com/repos/theonion/bulbs-elements/hooks","issue_events_url":"https://api.github.com/repos/theonion/bulbs-elements/issues/events{/number}","events_url":"https://api.github.com/repos/theonion/bulbs-elements/events","assignees_url":"https://api.github.com/repos/theonion/bulbs-elements/assignees{/user}","branches_url":"https://api.github.com/repos/theonion/bulbs-elements/branches{/branch}","tags_url":"https://api.github.com/repos/theonion/bulbs-elements/tags","blobs_url":"https://api.github.com/repos/theonion/bulbs-elements/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/theonion/bulbs-elements/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/theonion/bulbs-elements/git/refs{/sha}","trees_url":"https://api.github.com/repos/theonion/bulbs-elements/git/trees{/sha}","statuses_url":"https://api.github.com/repos/theonion/bulbs-elements/statuses/{sha}","languages_url":"https://api.github.com/repos/theonion/bulbs-elements/languages","stargazers_url":"https://api.github.com/repos/theonion/bulbs-elements/stargazers","contributors_url":"https://api.github.com/repos/theonion/bulbs-elements/contributors","subscribers_url":"https://api.github.com/repos/theonion/bulbs-elements/subscribers","subscription_url":"https://api.github.com/repos/theonion/bulbs-elements/subscription","commits_url":"https://api.github.com/repos/theonion/bulbs-elements/commits{/sha}","git_commits_url":"https://api.github.com/repos/theonion/bulbs-elements/git/commits{/sha}","comments_url":"https://api.github.com/repos/theonion/bulbs-elements/comments{/number}","issue_comment_url":"https://api.github.com/repos/theonion/bulbs-elements/issues/comments{/number}","contents_url":"https://api.github.com/repos/theonion/bulbs-elements/contents/{+path}","compare_url":"https://api.github.com/repos/theonion/bulbs-elements/compare/{base}...{head}","merges_url":"https://api.github.com/repos/theonion/bulbs-elements/merges","archive_url":"https://api.github.com/repos/theonion/bulbs-elements/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/theonion/bulbs-elements/downloads","issues_url":"https://api.github.com/repos/theonion/bulbs-elements/issues{/number}","pulls_url":"https://api.github.com/repos/theonion/bulbs-elements/pulls{/number}","milestones_url":"https://api.github.com/repos/theonion/bulbs-elements/milestones{/number}","notifications_url":"https://api.github.com/repos/theonion/bulbs-elements/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/theonion/bulbs-elements/labels{/name}","releases_url":"https://api.github.com/repos/theonion/bulbs-elements/releases{/id}","deployments_url":"https://api.github.com/repos/theonion/bulbs-elements/deployments","created_at":"2016-01-20T23:06:45Z","updated_at":"2016-06-13T15:01:59Z","pushed_at":"2016-06-13T16:07:31Z","git_url":"git://github.com/theonion/bulbs-elements.git","ssh_url":"git@github.com:theonion/bulbs-elements.git","clone_url":"https://github.com/theonion/bulbs-elements.git","svn_url":"https://github.com/theonion/bulbs-elements","homepage":"","size":15929,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/theonion/bulbs-elements/pulls/87"},"html":{"href":"https://github.com/theonion/bulbs-elements/pull/87"},"issue":{"href":"https://api.github.com/repos/theonion/bulbs-elements/issues/87"},"comments":{"href":"https://api.github.com/repos/theonion/bulbs-elements/issues/87/comments"},"review_comments":{"href":"https://api.github.com/repos/theonion/bulbs-elements/pulls/87/comments"},"review_comment":{"href":"https://api.github.com/repos/theonion/bulbs-elements/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/theonion/bulbs-elements/pulls/87/commits"},"statuses":{"href":"https://api.github.com/repos/theonion/bulbs-elements/statuses/74d8975c76f3dc174267636478a1fc3f20ac581d"}}}}
{"actor":{"display_login":"collin"}}