{"id":2911,"url":"https://github.com/SwiftKickMobile/TLLayoutTransitioning","last_synced_at":"2025-08-03T12:31:40.554Z","repository":{"id":56922959,"uuid":"13461044","full_name":"SwiftKickMobile/TLLayoutTransitioning","owner":"SwiftKickMobile","description":"Enhanced transitioning between UICollectionView layouts in iOS.","archived":false,"fork":false,"pushed_at":"2017-04-08T17:22:22.000Z","size":364,"stargazers_count":355,"open_issues_count":5,"forks_count":47,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-11-25T06:14:40.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SwiftKickMobile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-10T03:23:02.000Z","updated_at":"2024-06-12T08:42:28.000Z","dependencies_parsed_at":"2022-08-20T22:10:05.529Z","dependency_job_id":null,"html_url":"https://github.com/SwiftKickMobile/TLLayoutTransitioning","commit_stats":null,"previous_names":["wtmoose/tllayouttransitioning"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKickMobile%2FTLLayoutTransitioning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKickMobile%2FTLLayoutTransitioning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKickMobile%2FTLLayoutTransitioning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKickMobile%2FTLLayoutTransitioning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SwiftKickMobile","download_url":"https://codeload.github.com/SwiftKickMobile/TLLayoutTransitioning/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228543202,"owners_count":17934444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:16:26.100Z","updated_at":"2024-12-07T00:31:07.022Z","avatar_url":"https://github.com/SwiftKickMobile.png","language":"Objective-C","funding_links":[],"categories":["UI"],"sub_categories":["Table View / Collection View","Layout","Other free courses"],"readme":"TLLayoutTransitioning\n=====================\n\nEnhanced transitioning between UICollectionView layouts in iOS.\n\n##Overview\n\nTLLayoutTransitioning provides a `TLLayoutTransition` transition layout subclass and a `UICollectionView+TLTransitioning` category that combine to solve a few problems with collection view layout transitioning:\n\n1. `UICollectionViewLayoutTransition` does not handle content offset well, often leaving cells where you don't want them. `TLTransitionLayout` provides elegant control of content offset with Minimal, Visible, Center, Top, Left, Bottom or Right placement options relative to one or more index paths.\n\n2. `UICollectionViewLayoutTransition` does not support supplementary views. `TLTransitionLayout` provides support for any supplementary view kinds specified in the initializer.\n\n3. `-[UICollectionView setCollectionViewLayout:animated:completion]` has [serious known bugs][3] in iOS7 and does not provide any animation options. TLLayoutTransitioning provides a robust alternative to this API with support for animation duration, 30+ easing curves and content offset control. This is done by using `CADisplayLink` to drive an interactive `TLTransitionLayout` as a non-interactive animation. Note that this approach may not perform as well as Core Animation with more complex cells.\n\nCheck out the demos in the Examples workspace!\n\n###TLTransitionLayout Class\n\n`TLTransitionLayout` is a subclass of `UICollectionViewTransitionLayout` that interpolates linearly between layouts and optionally between the current content offset and a specified final offset. \n\nThe final offset is specified\nby setting the `toContentOffset` property. The `UICollectionView+TLTransitioning` category\nprovides an API for calculating Minimal, Visible, Center, Top, Left, Bottom or Right offset placements relative to one or more index paths. \n\nThe basic usage is as follows:\n\n```Objective-C\n- (void)someViewControllerEventHandler\n{\n    UICollectionViewLayout *nextLayout = ...;\n    self.transitionLayout = (TLTransitionLayout *)[self.collectionView startInteractiveTransitionToCollectionViewLayout:nextLayout \n                                        completion:^(BOOL completed, BOOL finish) {\n\t    if (finish) {\n            self.collectionView.contentOffset = self.transitionLayout.toContentOffset;\n            self.transitionLayout = nil;\n\t    }\n    }];\n    NSArray *indexPaths = ...;// some selection of index paths to place\n    self.transitionLayout.toContentOffset = [self.collectionView toContentOffsetForLayout:self.transitionLayout indexPaths:indexPaths placement:TLTransitionLayoutIndexPathPlacementCenter];\n}\n\n- (UICollectionViewTransitionLayout *)collectionView:(UICollectionView *)collectionView transitionLayoutForOldLayout:(UICollectionViewLayout *)fromLayout newLayout:(UICollectionViewLayout *)toLayout\n{\n    NSArray *supplementaryKinds = ...; // optional supplementary view kinds\n    return [[TLTransitionLayout alloc] initWithCurrentLayout:fromLayout nextLayout:toLayout supplementaryKinds:supplementaryKinds];\n}\n\n```\n\nNote that the collection view will reset `contentOffset` after the transition is finalized, but as illustrated above, this can be negated by setting it back to `toContentOffset` in the completion block.\n\n####Canceling a Transition\n\nIf you want to stop the current transition to start a new one from the current position, you need a way to stop the current transition in-place. Apple provides `finishInteractiveTransition` and `cancelInteractiveTransition` to end a transition, but neither of these stops the transition in-place. So, TLLayoutTransitioning provides such a method:\n\n```Objective-C\n[self.collectionView cancelInteractiveTransitionInPlaceWithCompletion:^(){\n    // initiate new transition in the completion block\n}];\n```\n\nYou can find out if a transition is currently in progress by checking the `isInteractiveTransitionInProgress` on `UICollectionView`.\n\n###UICollectionView+TLTransitioning Category\n\nThe `UICollectionView+TLTransitioning` category provides some of useful methods for calculating for interactive transitions. In particular, the `toContentOffsetForLayout:indexPaths:placement` API calculates final content offset values to achieve Minimal, Visible, Center, Top, Left, Bottom or Right placements for one or more index paths. The expanded version of this API provides for even further fine-tuning and supports transitioning to a different collection view size and content inset:\n\n````\n- (CGPoint)toContentOffsetForLayout:(UICollectionViewTransitionLayout *)layout\n                         indexPaths:(NSArray *)indexPaths\n                          placement:(TLTransitionLayoutIndexPathPlacement)placement\n                    placementAnchor:(CGPoint)placementAnchor\n                     placementInset:(UIEdgeInsets)placementInset\n                             toSize:(CGSize)toSize\n                     toContentInset:(UIEdgeInsets)toContentInset\n````\n\n`UICollectionView+TLTransitioning` also provides an alternative to `-[UICollectionView setCollectionViewLayout:animated:completion]` for non-interactive animation between layouts with support for animation duration, 30 built-in easing curves (courtesy of Warren Moore's [AHEasing library][1]), user defined easing curves (by defining custom `AHEasingFunctions`) and content offset control. The basic transition call is as follows:\n\n```Objective-C\nTLTransitionLayout *layout = (TLTransitionLayout *)[collectionView transitionToCollectionViewLayout:toLayout duration:2 easing:QuarticEaseInOut completion:nil];\nCGPoint toOffset = [collectionView toContentOffsetForLayout:layout indexPaths:@[indexPath] placement:TLTransitionLayoutIndexPathPlacementCenter];\nlayout.toContentOffset = toOffset;\n```\n\nwhere the view controller is configured to provide an instance of `TLTransitionLayout` as described above. Check out the [Resize sample project][2] in the Examples workspace to see this in action. \n\n##Installation\n\n###CocoaPods\n\nAdd the following to your Podfile\n\n    pod 'TLLayoutTransitioning'\n\n###Carthage\n\nAdd the following to your Cartfile\n\n    github \"wtmoose/TLLayoutTransitioning\"\n\nNote that TLLayoutTransitioning has a dependency on AHEasing, which\ndoes not support Carthage. As a workaround, TLLayoutTransitioning's Cartfile uses the `wtmoose/AHEasing` fork which adds Carthage support.\n\nTo request Carthage support for the canonical AHEasing library, consider leaving a comment in favor of reopening the [Add dynamic frameworks support](https://github.com/warrenm/AHEasing/pull/19) pull request.\n\n###Manual\n\nIf you're not using a dependency manager, check out the **noframeworks** branch and copy the following files into your project:\n\n    TLTransitionLayout.h\n    TLTransitionLayout.m\n\tUICollectionView+TLTransitionAnimator.h    \n\tUICollectionView+TLTransitionAnimator.m\n\t\nAnd copy the following files from [AHEasing][4]:\n\n\teasing.h\n\teasing.c\n\n##Examples\n\nOpen the Examples workspace (not the project) to run the sample app. The following examples are included:\n\n###Resize\n\nThe Resize example combines `TLTransitionLayout` and `-[UICollectionView+TLTransitioning transitionToCollectionViewLayout:duration:easing:completion:]` as a better alternative to `-[UICollectionView setCollectionViewLayout:animated:completion]`. Experiment with different durations, easing curves and content offset options on the settings panel. Toggle \"show section headers\" to see transitioning supplementary views.\n\n###Pinch\n\nThe Pinch example demonstrates a simple pinch-driven interactive transition using `TLTransitionLayout`. The destination `contentOffset` is selected such that the initial visible cells remain centered. Or if a cell is tapped, the `contentOffset` the cell is centered.\n\n## About SwiftKick Mobile\nWe build high quality apps! [Get in touch](http://www.swiftkickmobile.com) if you need help with a project.\n\n[1]:https://github.com/warrenm/AHEasing\n[2]:https://github.com/wtmoose/TLLayoutTransitioning/blob/master/Examples/Examples/ResizeCollectionViewController.m\n[3]:http://stackoverflow.com/questions/13780138/dynamically-setting-layout-on-uicollectionview-causes-inexplicable-contentoffset\n[4]:https://github.com/warrenm/AHEasing\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftKickMobile%2FTLLayoutTransitioning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSwiftKickMobile%2FTLLayoutTransitioning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftKickMobile%2FTLLayoutTransitioning/lists"}