Skip to content

Commit aa957b9

Browse files
committed
handle when className values are empty strings
1 parent d33887c commit aa957b9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,18 @@ Perhaps use a polyfill like: https://cdn.polyfill.io/v2/polyfill.js?features=Int
7272
}
7373

7474
const toggleClassBehavior =
75-
(classNameInView || classNameAboveView) && toggleClassNameOnInView
75+
(typeof classNameInView === 'string' ||
76+
typeof classNameAboveView === 'string') &&
77+
toggleClassNameOnInView
7678
const tooglePropsBehavior = childPropsInView && toggleChildPropsOnInView
7779
const toggleOnInViewBehavior = (onInView || onNotInView) && repeatOnInView
7880
const toggleBehavior =
7981
toggleClassBehavior || tooglePropsBehavior || toggleOnInViewBehavior
8082

8183
if (nowInView && !toggleBehavior) {
8284
const changes = {}
83-
if (classNameInView) changes.className = classNameInView
85+
if (typeof classNameInView === 'string')
86+
changes.className = classNameInView
8487
if (childPropsInView) changes.childProps = childPropsInView
8588
if (Object.keys(changes).length) {
8689
this.setState(changes)
@@ -98,7 +101,7 @@ Perhaps use a polyfill like: https://cdn.polyfill.io/v2/polyfill.js?features=Int
98101

99102
if (toggleBehavior) {
100103
// Check if we scrolled past view
101-
if (classNameAboveView) {
104+
if (typeof classNameAboveView === 'string') {
102105
if (
103106
// we just left the view
104107
!nowInView &&

0 commit comments

Comments
 (0)