{"id":4258,"url":"https://github.com/c-bata/react-native-focus-scroll","last_synced_at":"2025-08-04T01:31:59.633Z","repository":{"id":57337106,"uuid":"92317758","full_name":"c-bata/react-native-focus-scroll","owner":"c-bata","description":"React Native Library to detect children that are focused on ScrollView.","archived":true,"fork":false,"pushed_at":"2017-10-03T05:21:27.000Z","size":25415,"stargazers_count":38,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-16T17:53:48.749Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-native-focus-scroll","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/c-bata.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":"2017-05-24T17:18:35.000Z","updated_at":"2024-05-27T17:07:28.000Z","dependencies_parsed_at":"2022-09-12T13:42:58.117Z","dependency_job_id":null,"html_url":"https://github.com/c-bata/react-native-focus-scroll","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Freact-native-focus-scroll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Freact-native-focus-scroll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Freact-native-focus-scroll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-bata%2Freact-native-focus-scroll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c-bata","download_url":"https://codeload.github.com/c-bata/react-native-focus-scroll/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228582487,"owners_count":17940587,"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:17:06.080Z","updated_at":"2024-12-07T08:30:28.189Z","avatar_url":"https://github.com/c-bata.png","language":"JavaScript","readme":"# react-native-focus-scroll\n\nreact-native-focus-scroll can detect which children are focused when scrolling.\n\n![Example - vertical](https://github.com/c-bata/react-native-focus-scroll/raw/master/example/anim.gif)\n![Example - horizontal](https://github.com/c-bata/react-native-focus-scroll/raw/master/example/anim-horizontal.gif)\n\n## Installation\n\n```console\n$ npm i react-native-focus-scroll\n```\n\n## TODO\n\n- [x] Add FocusScrollView\n- [x] Support horizontal scroll\n- [ ] Add an android sample\n\n## Usage\n\n```jsx\nimport React, { Component } from 'react';\nimport {\n    View,\n    Image,\n} from 'react-native';\n\nimport { FocusScrollView } from 'react-native-focus-scroll';\n\nclass BeerComponent extends Component {\n    render() {\n        let style;\n        if (this.props.isFocused) {\n            style = {opacity: 1};\n        } else {\n            style = {opacity: 0.4};\n        }\n\n        return (\n            \u003cImage style={[style, {width: 200, height: 200, position: \"absolute\"}]} source={{uri: this.props.url}} /\u003e\n        )\n    }\n}\n\nexport default class example extends Component {\n    render() {\n        const urls = [\n            \"https://github.com/c-bata/react-native-focus-scroll/blob/master/example/assets/paulaner.jpg?raw=true\",\n            \"https://github.com/c-bata/react-native-focus-scroll/blob/master/example/assets/kilkenny.jpg?raw=true\",\n            \"https://github.com/c-bata/react-native-focus-scroll/blob/master/example/assets/guiness.jpg?raw=true\",\n            \"https://github.com/c-bata/react-native-focus-scroll/blob/master/example/assets/rokko-yamatanoorochi-ipa.jpg?raw=true\",\n        ];\n\n        return (\n            \u003cView style={styles.container}\u003e\n                \u003cFocusScrollView threshold={100}\u003e\n                    {urls.map((url, index) =\u003e \u003cBeerComponent key={index} imageUrl={url} /\u003e)}\n                \u003c/FocusScrollView\u003e\n            \u003c/View\u003e\n        );\n    }\n}\n```\n\n## Properties\n\nAll props is propagate to `ScrollView` wrapped by `FocusScrollView` .\n\n\n#### threshold\n\n- type: `integer`\n- required?: optional\n- default: `100`\n\nIf the distance between the center of FocusScrollView and the center of each children exceed a threshold,\nThe item of FocusScrollView is focused.\n\n#### whetherIsFocused\n\n- type: `function(size, margin) bool {}`\n- required?: optional\n\nTo replace the judge whether the child is focused.\nThe default function is below.\n\n```jsx\nwhetherIsFocused(size, margin) {\n    const distance = Math.abs((size.y + size.height / 2) - this.getCenterY());\n    return distance \u003c margin;\n}\n```\n\n\n## LICENSE\n\n[MIT License](https://github.com/c-bata/react-native-focus-scroll/raw/master/LICENSE)\n","funding_links":[],"categories":["Components","Others"],"sub_categories":["UI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-bata%2Freact-native-focus-scroll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc-bata%2Freact-native-focus-scroll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-bata%2Freact-native-focus-scroll/lists"}