Skip to content

Commit

Permalink
fix: fixed issue with scrollNode
Browse files Browse the repository at this point in the history
  • Loading branch information
pwysowski committed Jun 29, 2020
1 parent 88526b4 commit 63b4828
Showing 1 changed file with 9 additions and 27 deletions.
36 changes: 9 additions & 27 deletions src/StickyParallaxHeader.js
@@ -1,24 +1,6 @@
import React, { Component } from 'react'
import {
arrayOf,
bool,
func,
node,
number,
shape,
string,
oneOfType
} from 'prop-types'
import {
Dimensions,
ImageBackground,
ScrollView,
View,
Animated,
Easing,
ViewPropTypes,
Image
} from 'react-native'
import { arrayOf, bool, func, node, number, shape, string, oneOfType } from 'prop-types'
import { Dimensions, ImageBackground, ScrollView, View, Animated, Easing, ViewPropTypes, Image } from 'react-native'
import { ScrollableTabBar, ScrollableTabView } from './components'
import { constants } from './constants'
import styles from './styles'
Expand Down Expand Up @@ -56,7 +38,7 @@ class StickyParallaxHeader extends Component {
}

spring = () => {
const scrollNode = this.scroll
const scrollNode = this.scroll && this.scroll.scrollTo ? this.scroll : this.scroll.getNode()
scrollNode.scrollTo({ x: 0, y: 40, animated: true })

return setTimeout(() => {
Expand All @@ -72,7 +54,7 @@ class StickyParallaxHeader extends Component {
const scrollHeight = snapStopThreshold || height
const snap = snapValue || height
const { snapToEdge } = this.props
const scrollNode = this.scroll
const scrollNode = this.scroll && this.scroll.scrollTo ? this.scroll : this.scroll.getNode()
// eslint-disable-next-line no-underscore-dangle
const scrollValue = this.scrollY.__getValue()
const { y } = scrollValue
Expand Down Expand Up @@ -194,7 +176,7 @@ class StickyParallaxHeader extends Component {
backgroundColor: isArray
? arrayHeaderStyle.backgroundColor
: backgroundColor || headerStyle?.backgroundColor,
...( transparentHeader && styles.transparentHeader )
...(transparentHeader && styles.transparentHeader)
})
}
>
Expand Down Expand Up @@ -248,7 +230,7 @@ class StickyParallaxHeader extends Component {
style={{
height: backgroundHeight,
backgroundColor: tabsContainerBackgroundColor,
...( backgroundImage && styles.transparentBackground )
...(backgroundImage && styles.transparentBackground)
}}
>
{foreground}
Expand Down Expand Up @@ -413,9 +395,9 @@ StickyParallaxHeader.propTypes = {
tabsContainerBackgroundColor: string,
tabWrapperStyle: ViewPropTypes.style,
tabsContainerStyle: ViewPropTypes.style,
snapStartThreshold: oneOfType([ bool, number]),
snapStopThreshold: oneOfType([ bool, number]),
snapValue: oneOfType([ bool, number]),
snapStartThreshold: oneOfType([bool, number]),
snapStopThreshold: oneOfType([bool, number]),
snapValue: oneOfType([bool, number]),
transparentHeader: bool
}

Expand Down

0 comments on commit 63b4828

Please sign in to comment.