TriggeringView doesn't update threshold if renderHeader() component updates its height
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- react-native, typescript
- Domain
- mobile
Research direction
Start with TriggeringView and inspect its onLayout handling, especially how initialPageY is used to calculate the triggering threshold. Reproduce the case where HeaderScrollView's header height changes after the initial render, then verify that onHide and onDisplay use the updated threshold rather than the initial height.
Written by the indexing model from the issue text.
Description
Hey, first of all, thank you for this amazing work!
I'm using it in a special scenario where the header component height is calculated dynamically (using react-native-auto-height-image).
This would be my code:
import React, {Component} from "react";
import {Text, View} from "react-native";
import AutoHeightImage from 'react-native-auto-height-image';
import HeaderImageScrollView, {TriggeringView} from 'react-native-image-header-scroll-view';
const DEFAULT_HEADER_HEIGHT = 500;
export default class WallScreen extends Component {
componentWillMount() {
this._setHeaderHeight(DEFAULT_HEADER_HEIGHT);
}
render() {
return (
<View style={styles.container}>
<HeaderImageScrollView
maxHeight={this.props.headerHeight} // Prop coming from redux state.
minHeight={0}
fadeOutForeground={true}
renderHeader={this._renderHeader.bind(this)}
>
<TriggeringView
onHide={this._onHide.bind(this)}
onDisplay={this._onDisplay.bind(this)}
>
</TriggeringView>
<Text>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam asperiores at commodi cumque
dolor dolorum, ea eaque est excepturi nam, perferendis perspiciatis, porro! A illo ipsa itaque
quae rerum unde?
</Text>
</HeaderImageScrollView>
</View>
);
}
_setHeaderHeight(height){
// Here I would dispatch the redux action to update 'headerHeight'.
}
_renderHeader() {
return (
<View>
<AutoHeightImage
width={360} // Hardcoded, not important for this example
imageURL='https://example.com'
onHeightChange={this._setHeaderHeight.bind(this)}
/>
</View>
);
}
_onHide() {
console.log('On hide called');
}
_onDisplay() {
console.log('On display called')
}
}
Until now, all great! All the layout works great out of the box and my code updates the header height correctly!
BUT the problem comes with TriggeringView.
As you can see, the header height is initialized at 500. Well, as I update the headerHeight prop via redux, TriggeringView will still trigger the onHide and onDisplay callbacks using the 500 initial height.
I took a look at the source and saw that the triggering threshold is based in the initialPageY property, and this property is calculated in the onLayout hook.
So the problem is this that hook is not triggered when the header height changes.
PS: I fixed this adding a new dynamicHeaderHeight prop to HeaderScrollView. Will submit a PR today!
Thanks!
- Dominant language
- TypeScript
- Stars
- 1k
- Forks
- 101
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bamlab/react-native-image-header-scroll-view
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
bamlab/react-native-image-header-scroll-view#134 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 20/100
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
bamlab/react-native-image-header-scroll-view#131 · 1 comment ·
All issues in bamlab/react-native-image-header-scroll-view
Similar issues
-
area: aria/combobox gemini-triaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
angular/components#33973 ·
Maintainers usually reply within 1 day
-
bug priority: P2
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
[bug] status, list and push crash with an uncaught NotInitializedError stack trace when teamai is not initializedPossibly taken @jay23606 claimed this today. Openbug good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Tencent/teamai-cli#1227 ·
Maintainers usually reply within 1 day
-
[Tool]: YapOpen
Difficulty 1/5 1-3 hours Newbie friendliness 62/100
withkarann/aifoxx#417 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sindresorhus/eslint-plugin-unicorn#3921 ·
Maintainers usually reply within 1 day