react-infinite-virtual-scroll
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -15,2 +15,3 @@ "use strict"; | ||
var React = require("react"); | ||
var MAX_LOOP_COUNT = 10000; | ||
//AIV stands for async iterator virtualization | ||
@@ -65,3 +66,6 @@ function InfiniteVirtualScroll(props) { | ||
}; | ||
while (container.scrollTop < state.topSpace) { | ||
var loopCount = 0; | ||
// scrollTop must be clamped since in some browser it may drop below zero | ||
var scrollTop = Math.max(0, container.scrollTop); | ||
while (scrollTop < state.topSpace && loopCount++ < MAX_LOOP_COUNT) { | ||
//scroll to top, -start | ||
@@ -75,3 +79,3 @@ // console.log("head in") | ||
} | ||
while (lastChild && container.scrollHeight - container.clientHeight - container.scrollTop > state.bottomSpace + lastChild.clientHeight) { | ||
while (lastChild && container.scrollHeight - container.clientHeight - scrollTop > state.bottomSpace + lastChild.clientHeight && loopCount++ < MAX_LOOP_COUNT) { | ||
//scroll to top, -end | ||
@@ -85,3 +89,3 @@ // console.log("tail out") | ||
} | ||
while (firstChild && container.scrollTop > state.topSpace + firstChild.clientHeight) { | ||
while (firstChild && scrollTop > state.topSpace + firstChild.clientHeight && loopCount++ < MAX_LOOP_COUNT) { | ||
//scroll to bottom, +start | ||
@@ -95,3 +99,3 @@ // console.log("head out") | ||
} | ||
while (container.scrollHeight - container.clientHeight - container.scrollTop < state.bottomSpace) { | ||
while (container.scrollHeight - container.clientHeight - scrollTop < state.bottomSpace && loopCount++ < MAX_LOOP_COUNT) { | ||
//scroll to bottom, +end | ||
@@ -111,2 +115,5 @@ if (state.end < state.data.length) { | ||
} | ||
if (loopCount > MAX_LOOP_COUNT) { | ||
throw new Error("Loop count exceeded, it's a bug, please file an issue"); | ||
} | ||
shouldRerender && rerender({}); | ||
@@ -125,3 +132,3 @@ } | ||
var viewPortRef = React.useRef(null); | ||
return React.createElement("div", { style: __assign({}, props.style, { overflow: "auto" }) }, | ||
return React.createElement("div", { style: __assign({ overflow: "auto", WebkitOverflowScrolling: "touch" }, props.style) }, | ||
React.createElement("div", { ref: viewPortRef, style: { | ||
@@ -128,0 +135,0 @@ marginTop: state.topSpace, |
{ | ||
"name": "react-infinite-virtual-scroll", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "infinite virtual scroll with react and async iterator", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -17,2 +17,3 @@ # React Infinite Virtual Scroll | ||
# How | ||
*Important: You Must set a fixed height via style prop for it to work!* | ||
@@ -19,0 +20,0 @@ ```tsx |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
18846
270
55