Comments (7)
Hey thanks for your reply. I think I am gonna look at it starting of next week. Have a nice weekend.
from react-sizeme.
Hey, not yet started working on that. So if you have any idea, just do it :)
from react-sizeme.
Not you again! :)
Will certainly accept a PR for this and add you to the contributors list.
In regards to this issue I actually did think I had put something in place to do exactly what you are after, but looking at my implementation it is completely wrong. I used to use a streaming library for this when it was attached to a larger project. It made this type of thing really easy to manage, but it doesn't make sense bulking up this library with a large dependency just for this.
So, the code that is dodgy is the following:
line 173 of SizeMe.js
checkIfSizeChanged = debounce(throttle((el) => {
const { width, height } = el.getBoundingClientRect();
const next = { width, height };
if (this.hasSizeChanged(this.state, next)) {
this.setState(next);
}
}, refreshRate), refreshRate)
I wrap the function with a throttle and a debounce from lodash, but this is completely wrong. We should have these contained within the function being executed separately whilst ensuring that we don't get refresh conflicts. Thinking something like throttle for a long period, and debounce for our configured refresh rate, but it needs some thought.
Appreciate your help and interest in this library!
from react-sizeme.
@larrydahooster are you still up for this? I've actually thought up a solution. I'm in need of this myself now so if you are stacked up I can pick this up. Thanks
from react-sizeme.
Doh! Implemented a complex handler. Then read the lodash docs properly for throttle
. It does leading and tail execution. Thats all we need. Removed the debounce
and it works. 😊
from react-sizeme.
Hey thanks for your changes. I always was wondering why you combined debounce with throttle. Nice that you changed it to throttle. I always was used to debounce, but throttle seams to be a nice alternative. I will stick to this right now and see later on, if I need to switch to debounce to save some performance. :) Thanks for your efforts!
from react-sizeme.
No problem, yeah I think it was late at night when I decided to combine the two!
Happy that I have at least put throttle
on your radar. It's great to have the option of them.
lodash
is too awesome. :)
from react-sizeme.
Related Issues (20)
- react-sizeme not hoisting statics HOT 1
- height doesnt get measured in some cases HOT 3
- MEGA Chrome extension breaks sizeme using object strategy with placeholders HOT 2
- HOC usage is not forwarding refs HOT 1
- TypeScript types are incomplete HOT 1
- console.error in storybook jest snapshot testing HOT 2
- [Warn] Cannot update a component from a different component. HOT 1
- How to jest mock the size HOT 3
- Width and height remain undefined HOT 1
- findDOMNode is deprecated in StrictMode HOT 6
- React 17 support HOT 3
- HOC onSize callback alternative usage example not working HOT 1
- Multiple SizeMe components inside one another?
- Open Collective link is broken HOT 2
- GitHub CI needed HOT 1
- Use Resize Observer? HOT 2
- Sizable input lost focus
- Feature Request: clientHeight, offsetHeight and scrollHeight
- Placeholder size not updating until a state change HOT 1
- React size me parent height collapsed when rendering with placeholder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-sizeme.