{"id":16807096,"url":"https://github.com/toshi0383/horizontalstickyheaderlayout","last_synced_at":"2025-07-22T10:37:30.840Z","repository":{"id":55871325,"uuid":"106027453","full_name":"toshi0383/HorizontalStickyHeaderLayout","owner":"toshi0383","description":"Horizontal UICollectionViewLayout with Sticky HeaderView","archived":false,"fork":false,"pushed_at":"2023-10-06T04:52:31.000Z","size":94,"stargazers_count":88,"open_issues_count":0,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-01T11:53:40.234Z","etag":null,"topics":["carthage","headerview","ios","swift","tvos","uicollectionview","uicollectionviewlayout"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/toshi0383.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-06T16:38:09.000Z","updated_at":"2025-04-01T11:10:48.000Z","dependencies_parsed_at":"2024-10-27T11:57:39.200Z","dependency_job_id":"4ce6c3ad-6539-4d25-9cfc-6de6488cb6a3","html_url":"https://github.com/toshi0383/HorizontalStickyHeaderLayout","commit_stats":{"total_commits":67,"total_committers":3,"mean_commits":"22.333333333333332","dds":0.04477611940298509,"last_synced_commit":"9e7cfd012910c3fe73a4a5fdb49fd9fe68d2ab7c"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/toshi0383/HorizontalStickyHeaderLayout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshi0383%2FHorizontalStickyHeaderLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshi0383%2FHorizontalStickyHeaderLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshi0383%2FHorizontalStickyHeaderLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshi0383%2FHorizontalStickyHeaderLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toshi0383","download_url":"https://codeload.github.com/toshi0383/HorizontalStickyHeaderLayout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshi0383%2FHorizontalStickyHeaderLayout/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266477152,"owners_count":23935390,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["carthage","headerview","ios","swift","tvos","uicollectionview","uicollectionviewlayout"],"created_at":"2024-10-13T09:52:56.786Z","updated_at":"2025-07-22T10:37:30.815Z","avatar_url":"https://github.com/toshi0383.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HorizontalStickyHeaderLayout\n\nHorizontal UICollectionViewLayout with Sticky HeaderView\n\n![](https://github.com/toshi0383/assets/blob/master/HorizontalStickyHeaderLayout/hshl-iphone7.gif)\n\n![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20tvOS-blue.svg)\n[![Swift Package Manager](https://img.shields.io/badge/Swift_Package_Manager-compatible-brightgreen.svg)](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app)\n[![pod](https://img.shields.io/cocoapods/v/HorizontalStickyHeaderLayout.svg?style=flat)](https://cocoapods.org/pods/HorizontalStickyHeaderLayout)\n[![License](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat\n)](http://mit-license.org)\n\n# Requirements\n- iOS9+\n- tvOS9+\n\n# How to use\nJust implement these 5 required delegate methods.\n\n```swift\nextension ViewController: HorizontalStickyHeaderLayoutDelegate {\n    private enum Const {\n        static let headerSize = CGSize(width: 100, height: 38)\n        static let itemSize0  = CGSize(width: 50, height: 50)\n        static let itemSize1  = CGSize(width: 80, height: 80)\n        static let headerLeft: CGFloat = 8\n    }\n    func collectionView(_ collectionView: UICollectionView, hshlSizeForItemAtIndexPath indexPath: IndexPath) -\u003e CGSize {\n        if indexPath.section % 2 == 0 {\n            return Const.itemSize0\n        } else {\n            return Const.itemSize1\n        }\n    }\n    func collectionView(_ collectionView: UICollectionView, hshlSizeForHeaderAtSection section: Int) -\u003e CGSize {\n        return Const.headerSize\n    }\n    func collectionView(_ collectionView: UICollectionView, hshlHeaderInsetsAtSection section: Int) -\u003e UIEdgeInsets {\n        return UIEdgeInsets(top: 0, left: Const.headerLeft, bottom: 20, right: 20)\n    }\n    func collectionView(_ collectionView: UICollectionView, hshlMinSpacingForCellsAtSection section: Int) -\u003e CGFloat {\n        return 20\n    }\n    func collectionView(_ collectionView: UICollectionView, hshlSectionInsetsAtSection section: Int) -\u003e UIEdgeInsets {\n        return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: section == 4 ? 0 : 20)\n    }\n}\n```\n\nOptionally you can define `contentInset` for outer margin.\n\n![](https://github.com/toshi0383/assets/raw/master/HorizontalStickyHeaderLayout/layout-definitions.png)\n\nSee [Example](Example) for detail.\n\n# Animated header Y position for tvOS for free!\n![](https://github.com/toshi0383/assets/blob/master/HorizontalStickyHeaderLayout/sticky-animated-header-for-tvos.gif)\n\n## How to implement\n- On focus, call `updatePoppingHeaderIndexPaths()` to recalculate the popping header indexPaths to get the latest indexPaths.\n- Listen to pop indexPaths change on scroll by implementing `collectionView(_:,hshlDidUpdatePoppingHeaderIndexPaths:)` delegate method.\n- animate container view of your header view.\n\nSee [Example](Example) for recommended implementation.\n\n```swift\n    // Either in UICollectionViewDelegate or this override method.\n    override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {\n        layout.updatePoppingHeaderIndexPaths()\n        let (pop, unpop) = self.getHeaders(poppingHeadersIndexPaths: self.layout.poppingHeaderIndexPaths)\n        UIView.animate(withDuration: Const.unpopDuration, delay: 0, options: [.curveEaseOut], animations: {\n            unpop.forEach { $0.unpopHeader() }\n        }, completion: nil)\n        coordinator.addCoordinatedAnimations({\n            pop.forEach { $0.popHeader() }\n        }, completion: nil)\n        super.didUpdateFocus(in: context, with: coordinator)\n    }\n\n    func collectionView(_ collectionView: UICollectionView, hshlDidUpdatePoppingHeaderIndexPaths indexPaths: [IndexPath]) {\n        let (pop, unpop) = self.getHeaders(poppingHeadersIndexPaths: self.layout.poppingHeaderIndexPaths)\n        UIView.animate(withDuration: Const.unpopDuration, delay: 0, options: [.curveEaseOut], animations: {\n            unpop.forEach { $0.unpopHeader() }\n            pop.forEach { $0.popHeader() }\n        }, completion: nil)\n    }\n```\n\n# Install\n## SwiftPM\n\nInstall via Xcode.\n\n## CocoaPods\n```\npod \"HorizontalStickyHeaderLayout\"\n```\n\n# License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoshi0383%2Fhorizontalstickyheaderlayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoshi0383%2Fhorizontalstickyheaderlayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoshi0383%2Fhorizontalstickyheaderlayout/lists"}