{"id":31920221,"url":"https://github.com/iamgerwin/nova-infinite-scroll","last_synced_at":"2025-10-13T21:56:32.709Z","repository":{"id":317550888,"uuid":"1067956962","full_name":"iamgerwin/nova-infinite-scroll","owner":"iamgerwin","description":"Laravel Nova Infinite Scroll package supporting versions 3, 4, and 5. Enables smooth, automatic content loading as you scroll, enhancing UX for Nova resource index views","archived":false,"fork":false,"pushed_at":"2025-10-01T16:42:14.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-01T17:17:34.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/iamgerwin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"iamgerwin"}},"created_at":"2025-10-01T16:27:15.000Z","updated_at":"2025-10-01T16:42:18.000Z","dependencies_parsed_at":"2025-10-01T17:17:40.233Z","dependency_job_id":"2c4f55cb-60a1-4106-92e1-8918b90f1103","html_url":"https://github.com/iamgerwin/nova-infinite-scroll","commit_stats":null,"previous_names":["iamgerwin/nova-infinite-scroll"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/iamgerwin/nova-infinite-scroll","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamgerwin%2Fnova-infinite-scroll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamgerwin%2Fnova-infinite-scroll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamgerwin%2Fnova-infinite-scroll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamgerwin%2Fnova-infinite-scroll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamgerwin","download_url":"https://codeload.github.com/iamgerwin/nova-infinite-scroll/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamgerwin%2Fnova-infinite-scroll/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017013,"owners_count":26085951,"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-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":[],"created_at":"2025-10-13T21:56:27.647Z","updated_at":"2025-10-13T21:56:32.704Z","avatar_url":"https://github.com/iamgerwin.png","language":"PHP","readme":"# Laravel Nova Infinite Scroll\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/iamgerwin/nova-infinite-scroll.svg?style=flat-square)](https://packagist.org/packages/iamgerwin/nova-infinite-scroll)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/iamgerwin/nova-infinite-scroll/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/iamgerwin/nova-infinite-scroll/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/iamgerwin/nova-infinite-scroll/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/iamgerwin/nova-infinite-scroll/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/iamgerwin/nova-infinite-scroll.svg?style=flat-square)](https://packagist.org/packages/iamgerwin/nova-infinite-scroll)\n\nSeamless infinite scrolling for Laravel Nova resources. Automatically loads more records as users scroll, eliminating traditional pagination and providing a smooth, modern browsing experience. Compatible with Nova 3, 4, and 5.\n\nPerfect for resources with many records where traditional pagination feels clunky. Works harmoniously with filters, search, and sorting – everything just works! ✨\n\n## Features\n\n- 🚀 **Plug \u0026 Play**: Add one trait and you're done\n- 🎯 **Smart Loading**: Only fetches what's needed, when it's needed\n- 🔍 **Filter Friendly**: Works seamlessly with Nova's filters and search\n- 🎨 **Theme Aware**: Respects Nova's light and dark modes\n- ⚡ **Performance**: Low memory footprint with efficient query building\n- 🔧 **Highly Configurable**: Customize per-resource or globally\n- 📱 **Touch Optimized**: Smooth scrolling on mobile devices\n- 🔄 **Auto-Reset**: Automatically resets on filter/search changes\n\n## Requirements\n\n- PHP 8.2 or higher\n- Laravel 9.x, 10.x, 11.x, or 12.x\n- Laravel Nova 3.x, 4.x, or 5.x\n\n## Installation\n\nInstall the package via composer:\n\n```bash\ncomposer require iamgerwin/nova-infinite-scroll\n```\n\nOptionally, publish the configuration file:\n\n```bash\nphp artisan vendor:publish --tag=\"nova-infinite-scroll-config\"\n```\n\nThe package automatically registers itself with Nova – no additional setup required!\n\n## Quick Start\n\n### Basic Usage\n\nAdd the `HasInfiniteScroll` trait to your Nova Resource:\n\n```php\n\u003c?php\n\nnamespace App\\Nova;\n\nuse Iamgerwin\\NovaInfiniteScroll\\Traits\\HasInfiniteScroll;\nuse Laravel\\Nova\\Resource;\n\nclass User extends Resource\n{\n    use HasInfiniteScroll;\n\n    // Your resource definition...\n}\n```\n\nThat's it! Your resource now supports infinite scrolling. 🎉\n\n### Configuration\n\nThe package includes sensible defaults, but you can customize everything via the config file:\n\n```php\nreturn [\n    // Enable/disable infinite scroll globally (not recommended)\n    // Set to false to only enable for resources with HasInfiniteScroll trait\n    'enabled' =\u003e false,\n\n    // Number of records to load per batch\n    'per_page' =\u003e 25,\n\n    // Distance from bottom (in pixels) to trigger loading\n    'threshold' =\u003e 200,\n\n    // Customize loading messages\n    'loading_text' =\u003e 'Loading more records...',\n    'end_text' =\u003e 'All records loaded',\n\n    // Auto-enable on resource index pages with the trait\n    'auto_enable' =\u003e true,\n\n    // Exclude specific resources (when global enabled is true)\n    'excluded_resources' =\u003e [\n        // App\\Nova\\User::class,\n    ],\n];\n```\n\n### Per-Resource Configuration\n\nOverride settings for individual resources:\n\n```php\nclass Article extends Resource\n{\n    use HasInfiniteScroll;\n\n    public static function infiniteScrollPerPage(): int\n    {\n        return 50; // Load 50 articles at a time\n    }\n\n    public static function infiniteScrollThreshold(): int\n    {\n        return 300; // Trigger loading 300px from bottom\n    }\n\n    public static function infiniteScrollEnabled(): bool\n    {\n        return auth()-\u003euser()-\u003eprefersInfiniteScroll ?? true;\n    }\n}\n```\n\n## How It Works\n\nNova Infinite Scroll uses the Intersection Observer API to detect when users scroll near the bottom of the resource table. When triggered:\n\n1. **Checks State**: Ensures not already loading and more records exist\n2. **Fetches Data**: Makes an API request for the next batch of records\n3. **Appends Results**: Seamlessly adds new records to the existing list\n4. **Repeats**: Continues until all records are loaded\n\nThe magic happens behind the scenes with Vue.js components that integrate directly with Nova's resource index pages. Filters, search, and sorting automatically reset the infinite scroll state – no manual intervention needed!\n\n## Advanced Usage\n\n### Conditionally Enable Infinite Scroll\n\n```php\npublic static function infiniteScrollEnabled(): bool\n{\n    // Only for admins\n    return auth()-\u003euser()-\u003eisAdmin();\n\n    // Or based on resource count\n    // return static::newModel()-\u003ecount() \u003e 100;\n}\n```\n\n### Custom Batch Sizes Based on Context\n\n```php\npublic static function infiniteScrollPerPage(): int\n{\n    // Smaller batches on mobile\n    if (request()-\u003eheader('User-Agent') \u0026\u0026 str_contains(request()-\u003eheader('User-Agent'), 'Mobile')) {\n        return 15;\n    }\n\n    return 30;\n}\n```\n\n### Exclude Resources Programmatically\n\nIn your `config/nova-infinite-scroll.php`:\n\n```php\n'excluded_resources' =\u003e [\n    \\App\\Nova\\Resources\\HeavyResource::class,\n    \\App\\Nova\\Resources\\RealtimeData::class,\n],\n```\n\n## Performance Tips\n\n1. **Optimize Your Queries**: Use eager loading to prevent N+1 queries\n2. **Index Database Columns**: Ensure frequently filtered/sorted columns are indexed\n3. **Adjust Batch Size**: Larger batches = fewer requests, but more data transferred\n4. **Use Threshold Wisely**: Lower threshold = earlier loading (smoother UX, more requests)\n\n## Troubleshooting\n\n### Infinite scroll not working?\n\n- **Most Common**: Ensure the `HasInfiniteScroll` trait is added to your Resource\n- Check browser console for JavaScript errors\n- If using global mode, verify `nova-infinite-scroll.enabled` is `true` in config\n- Confirm the resource isn't in `excluded_resources`\n- Clear browser cache and reload the page\n\n### Default pagination not working?\n\nIf you're experiencing issues with default pagination (clicking \"Next\" does nothing), ensure you're using the latest version. Versions prior to 1.1.0 had a critical bug that broke pagination for resources without the trait.\n\n### Loading indicator doesn't show?\n\n- Check if Nova's default styles are loaded\n- Verify JavaScript assets are being served\n- Try clearing Nova's compiled assets: `php artisan nova:publish`\n\n### Performance issues?\n\n- Reduce `per_page` value for fewer records per batch\n- Add database indexes on frequently queried columns\n- Consider excluding resources with complex computed fields\n\n## Testing\n\nRun the test suite:\n\n```bash\ncomposer test\n```\n\nRun tests with coverage:\n\n```bash\ncomposer test-coverage\n```\n\nCheck code style:\n\n```bash\ncomposer format\n```\n\nRun static analysis:\n\n```bash\ncomposer analyse\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on recent changes.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate and adhere to PSR-12 coding standards.\n\n## Security\n\nIf you discover any security-related issues, please email iamgerwin@live.com instead of using the issue tracker.\n\n## Credits\n\n- [Gerwin](https://github.com/iamgerwin) - Creator and maintainer\n- Inspired by [Filament Infinite Scroll](https://github.com/fibtegis/filament-infinite-scroll)\n- Built with [Spatie's Laravel Package Tools](https://github.com/spatie/laravel-package-tools)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n---\n\nMade with ❤️ for the Laravel Nova community\n","funding_links":["https://github.com/sponsors/iamgerwin"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamgerwin%2Fnova-infinite-scroll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamgerwin%2Fnova-infinite-scroll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamgerwin%2Fnova-infinite-scroll/lists"}