lazy-render-virtual-scroll 1.0.2 → 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 +52 -53
  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
@@ -242,30 +242,29 @@ const state = engine.getState();
242
242
 
243
243
  ## Performance Benefits
244
244
 
245
- 1. **Efficient Rendering**: Sirf visible items render hote hain
246
- 2. **Memory Management**: Unnecessary items remove ho jaate hain
247
- 3. **Smart Prefetch**: Data提前 load hota hai
248
- 4. **Smooth Scrolling**: Lag nahi aati
245
+ 1. **Efficient Rendering**: Only visible items are rendered
246
+ 2. **Memory Management**: Unnecessary items are removed from memory
247
+ 3. **Smart Prefetch**: Data loads ahead of user scroll
248
+ 4. **Smooth Scrolling**: Overscan provides seamless experience
249
249
 
250
- ## Performance Benefits
250
+ ## Installation
251
251
 
252
- 1. **Efficient Rendering**: Sirf visible items render hote hain
253
- 2. **Memory Management**: Unnecessary items remove ho jaate hain
254
- 3. **Smart Prefetch**: Data提前 load hota hai
255
- 4. **Smooth Scrolling**: Overscan provides seamless experience
252
+ ```bash
253
+ npm i lazy-render-virtual-scroll
254
+ ```
256
255
 
257
256
  ## When to Use lazy-render
258
257
 
259
258
  ### Use when:
260
- - 1000+ items ko render karna hai
261
- - Infinite scroll functionality chahiye
259
+ - Rendering 1000+ items
260
+ - Need infinite scroll functionality
262
261
  - Dashboard widgets with large data sets
263
262
  - Chat applications with message history
264
263
  - Feed applications with posts/comments
265
264
  - Any scenario with large data that needs smooth scrolling
266
265
 
267
266
  ### Avoid when:
268
- - Less than 100 items ko render karna hai
267
+ - Rendering less than 100 items
269
268
  - Static content with no scrolling
270
269
  - Simple pages without performance concerns
271
270
 
@@ -280,10 +279,10 @@ const state = engine.getState();
280
279
 
281
280
  ## Performance Tips
282
281
 
283
- 1. Consistent item heights use karo for best performance
284
- 2. Buffer size adjust karo content complexity ke hisab se
285
- 3. Proper error handling implement karo
286
- 4. Skeleton loaders use karo better UX ke liye
282
+ 1. Use consistent item heights for best performance
283
+ 2. Adjust buffer size based on content complexity
284
+ 3. Implement proper error handling
285
+ 4. Use skeleton loaders for better UX
287
286
  5. Use overscan for smoother scrolling experience
288
287
 
289
288
  ## Examples
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lazy-render-virtual-scroll",
3
- "version": "1.0.2",
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",