Skip to content

Commit c780b3f

Browse files
committed
update scroll-screen startManyHeight calculation split screen
1 parent 86f22ca commit c780b3f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-scroll-anim",
3-
"version": "2.7.0",
3+
"version": "2.7.1",
44
"description": "scroll-anim anim component for react",
55
"keywords": [
66
"react",

src/ScrollScreen.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class ScrollScreenClass {
7272
const t = this.scrollTop - startManyHeight;
7373
tooNum = t > 0 ? Math.ceil(t / winHeight) : Math.floor(t / winHeight);
7474
this.num = tooNum;
75-
this.toHeight = startManyHeight + tooNum * winHeight;
75+
const tc = Math.ceil(startManyHeight / winHeight);
76+
this.toHeight = (tc + tooNum) * winHeight;
7677
}
7778
}
7879
}
@@ -115,7 +116,7 @@ class ScrollScreenClass {
115116
this.rafID = -1;
116117
}
117118
getComputedStyle = (dom) => {
118-
return document.defaultView && document.defaultView.getComputedStyle ?
119+
return dom && document.defaultView && document.defaultView.getComputedStyle ?
119120
document.defaultView.getComputedStyle(dom) : {};
120121
}
121122
isScroll = (dom) => {
@@ -124,7 +125,7 @@ class ScrollScreenClass {
124125
const overflowY = style.overflowY;
125126
const isScrollOverflow = overflow === 'auto' || overflow === 'scroll' || overflow === 'overlay'
126127
|| overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'overlay';
127-
if (dom === document.body || dom === window) {
128+
if (dom === document.body || !dom) {
128129
return false;
129130
} else if (dom.scrollHeight > dom.offsetHeight
130131
&& isScrollOverflow
@@ -171,7 +172,7 @@ class ScrollScreenClass {
171172
const manyScale = manyHeight ? Math.ceil(manyHeight / winHeight) : 0;
172173
this.limitNum(-startManyScale, mapped.length - 1 + manyScale);
173174
const currentDom = mapped[this.num];
174-
this.toHeight = currentDom ? currentDom.offsetTop : startManyHeight + this.num * winHeight;
175+
this.toHeight = currentDom ? currentDom.offsetTop : (startManyScale + this.num) * winHeight;
175176
this.toHeight = this.toHeight < 0 ? 0 : this.toHeight;
176177
this.toHeight = this.toHeight > docHeight - winHeight ?
177178
(docHeight - winHeight) : this.toHeight;

0 commit comments

Comments
 (0)