Skip to content

No way to limit the data source top? #89

@SaintFlipper

Description

@SaintFlipper

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:

<div ui-scroll-viewport style="height:800px;">
    <div class="imageCell" ui-scroll="item in scrollerDataSource">
        <a class="thumbnail">
            <img alt="IMG" class="thumbImg" overlay-reveal="{{item.summary}}" ng-src="/{{item.imageSquareThumbnailURL}}" ng-click="content.popup(item);"/>
        </a>
    </div>
</div>

I 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.

In 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.

Currently 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions