lazy-render-virtual-scroll 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +37 -37
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -36,31 +36,31 @@ A framework-agnostic virtual scrolling and lazy rendering solution that efficien
36
36
  ## Installation
37
37
 
38
38
  ```bash
39
- npm install lazy-render
39
+ npm install lazy-render-virtual-scroll
40
40
  ```
41
41
 
42
- ## Quick Start - Hinglish Guide
42
+ ## Quick Start - English Guide
43
43
 
44
- ### React Adapter Ka Istemal
44
+ ### React Adapter Usage
45
45
 
46
46
  ```tsx
47
47
  import React, { useState } from 'react';
48
- import { LazyList } from 'lazy-render';
48
+ import { LazyList } from 'lazy-render-virtual-scroll';
49
49
 
50
50
  const MyComponent = () => {
51
51
  const [items, setItems] = useState<any[]>([]);
52
52
  const [hasMore, setHasMore] = useState(true);
53
53
 
54
- // Data fetch karne ka function
54
+ // Function to fetch data
55
55
  const fetchMore = async () => {
56
- // API call simulate kar rahe hain
56
+ // Simulate API call
57
57
  const newItems = await fetchItems(items.length, 20);
58
58
  setItems(prev => [...prev, ...newItems]);
59
59
  setHasMore(newItems.length > 0);
60
60
  return newItems;
61
61
  };
62
62
 
63
- // Har item ko render karne ka function
63
+ // Function to render each item
64
64
  const renderItem = (item: any, index: number) => (
65
65
  <div style={{ height: '50px', borderBottom: '1px solid #eee' }}>
66
66
  Item {index}: {item.name}
@@ -69,11 +69,11 @@ const MyComponent = () => {
69
69
 
70
70
  return (
71
71
  <LazyList
72
- items={items} // Tumhara data array
73
- itemHeight={50} // Har item ki height
74
- viewportHeight={400} // Container ki visible height
75
- fetchMore={fetchMore} // Data fetch karne ka function
76
- renderItem={renderItem} // Item render karne ka function
72
+ items={items} // Your data array
73
+ itemHeight={50} // Height of each item
74
+ viewportHeight={400} // Visible height of container
75
+ fetchMore={fetchMore} // Function to fetch data
76
+ renderItem={renderItem} // Function to render items
77
77
  bufferSize={5} // Buffer items (extra render)
78
78
  overscan={2} // Additional buffer for smooth scrolling
79
79
  />
@@ -81,11 +81,11 @@ const MyComponent = () => {
81
81
  };
82
82
  ```
83
83
 
84
- ### Hook Ka Istemal
84
+ ### Hook Usage
85
85
 
86
86
  ```tsx
87
87
  import React, { useState } from 'react';
88
- import { useLazyList } from 'lazy-render';
88
+ import { useLazyList } from 'lazy-render-virtual-scroll';
89
89
 
90
90
  const MyCustomComponent = () => {
91
91
  const [items, setItems] = useState<any[]>([]);
@@ -108,21 +108,21 @@ const MyCustomComponent = () => {
108
108
  }
109
109
  });
110
110
 
111
- // Sirf visible items ko nikal rahe hain
111
+ // Extract only visible items
112
112
  const visibleItems = items.slice(visibleRange.start, visibleRange.end);
113
113
 
114
114
  return (
115
115
  <div
116
- ref={setContainerRef} // Scroll detection ke liye
116
+ ref={setContainerRef} // For scroll detection
117
117
  style={{
118
118
  height: '400px',
119
119
  overflowY: 'auto'
120
120
  }}
121
121
  >
122
- {/* Top padding for scroll position maintain karne ke liye */}
122
+ {/* Top padding to maintain scroll position */}
123
123
  <div style={{ height: `${visibleRange.start * 50}px` }} />
124
124
 
125
- {/* Visible items render */}
125
+ {/* Render visible items */}
126
126
  {visibleItems.map((item, index) => (
127
127
  <div
128
128
  key={visibleRange.start + index}
@@ -156,39 +156,39 @@ const MyCustomComponent = () => {
156
156
  };
157
157
  ```
158
158
 
159
- ## Package Kaise Kam Karta Hai - Step by Step
159
+ ## How Package Works - Step by Step
160
160
 
161
- ### 1. Install Karo
161
+ ### 1. Install
162
162
  ```bash
163
163
  npm install lazy-render
164
164
  ```
165
165
 
166
- ### 2. Import Karo
166
+ ### 2. Import
167
167
  ```javascript
168
- import { LazyList, useLazyList } from 'lazy-render';
168
+ import { LazyList, useLazyList } from 'lazy-render-virtual-scroll';
169
169
  ```
170
170
 
171
171
  ### 3. Basic Usage
172
- - Tumhara data array lelo
173
- - Item ki height batado
174
- - Container ki height batado
175
- - FetchMore function provide karo
176
- - RenderItem function provide karo
172
+ - Get your data array
173
+ - Specify item height
174
+ - Specify container height
175
+ - Provide fetchMore function
176
+ - Provide renderItem function
177
177
 
178
178
  ### 4. How It Works Internally
179
- - **Scroll Detection**: User scroll karta hai toh detect hota hai
180
- - **Range Calculation**: Visible range calculate hota hai (kitne items dikh rahe hain)
181
- - **Smart Rendering**: Sirf visible items render hote hain
182
- - **Prefetch Logic**: User end tak pahunchne se pehle data fetch hota hai
183
- - **Memory Cleanup**: Off-screen items remove ho jaate hain
179
+ - **Scroll Detection**: Detects when user scrolls
180
+ - **Range Calculation**: Calculates visible range (which items are visible)
181
+ - **Smart Rendering**: Only renders visible items
182
+ - **Prefetch Logic**: Fetches data before user reaches the end
183
+ - **Memory Cleanup**: Removes off-screen items
184
184
 
185
185
  ### 5. Configuration Options
186
- - `itemHeight`: Har item ki height in pixels
187
- - `viewportHeight`: Container ki visible height
188
- - `bufferSize`: Extra items render (default: 5)
186
+ - `itemHeight`: Height of each item in pixels
187
+ - `viewportHeight`: Visible height of container
188
+ - `bufferSize`: Extra items to render (default: 5)
189
189
  - `overscan`: Additional buffer for smooth scrolling (default: 2)
190
- - `fetchMore`: Data fetch karne ka function
191
- - `renderItem`: Item render karne ka function
190
+ - `fetchMore`: Function to fetch data
191
+ - `renderItem`: Function to render items
192
192
 
193
193
  ### 6. Hook Return Values
194
194
  - `visibleRange`: Currently visible items range
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lazy-render-virtual-scroll",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A framework-agnostic virtual scrolling and lazy rendering solution",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",