Giter Site home page Giter Site logo

ethansinjin / timelineview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lukescott/timelineview

0.0 2.0 0.0 55 KB

TimelineView functions like a UITableView, but allows you to position cells anywhere using a custom frame (CGRect). This allows you to have irregular spacing, overlapping cells, etc...

License: MIT License

Objective-C 100.00%

timelineview's Introduction

TimelineView

TimelineView functions like a UITableView, but allows you to position cells anywhere using a custom frame (CGRect). This allows you to have irregular spacing, overlapping cells, etc... The only requirement is the data source must be sorted by min X/Y position (horizontal/vertical). Cells can be highlighted, selected, and dragged by the user. Works in the horizontal or vertical direction.

For the most part the delegate and dataSource protocol is similar to a UITableView/UICollectionView with the following additions/changes:

TimelineView uses an NSInteger for index instead of NSIndexPath. TimelineView doesn't have sections.

You must specify a content size. The TimelineView cannot assume what the content size is. You may want it to be as large as the last element, or you may want it larger to allow the user to drag elements beyond the last element.

- (CGSize)contentSizeForTimelineView:(TimelineView *)timelineView

TimelineView asks for the frame size to determine the visible index range. It makes an educated guess what the top visible index is and works backward/forward until it finds the visible range. It will try to cache requests for the frame size.

- (CGRect)timelineView:(TimelineView *)timelineView frameForCellAtIndex:(NSInteger)index

When a user drags a cell to a new position it also passes the new frame (CGRect). You can use this to update your data source. It will determine the correct destination index, provided your data source is properly sorted.

- (void)timelineView:(TimelineView *)timelineView moveItemAtIndex:(NSInteger)sourceIndex toIndex:(NSInteger)destinationIndex withFrame:(CGRect)frame

Other than what is mentioned above, the TimelineView has the same delegate calls a UITableView / UICollectionView has, so it can be used (almost) identically.

timelineview's People

Contributors

ethansinjin avatar lukescott avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.