Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I cant calc the dom size #93

Closed
fuwei-1993 opened this issue Oct 24, 2019 · 4 comments
Closed

I cant calc the dom size #93

fuwei-1993 opened this issue Oct 24, 2019 · 4 comments

Comments

@fuwei-1993
Copy link

useObservable is never use in useEffect, but i wanna calc the dom size without some event

@Brooooooklyn
Copy link
Contributor

Please provide some codes to show your usecase, I'm hardly understand your problem.

@fuwei-1993
Copy link
Author

fuwei-1993 commented Oct 31, 2019

useEffect(() => {
    const virtualListEle: HTMLDivElement = listContainerRef.current
    containerHeight$.next(virtualListEle.clientHeight)

    const actualRow$ = combineLatest(containerHeight$, props.options$).pipe(
      map(([ch, { height }]) => Math.ceil(ch / height)),
    )

    const dataInViewSlice$ = combineLatest(props.data$, actualRow$).pipe(
      map(([data, actualRows]) => data.slice(0, actualRows)),
    )
    const scrollHeight$ = combineLatest(props.data$, props.options$).pipe(
      map(([data, { height }]) => data.length * height),
    )

    sub.add(
      combineLatest(dataInViewSlice$, scrollHeight$).subscribe(
        ([data, height]) => {
          setData(data)
          seHeight(height)
        },
      ),
    )

    return () => {
      sub.unsubscribe()
    }
  }, [listContainerRef.current])

@zry656565
Copy link
Contributor

It seems that rxjs-hooks isn't suitable for this case. So you may have to do the thing in your own style.

@fuwei-1993
Copy link
Author

ok tks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants