TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Animating programmatically with Redux and React

10 pointsby dominic_cocchalmost 9 years ago

1 comment

tracker1almost 9 years ago
I&#x27;ve taken a different approach for similar needs in the past... I have the current window size and scroll position in my state, and have windows events for resize&#x2F;onscroll update said values... from there, I can have pure rendering that uses the values... Also, but centralizing the size&#x2F;position values, I can have multiple components that handle their rendering as appropriate internally.<p><pre><code> window.addEventListener( &#x27;resize&#x27;, ()=&gt;store.dispatch({ type: &#x27;WINDOW_RESIZE&#x27; }) ); window.addEventListener( &#x27;scroll&#x27;, ()=&gt;store.dispatch({ type: &#x27;WINDOW_SCROLL&#x27; }) ); </code></pre> NOTE: you should double-check your scroll position, as the scroll events continue to fire as you hit the edge of the viewport.
评论 #12072876 未加载