Skip to content

Start Scrolling With Delay #30

@NimaKaviyani

Description

@NimaKaviyani

Hi,
I have an accordion component at bottom of the page, I want scrolling after it open.
Is it possible to start scrolling with delay?

I try this code:

constructor(props) {
    super(props);
    this.state = {
        showUpload: false,
    };
    this.anchorRef = createRef();
}
showUploadBlock = () => {
    this.setState(prevState => ({
        showUpload: !prevState.showUpload,
    }), () => {
        if (this.state.showUpload) {
            setTimeout(() => {
                this.anchorRef.click();
            }, 5);
        }
    });
};
<Button
    onClick={this.showUploadBlock}
    variant="info"
    size="lg"
    block
>
    Upload File
</Button>
<AnchorLink
    ref={(ref) => {
        this.anchorRef = ref;
    }}
    href="#upload"
    className="invisible"
/>

But ref is not working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions