{"action":"created","comment":{"url":"https://api.github.com/repos/vvo/in-viewport/pulls/comments/31438754","id":31438754,"diff_hunk":"@@ -94,20 +93,35 @@ function createInViewport(container) {\n   setInterval(debouncedCheck, 150);\n \n   function isInViewport(elt, offset, cb) {\n-    var visible = isVisible(elt, offset);\n-    if (visible) {\n-      if (cb) {\n-        watching.splice(indexOf.call(watching, elt), 1);\n-        cb(elt);\n-      }\n-      return true;\n+    if (!cb) {\n+      return isVisible(elt, offset);\n+    }\n+\n+    var accessor = createAccessor(elt, offset, cb);","path":"in-viewport.js","position":38,"original_position":38,"commit_id":"9776baa07e17fd1a5460d1eddedfe4a692b5b16c","original_commit_id":"9776baa07e17fd1a5460d1eddedfe4a692b5b16c","user":{"login":"vvo","id":123822,"avatar_url":"https://avatars.githubusercontent.com/u/123822?v=3","gravatar_id":"","url":"https://api.github.com/users/vvo","html_url":"https://github.com/vvo","followers_url":"https://api.github.com/users/vvo/followers","following_url":"https://api.github.com/users/vvo/following{/other_user}","gists_url":"https://api.github.com/users/vvo/gists{/gist_id}","starred_url":"https://api.github.com/users/vvo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vvo/subscriptions","organizations_url":"https://api.github.com/users/vvo/orgs","repos_url":"https://api.github.com/users/vvo/repos","events_url":"https://api.github.com/users/vvo/events{/privacy}","received_events_url":"https://api.github.com/users/vvo/received_events","type":"User","site_admin":false},"body":"`var watcher = createWatcher(..)`? Would be less abstract I feel","created_at":"2015-06-01T15:48:04Z","updated_at":"2015-06-01T15:48:04Z","html_url":"https://github.com/vvo/in-viewport/pull/10#discussion_r31438754","pull_request_url":"https://api.github.com/repos/vvo/in-viewport/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/vvo/in-viewport/pulls/comments/31438754"},"html":{"href":"https://github.com/vvo/in-viewport/pull/10#discussion_r31438754"},"pull_request":{"href":"https://api.github.com/repos/vvo/in-viewport/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/vvo/in-viewport/pulls/10","id":36627747,"html_url":"https://github.com/vvo/in-viewport/pull/10","diff_url":"https://github.com/vvo/in-viewport/pull/10.diff","patch_url":"https://github.com/vvo/in-viewport/pull/10.patch","issue_url":"https://api.github.com/repos/vvo/in-viewport/issues/10","number":10,"state":"open","locked":false,"title":"Patch to add a watch & dispose API","user":{"login":"tzi","id":415891,"avatar_url":"https://avatars.githubusercontent.com/u/415891?v=3","gravatar_id":"","url":"https://api.github.com/users/tzi","html_url":"https://github.com/tzi","followers_url":"https://api.github.com/users/tzi/followers","following_url":"https://api.github.com/users/tzi/following{/other_user}","gists_url":"https://api.github.com/users/tzi/gists{/gist_id}","starred_url":"https://api.github.com/users/tzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzi/subscriptions","organizations_url":"https://api.github.com/users/tzi/orgs","repos_url":"https://api.github.com/users/tzi/repos","events_url":"https://api.github.com/users/tzi/events{/privacy}","received_events_url":"https://api.github.com/users/tzi/received_events","type":"User","site_admin":false},"body":"Hi @vvo!\r\n\r\nSince I've seen the open issue and I like this project, I would like to try to provide a watch / dispose API.\r\n\r\nI had to make some code reorganization, so you probably won't like it :(\r\nI made 3 commits, you should probably review one by one, it would be easier:\r\n\r\n1. Add a test for the dispose API\r\n2. Regroup `watches` & `watching` variables and add an API over it to make the code more readable & maintainable. This was not mandatory, but it simplify a lot the next reorganization.\r\n3. Add a `watch` & `dispose` API when isInViewport is called with a callback.\r\n\r\nThere is no hurry with this PR.\r\nI'm available to help if you're interested in this feature.\r\n\r\nCheers,\r\nThomas.","created_at":"2015-06-01T13:21:23Z","updated_at":"2015-06-01T15:48:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ed8501b13cc7924fc690576ac10469f367ad364","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/vvo/in-viewport/pulls/10/commits","review_comments_url":"https://api.github.com/repos/vvo/in-viewport/pulls/10/comments","review_comment_url":"https://api.github.com/repos/vvo/in-viewport/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vvo/in-viewport/issues/10/comments","statuses_url":"https://api.github.com/repos/vvo/in-viewport/statuses/9776baa07e17fd1a5460d1eddedfe4a692b5b16c","head":{"label":"tzi:patch_clean-dispose","ref":"patch_clean-dispose","sha":"9776baa07e17fd1a5460d1eddedfe4a692b5b16c","user":{"login":"tzi","id":415891,"avatar_url":"https://avatars.githubusercontent.com/u/415891?v=3","gravatar_id":"","url":"https://api.github.com/users/tzi","html_url":"https://github.com/tzi","followers_url":"https://api.github.com/users/tzi/followers","following_url":"https://api.github.com/users/tzi/following{/other_user}","gists_url":"https://api.github.com/users/tzi/gists{/gist_id}","starred_url":"https://api.github.com/users/tzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzi/subscriptions","organizations_url":"https://api.github.com/users/tzi/orgs","repos_url":"https://api.github.com/users/tzi/repos","events_url":"https://api.github.com/users/tzi/events{/privacy}","received_events_url":"https://api.github.com/users/tzi/received_events","type":"User","site_admin":false},"repo":{"id":33188323,"name":"in-viewport","full_name":"tzi/in-viewport","owner":{"login":"tzi","id":415891,"avatar_url":"https://avatars.githubusercontent.com/u/415891?v=3","gravatar_id":"","url":"https://api.github.com/users/tzi","html_url":"https://github.com/tzi","followers_url":"https://api.github.com/users/tzi/followers","following_url":"https://api.github.com/users/tzi/following{/other_user}","gists_url":"https://api.github.com/users/tzi/gists{/gist_id}","starred_url":"https://api.github.com/users/tzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzi/subscriptions","organizations_url":"https://api.github.com/users/tzi/orgs","repos_url":"https://api.github.com/users/tzi/repos","events_url":"https://api.github.com/users/tzi/events{/privacy}","received_events_url":"https://api.github.com/users/tzi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tzi/in-viewport","description":"Get a callback when any element becomes visible in a viewport (body or custom viewport)","fork":true,"url":"https://api.github.com/repos/tzi/in-viewport","forks_url":"https://api.github.com/repos/tzi/in-viewport/forks","keys_url":"https://api.github.com/repos/tzi/in-viewport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tzi/in-viewport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tzi/in-viewport/teams","hooks_url":"https://api.github.com/repos/tzi/in-viewport/hooks","issue_events_url":"https://api.github.com/repos/tzi/in-viewport/issues/events{/number}","events_url":"https://api.github.com/repos/tzi/in-viewport/events","assignees_url":"https://api.github.com/repos/tzi/in-viewport/assignees{/user}","branches_url":"https://api.github.com/repos/tzi/in-viewport/branches{/branch}","tags_url":"https://api.github.com/repos/tzi/in-viewport/tags","blobs_url":"https://api.github.com/repos/tzi/in-viewport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tzi/in-viewport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tzi/in-viewport/git/refs{/sha}","trees_url":"https://api.github.com/repos/tzi/in-viewport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tzi/in-viewport/statuses/{sha}","languages_url":"https://api.github.com/repos/tzi/in-viewport/languages","stargazers_url":"https://api.github.com/repos/tzi/in-viewport/stargazers","contributors_url":"https://api.github.com/repos/tzi/in-viewport/contributors","subscribers_url":"https://api.github.com/repos/tzi/in-viewport/subscribers","subscription_url":"https://api.github.com/repos/tzi/in-viewport/subscription","commits_url":"https://api.github.com/repos/tzi/in-viewport/commits{/sha}","git_commits_url":"https://api.github.com/repos/tzi/in-viewport/git/commits{/sha}","comments_url":"https://api.github.com/repos/tzi/in-viewport/comments{/number}","issue_comment_url":"https://api.github.com/repos/tzi/in-viewport/issues/comments{/number}","contents_url":"https://api.github.com/repos/tzi/in-viewport/contents/{+path}","compare_url":"https://api.github.com/repos/tzi/in-viewport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tzi/in-viewport/merges","archive_url":"https://api.github.com/repos/tzi/in-viewport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tzi/in-viewport/downloads","issues_url":"https://api.github.com/repos/tzi/in-viewport/issues{/number}","pulls_url":"https://api.github.com/repos/tzi/in-viewport/pulls{/number}","milestones_url":"https://api.github.com/repos/tzi/in-viewport/milestones{/number}","notifications_url":"https://api.github.com/repos/tzi/in-viewport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tzi/in-viewport/labels{/name}","releases_url":"https://api.github.com/repos/tzi/in-viewport/releases{/id}","created_at":"2015-03-31T13:56:08Z","updated_at":"2015-03-31T13:56:08Z","pushed_at":"2015-06-01T13:10:19Z","git_url":"git://github.com/tzi/in-viewport.git","ssh_url":"git@github.com:tzi/in-viewport.git","clone_url":"https://github.com/tzi/in-viewport.git","svn_url":"https://github.com/tzi/in-viewport","homepage":"","size":241,"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":"master"}},"base":{"label":"vvo:master","ref":"master","sha":"84adf6ca39a5afeed42b4b9f71c542ecdcf6dfef","user":{"login":"vvo","id":123822,"avatar_url":"https://avatars.githubusercontent.com/u/123822?v=3","gravatar_id":"","url":"https://api.github.com/users/vvo","html_url":"https://github.com/vvo","followers_url":"https://api.github.com/users/vvo/followers","following_url":"https://api.github.com/users/vvo/following{/other_user}","gists_url":"https://api.github.com/users/vvo/gists{/gist_id}","starred_url":"https://api.github.com/users/vvo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vvo/subscriptions","organizations_url":"https://api.github.com/users/vvo/orgs","repos_url":"https://api.github.com/users/vvo/repos","events_url":"https://api.github.com/users/vvo/events{/privacy}","received_events_url":"https://api.github.com/users/vvo/received_events","type":"User","site_admin":false},"repo":{"id":9948608,"name":"in-viewport","full_name":"vvo/in-viewport","owner":{"login":"vvo","id":123822,"avatar_url":"https://avatars.githubusercontent.com/u/123822?v=3","gravatar_id":"","url":"https://api.github.com/users/vvo","html_url":"https://github.com/vvo","followers_url":"https://api.github.com/users/vvo/followers","following_url":"https://api.github.com/users/vvo/following{/other_user}","gists_url":"https://api.github.com/users/vvo/gists{/gist_id}","starred_url":"https://api.github.com/users/vvo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vvo/subscriptions","organizations_url":"https://api.github.com/users/vvo/orgs","repos_url":"https://api.github.com/users/vvo/repos","events_url":"https://api.github.com/users/vvo/events{/privacy}","received_events_url":"https://api.github.com/users/vvo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vvo/in-viewport","description":"Get a callback when any element becomes visible in a viewport (body or custom viewport)","fork":false,"url":"https://api.github.com/repos/vvo/in-viewport","forks_url":"https://api.github.com/repos/vvo/in-viewport/forks","keys_url":"https://api.github.com/repos/vvo/in-viewport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vvo/in-viewport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vvo/in-viewport/teams","hooks_url":"https://api.github.com/repos/vvo/in-viewport/hooks","issue_events_url":"https://api.github.com/repos/vvo/in-viewport/issues/events{/number}","events_url":"https://api.github.com/repos/vvo/in-viewport/events","assignees_url":"https://api.github.com/repos/vvo/in-viewport/assignees{/user}","branches_url":"https://api.github.com/repos/vvo/in-viewport/branches{/branch}","tags_url":"https://api.github.com/repos/vvo/in-viewport/tags","blobs_url":"https://api.github.com/repos/vvo/in-viewport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vvo/in-viewport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vvo/in-viewport/git/refs{/sha}","trees_url":"https://api.github.com/repos/vvo/in-viewport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vvo/in-viewport/statuses/{sha}","languages_url":"https://api.github.com/repos/vvo/in-viewport/languages","stargazers_url":"https://api.github.com/repos/vvo/in-viewport/stargazers","contributors_url":"https://api.github.com/repos/vvo/in-viewport/contributors","subscribers_url":"https://api.github.com/repos/vvo/in-viewport/subscribers","subscription_url":"https://api.github.com/repos/vvo/in-viewport/subscription","commits_url":"https://api.github.com/repos/vvo/in-viewport/commits{/sha}","git_commits_url":"https://api.github.com/repos/vvo/in-viewport/git/commits{/sha}","comments_url":"https://api.github.com/repos/vvo/in-viewport/comments{/number}","issue_comment_url":"https://api.github.com/repos/vvo/in-viewport/issues/comments{/number}","contents_url":"https://api.github.com/repos/vvo/in-viewport/contents/{+path}","compare_url":"https://api.github.com/repos/vvo/in-viewport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vvo/in-viewport/merges","archive_url":"https://api.github.com/repos/vvo/in-viewport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vvo/in-viewport/downloads","issues_url":"https://api.github.com/repos/vvo/in-viewport/issues{/number}","pulls_url":"https://api.github.com/repos/vvo/in-viewport/pulls{/number}","milestones_url":"https://api.github.com/repos/vvo/in-viewport/milestones{/number}","notifications_url":"https://api.github.com/repos/vvo/in-viewport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vvo/in-viewport/labels{/name}","releases_url":"https://api.github.com/repos/vvo/in-viewport/releases{/id}","created_at":"2013-05-09T00:07:00Z","updated_at":"2015-05-24T20:23:47Z","pushed_at":"2015-06-01T13:21:23Z","git_url":"git://github.com/vvo/in-viewport.git","ssh_url":"git@github.com:vvo/in-viewport.git","clone_url":"https://github.com/vvo/in-viewport.git","svn_url":"https://github.com/vvo/in-viewport","homepage":"","size":600,"stargazers_count":49,"watchers_count":49,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":2,"forks":7,"open_issues":2,"watchers":49,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vvo/in-viewport/pulls/10"},"html":{"href":"https://github.com/vvo/in-viewport/pull/10"},"issue":{"href":"https://api.github.com/repos/vvo/in-viewport/issues/10"},"comments":{"href":"https://api.github.com/repos/vvo/in-viewport/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/vvo/in-viewport/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/vvo/in-viewport/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vvo/in-viewport/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/vvo/in-viewport/statuses/9776baa07e17fd1a5460d1eddedfe4a692b5b16c"}}}}