{"id":3949,"url":"https://github.com/jmurzy/react-native-foldview","last_synced_at":"2025-05-15T10:06:29.223Z","repository":{"id":57337098,"uuid":"71099152","full_name":"jmurzy/react-native-foldview","owner":"jmurzy","description":"FoldView implemented in JavaScript ⛱","archived":false,"fork":false,"pushed_at":"2018-07-28T17:08:18.000Z","size":1127,"stargazers_count":1971,"open_issues_count":5,"forks_count":183,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-04-14T15:02:36.685Z","etag":null,"topics":["react-native"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/jmurzy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-17T04:09:51.000Z","updated_at":"2025-02-05T09:23:14.000Z","dependencies_parsed_at":"2022-09-12T13:42:55.866Z","dependency_job_id":null,"html_url":"https://github.com/jmurzy/react-native-foldview","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmurzy%2Freact-native-foldview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmurzy%2Freact-native-foldview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmurzy%2Freact-native-foldview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmurzy%2Freact-native-foldview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmurzy","download_url":"https://codeload.github.com/jmurzy/react-native-foldview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319719,"owners_count":22051073,"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":["react-native"],"created_at":"2024-01-05T20:16:56.264Z","updated_at":"2025-05-15T10:06:29.170Z","avatar_url":"https://github.com/jmurzy.png","language":"JavaScript","funding_links":[],"categories":["Components","Index","JavaScript","Others"],"sub_categories":["UI","Custom Components and Cool Shit"],"readme":"# React Native FoldView [![Medium](https://img.shields.io/badge/blog-medium-brightgreen.svg)](https://commitocracy.com/implementing-foldview-in-react-native-e970011f98b8) [![CircleCI](https://img.shields.io/circleci/project/jmurzy/react-native-foldview/master.svg?style=flat-square)](https://circleci.com/gh/jmurzy/react-native-foldview) [![npm version](https://img.shields.io/npm/v/react-native-foldview.svg?style=flat-square)](https://www.npmjs.com/package/react-native-foldview) [![npm](https://img.shields.io/npm/l/react-native-foldview.svg?style=flat-square)](https://github.com/jmurzy/react-native-foldview/blob/master/LICENSE.md)\n\nFoldingCell implementation in JavaScript. This project was inspired by the folding cell animation seen on [Dribbble](https://dribbble.com/shots/2121350-Delivery-Card).\n\n\n\u003cimg align=\"right\" width=\"360px\" src=\"https://raw.githubusercontent.com/jmurzy/react-native-foldview/master/.github/screenshot.gif\"\u003e\n\n#### Questions?\nFeel free to reach out to me on Twitter [@jmurzy](https://twitter.com/jmurzy).\n\n### Read it on Medium\nTo learn more about how FoldView was implemented, check out the article on Medium: [Implementing FoldView in React Native](https://commitocracy.com/implementing-foldview-in-react-native-e970011f98b8).\n\n### Example\nThe demo app from the GIF can be found at `examples/Simple`.\n\nTo build and run the example app:\n\n```bash\ngit clone https://github.com/jmurzy/react-native-foldview\n\ncd react-native-foldview/examples/Simple\nnpm install\n```\n\nTo deploy to iOS simulator:\n\n```bash\nnpm run ios\n```\n\n### Installation\n\n#### Using npm:\n\n```sh\n$ npm install --save react-native-foldview\n```\n\n#### Using yarn:\n\n```sh\n$ yarn add react-native-foldview\n```\n\n### Usage\n\n```jsx\nimport React, { Component } from 'react';\n\nimport FoldView from 'react-native-foldview';\n\nconst Frontface = (props) =\u003e (/*...*/);\nconst Backface = (props) =\u003e (/*...*/);\nconst Base = (props) =\u003e (/*...*/);\n\nexport default class Row extends Component {\n\n  constructor(props) {\n    super(props);\n\n    this.state = {\n      expanded: false,\n    };\n  }\n\n  componentWillMount() {\n    this.flip = this.flip.bind(this);\n  }\n\n  flip() {\n    this.setState({\n      expanded: !this.state.expanded,\n    });\n  }\n\n  renderFrontface() {\n    return (\n      \u003cFrontface /\u003e\n    );\n  }\n\n  renderBackface() {\n    /**\n     * You can nest \u003cFoldView\u003es here to achieve the folding effect shown in the GIF above.\n     * A reference implementation can be found in examples/Simple.\n     */\n    return (\n      \u003cBackface /\u003e\n    );\n  }\n\n  render() {\n    return (\n      \u003cFoldView\n        expanded={this.state.expanded}\n        renderBackface={this.renderBackface}\n        renderFrontface={this.renderFrontface}\n      \u003e\n        \u003cBase /\u003e\n      \u003c/FoldView\u003e\n    );\n  }\n}\n\n```\n\n#### Props\n\n| Prop | Type | Description |\n|---|---|---|\n|**`children`**|`ReactElement\u003cany\u003e`|React Element(s) to render.|\n|**`flipDuration`**|`?number`|Length of flip animation in milliseconds. _Default 280._|\n|**`renderBackface`**|`() =\u003e ReactElement\u003cany\u003e`|Callback that renders a backface.|\n|**`renderFrontface`**|`() =\u003e ReactElement\u003cany\u003e`|Callback that renders a frontface.|\n|**`renderLoading`**|`?() =\u003e ReactElement\u003cany\u003e`|Callback that renders a temporary view to display before base layout occurs. If not provided, `renderFrontface` is used instead.|\n\n#### Root-only Props\n\nFoldViews can be nested. The following props can only be set on the root `FoldView`.\n\n| Prop | Type | Description |\n|---|---|---|\n|**`collapse`**|`?(foldviews: Array\u003cIFoldView\u003e) =\u003e Promise`|Called when FoldView should collapse allowing you to have control over which FoldViews(s) to collapse. Default behavior is to wait until a FoldView is collapsed before collapsing the next one.|\n|**`expand`**|`?(foldviews: Array\u003cIFoldView\u003e) =\u003e Promise`|Called when FoldView should expand allowing you to have control over which FoldView(s) to expand. Default behavior is to wait until a FoldView is expanded before expanding the next one.|\n|**`expanded`**|`boolean`|Allows you to expand and collapse the FoldView content.|\n|**`onAnimationEnd`**|`?(duration: number, height: number) =\u003e void`|Called when a collapse animation ends.|\n|**`onAnimationStart`**|`?(duration: number, height: number) =\u003e void`|Called before an expand animation starts.|\n|**`perspective`**|`?number`|Defines the space within which the 3D animation occurs.|\n\n### Advanced Usage\nYou can customize the behavior of expand and collapse animations using the `expand` and `collapse` props on the root `FoldView`. For example, it's very much possible to collapse all FoldViews in a given stack altogether rather than one by one. You can do so as follows:\n\n```jsx\nconst collapse = async (foldViews) =\u003e {\n  /**\n   * Internally, FoldView turns off rasterization when collapsed as an optimization to decrease\n   * memory usage. It's important to wrap your calls in a `Promise` here to avoid early disabling\n   * of rasterization.\n   */\n  await Promise.all(foldViews.map(foldView =\u003e foldView.collapse()));\n}\n\n\u003cFoldView\n  collapse={collapse}\n  renderBackface={/* ... */}\n  renderFrontface={/* ... */}\n\u003e\n  { /* ... */ }\n\u003c/FoldView\u003e\n```\n\n### Platform Support\nThis library heavily depends on the `overflow` style property. Unfortunately, `overflow` defaults to `hidden` on Android and cannot be changed. Although it looks like a [possible](https://github.com/facebook/react-native/issues/3198#issuecomment-241867280) [fix](https://github.com/facebook/react-native/tree/master/ReactAndroid/src/main/java/com/facebook/react/flat) is in the making, currently, FoldingView is only supported on iOS.\n\n### Contributing\nContributions are very welcome: bug fixes, features, documentation, tests. Just make sure the CI is 👌.\n\n#### Hacking\n\nUnfortunately, React Native packager does not support symlinking so you cannot use [`npm link`](https://docs.npmjs.com/cli/link) when hacking on this library. You can learn more about that, [here](https://productpains.com/post/react-native/symlink-support-for-packager/).\n\nThe library code is specified as a [local dependency](local dependency) in the example's `package.json`. In order to hack on the library code, you need to sync it into `examples/Simple/node_modules`. To do so, run:\n\n```js\nnpm run watch\n```\n\nThis will automatically watch the `src` directory and sync your changes into `examples/Simple/node_modules` every time something changes.\n\n#### License\n\nAll pull requests that get merged will be made available under [the MIT license](https://github.com/jmurzy/react-native-foldview/blob/master/LICENSE.md), as the rest of the repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmurzy%2Freact-native-foldview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmurzy%2Freact-native-foldview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmurzy%2Freact-native-foldview/lists"}