Skip to content

onLayoutComplete triggered before any layout has taken place #139

@JuRomand

Description

@JuRomand

Hello,

I have a problem with onLayoutComplete :
I'd like to wait for the layout and animations to be complete before showing the items but the event "onLayoutComplete" is triggered before any layout has taken place (I tried with debugger), and is then triggered a lot of times (more times than the number of items I need to display).

Did I miss something ?

I'm also not sure whether the event is supposed to be triggered once all items have been rendered properly or each time an item is render.

Thanks in advance for your help (and many thanks for this lib!!!)!

This is my code (simplified):

export class Masonry extends React.Component<{props}, State> {

	//...

	public constructor(props) {
		super(props);
		//...
		this.handleLaidOutItems = this.handleLaidOutItems.bind(this);
	}

	// ... component logic

	public handleLaidOutItems(laidOutItems) {
		//...
	}

	public render() {
		return (
			<InfiniteScroll
				pageStart={0}
				loadMore={this.renderMoreTweetCards}
				hasMore={this.hasMoreItems}
				useWindow={false}
				initialLoad={false} // Necessary: loads all items if true
				threshold={500}
			>
				<Masonry
					className="grid"
					options={{
						itemSelector: ".grid-item",
						transitionDuration: 0,
					}}
					enableResizableChildren={true}
					onLayoutComplete={this.handleLaidOutItems}
				>
					{children.map( id => {
						return <child key={id}/>
					})}
				</Masonry>
			</InfiniteScroll>
		);
	}
}

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