{"action":"created","comment":{"url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/comments/87456338","pull_request_review_id":8069498,"id":87456338,"diff_hunk":"@@ -6,27 +6,120 @@ define(['./load', './picture', './gallery', './resizer', './upload'], function(l\n \n   hide(filtersBlock);\n \n-  var picturesCallbackName = '__jsonpCallback';\n-  var picturesUrl = '/api/pictures?callback=';\n+  var picturesUrl = '/api/pictures';\n   var gallery = new Gallery();\n \n-  load(picturesUrl, loadCallback, picturesCallbackName);\n+  var pageNumber = 0;\n+  var pageSize = 12;\n+  var currentFilter = 'filter-popular';\n+  var params = {\n+    from: pageNumber * pageSize,\n+    to: pageNumber * pageSize + pageSize,\n+    filter: currentFilter\n+  };\n+\n+  var originArraySize = 0;\n+  setOriginArraySize();\n+\n+  load(picturesUrl, params, loadCallback);\n+\n+  function setOriginArraySize() {\n+    load(picturesUrl, {\n+      from: 0,\n+      to: Infinity,\n+      filter: currentFilter\n+    }, function(data) {\n+      originArraySize = data.length;\n+    });\n+  }\n+\n+  var footer = document.querySelector('.footer');\n+  var scrollingGap = 100;\n+  var throttleTimeout = 100;\n+  var lastCall = Date.now();\n+\n+  function isFooterVisible() {\n+    var clientRect = footer.getBoundingClientRect();\n+    var bottomDelta = clientRect.bottom - window.innerHeight;\n+    return bottomDelta <= scrollingGap;\n+  }\n+\n+  function showNextPage() {\n+    if (!isAllDataLoaded() && isFooterVisible()) {\n+      params.from = ++pageNumber * pageSize;\n+      params.to = params.from + pageSize;\n+\n+      load(picturesUrl, params, loadCallback);\n+    }\n+    lastCall = Date.now();\n+  }\n+\n+  window.addEventListener('scroll', function() {\n+    if (isAllDataLoaded()) {\n+      return;\n+    }\n+\n+    var isTimeoutEnded = Date.now() - lastCall >= throttleTimeout;\n+    if (isTimeoutEnded) {\n+      showNextPage();\n+    }\n+  });\n+\n+  var loadedData = [];","path":"src/js/main.js","position":49,"original_position":66,"commit_id":"0bff9e51ecf0c46981cb53a90eb8136dde77b9bb","original_commit_id":"1e18d131da9e8df5e012602f281488b5f0ad484e","user":{"login":"panban","id":8193640,"avatar_url":"https://avatars.githubusercontent.com/u/8193640?v=3","gravatar_id":"","url":"https://api.github.com/users/panban","html_url":"https://github.com/panban","followers_url":"https://api.github.com/users/panban/followers","following_url":"https://api.github.com/users/panban/following{/other_user}","gists_url":"https://api.github.com/users/panban/gists{/gist_id}","starred_url":"https://api.github.com/users/panban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/panban/subscriptions","organizations_url":"https://api.github.com/users/panban/orgs","repos_url":"https://api.github.com/users/panban/repos","events_url":"https://api.github.com/users/panban/events{/privacy}","received_events_url":"https://api.github.com/users/panban/received_events","type":"User","site_admin":false},"body":"Зачем каждый раз заново создавать и рендерить уже загруженные сообщения? Почему не добавлять к предыдущим новые? Нужно отрендерить новые элементы и поместить их в массив loadedData","created_at":"2016-11-10T18:31:32Z","updated_at":"2016-11-10T18:31:32Z","html_url":"https://github.com/htmlacademy-javascript/159646-kekstagram/pull/12#discussion_r87456338","pull_request_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/comments/87456338"},"html":{"href":"https://github.com/htmlacademy-javascript/159646-kekstagram/pull/12#discussion_r87456338"},"pull_request":{"href":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/12","id":92854719,"html_url":"https://github.com/htmlacademy-javascript/159646-kekstagram/pull/12","diff_url":"https://github.com/htmlacademy-javascript/159646-kekstagram/pull/12.diff","patch_url":"https://github.com/htmlacademy-javascript/159646-kekstagram/pull/12.patch","issue_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/issues/12","number":12,"state":"open","locked":false,"title":"Постраничный вывод и делегирование событий","user":{"login":"AlekseyTrubitsyn","id":16762192,"avatar_url":"https://avatars.githubusercontent.com/u/16762192?v=3","gravatar_id":"","url":"https://api.github.com/users/AlekseyTrubitsyn","html_url":"https://github.com/AlekseyTrubitsyn","followers_url":"https://api.github.com/users/AlekseyTrubitsyn/followers","following_url":"https://api.github.com/users/AlekseyTrubitsyn/following{/other_user}","gists_url":"https://api.github.com/users/AlekseyTrubitsyn/gists{/gist_id}","starred_url":"https://api.github.com/users/AlekseyTrubitsyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlekseyTrubitsyn/subscriptions","organizations_url":"https://api.github.com/users/AlekseyTrubitsyn/orgs","repos_url":"https://api.github.com/users/AlekseyTrubitsyn/repos","events_url":"https://api.github.com/users/AlekseyTrubitsyn/events{/privacy}","received_events_url":"https://api.github.com/users/AlekseyTrubitsyn/received_events","type":"User","site_admin":false},"body":"\n\n--\n:boom: https://htmlacademy-javascript.github.io/159646-kekstagram/12/","created_at":"2016-11-08T20:40:20Z","updated_at":"2016-11-10T18:31:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d7d7c7820ad3b763c4470f98e966aff918a441d8","assignee":{"login":"panban","id":8193640,"avatar_url":"https://avatars.githubusercontent.com/u/8193640?v=3","gravatar_id":"","url":"https://api.github.com/users/panban","html_url":"https://github.com/panban","followers_url":"https://api.github.com/users/panban/followers","following_url":"https://api.github.com/users/panban/following{/other_user}","gists_url":"https://api.github.com/users/panban/gists{/gist_id}","starred_url":"https://api.github.com/users/panban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/panban/subscriptions","organizations_url":"https://api.github.com/users/panban/orgs","repos_url":"https://api.github.com/users/panban/repos","events_url":"https://api.github.com/users/panban/events{/privacy}","received_events_url":"https://api.github.com/users/panban/received_events","type":"User","site_admin":false},"assignees":[{"login":"panban","id":8193640,"avatar_url":"https://avatars.githubusercontent.com/u/8193640?v=3","gravatar_id":"","url":"https://api.github.com/users/panban","html_url":"https://github.com/panban","followers_url":"https://api.github.com/users/panban/followers","following_url":"https://api.github.com/users/panban/following{/other_user}","gists_url":"https://api.github.com/users/panban/gists{/gist_id}","starred_url":"https://api.github.com/users/panban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/panban/subscriptions","organizations_url":"https://api.github.com/users/panban/orgs","repos_url":"https://api.github.com/users/panban/repos","events_url":"https://api.github.com/users/panban/events{/privacy}","received_events_url":"https://api.github.com/users/panban/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/12/commits","review_comments_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/12/comments","review_comment_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/comments{/number}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/issues/12/comments","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/statuses/0bff9e51ecf0c46981cb53a90eb8136dde77b9bb","head":{"label":"AlekseyTrubitsyn:module7-task1","ref":"module7-task1","sha":"0bff9e51ecf0c46981cb53a90eb8136dde77b9bb","user":{"login":"AlekseyTrubitsyn","id":16762192,"avatar_url":"https://avatars.githubusercontent.com/u/16762192?v=3","gravatar_id":"","url":"https://api.github.com/users/AlekseyTrubitsyn","html_url":"https://github.com/AlekseyTrubitsyn","followers_url":"https://api.github.com/users/AlekseyTrubitsyn/followers","following_url":"https://api.github.com/users/AlekseyTrubitsyn/following{/other_user}","gists_url":"https://api.github.com/users/AlekseyTrubitsyn/gists{/gist_id}","starred_url":"https://api.github.com/users/AlekseyTrubitsyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlekseyTrubitsyn/subscriptions","organizations_url":"https://api.github.com/users/AlekseyTrubitsyn/orgs","repos_url":"https://api.github.com/users/AlekseyTrubitsyn/repos","events_url":"https://api.github.com/users/AlekseyTrubitsyn/events{/privacy}","received_events_url":"https://api.github.com/users/AlekseyTrubitsyn/received_events","type":"User","site_admin":false},"repo":{"id":69997474,"name":"159646-kekstagram","full_name":"AlekseyTrubitsyn/159646-kekstagram","owner":{"login":"AlekseyTrubitsyn","id":16762192,"avatar_url":"https://avatars.githubusercontent.com/u/16762192?v=3","gravatar_id":"","url":"https://api.github.com/users/AlekseyTrubitsyn","html_url":"https://github.com/AlekseyTrubitsyn","followers_url":"https://api.github.com/users/AlekseyTrubitsyn/followers","following_url":"https://api.github.com/users/AlekseyTrubitsyn/following{/other_user}","gists_url":"https://api.github.com/users/AlekseyTrubitsyn/gists{/gist_id}","starred_url":"https://api.github.com/users/AlekseyTrubitsyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlekseyTrubitsyn/subscriptions","organizations_url":"https://api.github.com/users/AlekseyTrubitsyn/orgs","repos_url":"https://api.github.com/users/AlekseyTrubitsyn/repos","events_url":"https://api.github.com/users/AlekseyTrubitsyn/events{/privacy}","received_events_url":"https://api.github.com/users/AlekseyTrubitsyn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AlekseyTrubitsyn/159646-kekstagram","description":"Алексей Трубицын","fork":true,"url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram","forks_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/forks","keys_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/teams","hooks_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/hooks","issue_events_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/issues/events{/number}","events_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/events","assignees_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/assignees{/user}","branches_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/branches{/branch}","tags_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/tags","blobs_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/git/refs{/sha}","trees_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/statuses/{sha}","languages_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/languages","stargazers_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/stargazers","contributors_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/contributors","subscribers_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/subscribers","subscription_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/subscription","commits_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/commits{/sha}","git_commits_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/git/commits{/sha}","comments_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/comments{/number}","issue_comment_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/issues/comments{/number}","contents_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/contents/{+path}","compare_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/merges","archive_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/downloads","issues_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/issues{/number}","pulls_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/pulls{/number}","milestones_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/milestones{/number}","notifications_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/labels{/name}","releases_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/releases{/id}","deployments_url":"https://api.github.com/repos/AlekseyTrubitsyn/159646-kekstagram/deployments","created_at":"2016-10-04T19:10:54Z","updated_at":"2016-10-04T19:10:56Z","pushed_at":"2016-11-09T21:52:44Z","git_url":"git://github.com/AlekseyTrubitsyn/159646-kekstagram.git","ssh_url":"git@github.com:AlekseyTrubitsyn/159646-kekstagram.git","clone_url":"https://github.com/AlekseyTrubitsyn/159646-kekstagram.git","svn_url":"https://github.com/AlekseyTrubitsyn/159646-kekstagram","homepage":null,"size":4375,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":false,"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":"htmlacademy-javascript:master","ref":"master","sha":"0195439ce9aa122e180d77c5c233bb85187eab26","user":{"login":"htmlacademy-javascript","id":14179712,"avatar_url":"https://avatars.githubusercontent.com/u/14179712?v=3","gravatar_id":"","url":"https://api.github.com/users/htmlacademy-javascript","html_url":"https://github.com/htmlacademy-javascript","followers_url":"https://api.github.com/users/htmlacademy-javascript/followers","following_url":"https://api.github.com/users/htmlacademy-javascript/following{/other_user}","gists_url":"https://api.github.com/users/htmlacademy-javascript/gists{/gist_id}","starred_url":"https://api.github.com/users/htmlacademy-javascript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htmlacademy-javascript/subscriptions","organizations_url":"https://api.github.com/users/htmlacademy-javascript/orgs","repos_url":"https://api.github.com/users/htmlacademy-javascript/repos","events_url":"https://api.github.com/users/htmlacademy-javascript/events{/privacy}","received_events_url":"https://api.github.com/users/htmlacademy-javascript/received_events","type":"Organization","site_admin":false},"repo":{"id":69996132,"name":"159646-kekstagram","full_name":"htmlacademy-javascript/159646-kekstagram","owner":{"login":"htmlacademy-javascript","id":14179712,"avatar_url":"https://avatars.githubusercontent.com/u/14179712?v=3","gravatar_id":"","url":"https://api.github.com/users/htmlacademy-javascript","html_url":"https://github.com/htmlacademy-javascript","followers_url":"https://api.github.com/users/htmlacademy-javascript/followers","following_url":"https://api.github.com/users/htmlacademy-javascript/following{/other_user}","gists_url":"https://api.github.com/users/htmlacademy-javascript/gists{/gist_id}","starred_url":"https://api.github.com/users/htmlacademy-javascript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htmlacademy-javascript/subscriptions","organizations_url":"https://api.github.com/users/htmlacademy-javascript/orgs","repos_url":"https://api.github.com/users/htmlacademy-javascript/repos","events_url":"https://api.github.com/users/htmlacademy-javascript/events{/privacy}","received_events_url":"https://api.github.com/users/htmlacademy-javascript/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/htmlacademy-javascript/159646-kekstagram","description":"Алексей Трубицын","fork":false,"url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram","forks_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/forks","keys_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/teams","hooks_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/hooks","issue_events_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/issues/events{/number}","events_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/events","assignees_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/assignees{/user}","branches_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/branches{/branch}","tags_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/tags","blobs_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/git/refs{/sha}","trees_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/statuses/{sha}","languages_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/languages","stargazers_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/stargazers","contributors_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/contributors","subscribers_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/subscribers","subscription_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/subscription","commits_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/commits{/sha}","git_commits_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/git/commits{/sha}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/comments{/number}","issue_comment_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/issues/comments{/number}","contents_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/contents/{+path}","compare_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/merges","archive_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/downloads","issues_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/issues{/number}","pulls_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls{/number}","milestones_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/milestones{/number}","notifications_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/labels{/name}","releases_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/releases{/id}","deployments_url":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/deployments","created_at":"2016-10-04T18:53:25Z","updated_at":"2016-10-04T19:17:58Z","pushed_at":"2016-11-09T21:55:34Z","git_url":"git://github.com/htmlacademy-javascript/159646-kekstagram.git","ssh_url":"git@github.com:htmlacademy-javascript/159646-kekstagram.git","clone_url":"https://github.com/htmlacademy-javascript/159646-kekstagram.git","svn_url":"https://github.com/htmlacademy-javascript/159646-kekstagram","homepage":"https://github.com/AlekseyTrubitsyn/159646-kekstagram","size":4574,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/12"},"html":{"href":"https://github.com/htmlacademy-javascript/159646-kekstagram/pull/12"},"issue":{"href":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/issues/12"},"comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/htmlacademy-javascript/159646-kekstagram/statuses/0bff9e51ecf0c46981cb53a90eb8136dde77b9bb"}}}}
{"actor":{"display_login":"panban"}}