{"action":"created","issue":{"url":"https://api.github.com/repos/Hill30/NGScroller/issues/89","labels_url":"https://api.github.com/repos/Hill30/NGScroller/issues/89/labels{/name}","comments_url":"https://api.github.com/repos/Hill30/NGScroller/issues/89/comments","events_url":"https://api.github.com/repos/Hill30/NGScroller/issues/89/events","html_url":"https://github.com/Hill30/NGScroller/issues/89","id":92710366,"number":89,"title":"No way to limit the data source top?","user":{"login":"SaintFlipper","id":13155493,"avatar_url":"https://avatars.githubusercontent.com/u/13155493?v=3","gravatar_id":"","url":"https://api.github.com/users/SaintFlipper","html_url":"https://github.com/SaintFlipper","followers_url":"https://api.github.com/users/SaintFlipper/followers","following_url":"https://api.github.com/users/SaintFlipper/following{/other_user}","gists_url":"https://api.github.com/users/SaintFlipper/gists{/gist_id}","starred_url":"https://api.github.com/users/SaintFlipper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SaintFlipper/subscriptions","organizations_url":"https://api.github.com/users/SaintFlipper/orgs","repos_url":"https://api.github.com/users/SaintFlipper/repos","events_url":"https://api.github.com/users/SaintFlipper/events{/privacy}","received_events_url":"https://api.github.com/users/SaintFlipper/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-02T19:03:57Z","updated_at":"2015-07-04T02:04:20Z","closed_at":null,"body":"I'm using uiScroll to display image thumbnails queried from a back-end service. The images are displayed a float:left DIVs rather than using a table, something like this:\r\n\r\n```html\r\n<div ui-scroll-viewport style=\"height:800px;\">\r\n\t<div class=\"imageCell\" ui-scroll=\"item in scrollerDataSource\">\r\n\t\t<a class=\"thumbnail\">\r\n\t\t\t<img alt=\"IMG\" class=\"thumbImg\" overlay-reveal=\"{{item.summary}}\" ng-src=\"/{{item.imageSquareThumbnailURL}}\" ng-click=\"content.popup(item);\"/>\r\n\t\t</a>\r\n\t</div>\r\n</div>\r\n```\r\n\r\nI notice that on the first page load the data source get() is called with index=1, 11, 21 as the viewport is filled, and finally with index=-9. A negative index is also specified if the user scrolls down then up again to the top. That's fine in the examples where the item is programatically created and the index is used in the display value, but it has no meaning when querying from a data source with a defined \"top\", for example here where the \"top\" is the most recently received image.\r\n\r\nIn such a case there doesn't seem to be any way to specify that there are no previous items to return. If get() calls success() with an array of items smaller than the requested count then it seems that success() has no way of knowing which items those are. For example if get() is called with index=-5 and count=10 the data source could choose to clip the item array so it only contains the 5 items for index=0..4. However success() doesn't know that those items are for 0..4, and they might as well be for -5...-1 or any other subset.\r\n\r\nCurrently my data source just ignores any get() request with a negative index and returns an empty set of items. However that results in bizarre behaviour where scrolling down then back up to the top leaves a different item at the top each time.\r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Hill30/NGScroller/issues/comments/118449770","html_url":"https://github.com/Hill30/NGScroller/issues/89#issuecomment-118449770","issue_url":"https://api.github.com/repos/Hill30/NGScroller/issues/89","id":118449770,"user":{"login":"mfeingold","id":135903,"avatar_url":"https://avatars.githubusercontent.com/u/135903?v=3","gravatar_id":"","url":"https://api.github.com/users/mfeingold","html_url":"https://github.com/mfeingold","followers_url":"https://api.github.com/users/mfeingold/followers","following_url":"https://api.github.com/users/mfeingold/following{/other_user}","gists_url":"https://api.github.com/users/mfeingold/gists{/gist_id}","starred_url":"https://api.github.com/users/mfeingold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfeingold/subscriptions","organizations_url":"https://api.github.com/users/mfeingold/orgs","repos_url":"https://api.github.com/users/mfeingold/repos","events_url":"https://api.github.com/users/mfeingold/events{/privacy}","received_events_url":"https://api.github.com/users/mfeingold/received_events","type":"User","site_admin":false},"created_at":"2015-07-04T02:04:20Z","updated_at":"2015-07-04T02:04:20Z","body":"I know this business of negative index makes this math about indexes a bit tricky, especially because of the unpredictability of the scrolling increments generated by the scroll bars. \r\n\r\nIgnoring negative indexes is not right. When a bufferSize (default 10) of items is requested us say from index -9, you indeed need to return an empty array (assuming that you want to index your dataset starting with index 1). For starting index -8 the return array should consist of single item #1 in your dataset. For -7 it should be 2 items #1 and #2 and so forth.\r\n\r\nIt feels somewhat complex, but this is what allows you populate the scroller starting from arbitrary position  \r\nand the scroll in both directions.\r\n\r\nThe implementation of this math is actually not that complex. Check for instance [this](http://rawgit.com/Hill30/NGScroller/master/src/examples/positionedList.html) example\r\n"}}