Added Programmatic Population of Items

Merged
#15 · Created  · Last updated

Merged pull request

Added programmatic population of items.

f1798d7·Author: ·Closed by: ·2019-03-16

Description

Resolves

N/A

Proposed Changes

Adds an accessor for the closestItem (the item closest to the scroll snap’s pivot.

Adds an IEnumberable accessor for all of the items of the scroll snap.

Allows you to programmatically add and remove items from the Scroll Snap. Includes the following functions: AddItemAtEnd, AddItemAtStart, AddItemAfter, AddItemBefore, RemoveItem, RemoveItemAtStart, and RemoveITemAtEnd.

Reason for Changes

Often people want to populate a scroll snap dynamically based on some outside data, such as available items in a shop, or available maps for a gamemode. This change supports this.

Test Coverage

Added tests for the InternalAddItem function (the function all Add functions delegate to).

Added tests for the closestItem accessor.

Added some additional tests to the ShiftItemsForSnappability class (previously the ShiftItems class) to cover some issues found while creating this feature.

The RemoveItem functions were tested by hand using the Modifying at Runtime demo.

  1. Hit play to run the Modifying at Runtime demo.

  2. Hit the Remove Item button. Observed how the item was properly removed. (pass)

  3. Hit the Remove Item Delayed button and dragged the scroll snap. Observed how the item was properly removed and the scroll snap did not appear to jump. (pass)

  4. Flung the scroll snap and hit the Remove Item button. Observed how the item was properly removed and the scroll snap did not appear to jump. (pass)

Repeated for all RemoveItem functions.

The AddItem functions were also tested by hand in addition to the programmatic tests so that they could be verified visually. This was done using the Modifying at Runtime demo.

  1. Hit play to run the Modifying at Runtime demo.

  2. Hit the Add Item button. Observed how the item was properly added. (pass)

  3. Hit the Add Item Delayed button and dragged the scroll snap. Observed how the item was properly added and the scroll snap did not appear to jump. (pass)

  4. Flung the scroll snap and hit the Add Item button. Observed how the item was properly added and the scroll snap did not appear to jump. (pass)

Repeated for all AddItem functions.

Note that adding/removing an item does not cause the scroll snap to recalculate its snap position, so removing or shifting (for instance when adding items) the item that the scroll snap is scrolling to could break your scroll snap. It will become easier to avoid this as properties like velocity become public.

DEMO COVERAGE

Added a Populating Before Enabled demo to showcase how it is more efficient to populate the scroll snap before it is enabled, if possible.

Added a Modifying at Runtime demo to showcase how modifying the scroll snap works when the scroll snap is running.

Additional Information

N/A

0 attachments

0 comments

Loading commits...