Comments (2)
200 is definitely an arbitrary number. It's not clear that just waiting one frame will be enough either though, because the rate at which resize
events are emitted is not tied to the request animation frame loop. I'll take a closer look though to test your suggestion. If resize
events are called faster than the request animation frame, we're good (this may be hardware dependent, not sure if there's a spec). If not then a fudge factor (like 200ms) might be needed, though 200 is generous. Really there's no significant problem with having the end
event fired 200ms after the last resize
event. In the future, I'd like to manually limit the DOM events to fire at most once per request animation frame loop (taking the last event fired in the loop and ignoring the others).
For clarity on the code, the point of the debounce is to convert a continuously emitted resize
event into start
, update
and end
events to fit the architecture. The first resize
event can easily be detected and converted to a start
. The last one can only be detected with a debounce style call.
from samsara.
After some testing, I've found the resize
event to be triggered slower than the request animation frame loop. Browsers likely throttle the event internally. This forces us to keep a fudge factor, but I've decided to lower it slightly to 150ms.
Whatever value is chosen will cause a lag if there is a sudden resize event triggered. For instance, opening and closing the dev tools on a desktop browser, or changing the orientation from landscape to portrait (or vice versa) on a mobile app. The view won't update responsively for the duration of 150ms.
This is undesirable, however, at least on mobile you can detect for this (because the only resize events from orientation change are discrete in nature). So we can remove any lag on mobile orientation resizes.
This has been updated in 4f681de
from samsara.
Related Issues (20)
- Not responsive to split view on iOS HOT 4
- [Question] Min & Max Opacity HOT 8
- EventEmitter incorrectly binds owner on `once`
- EventHandler never turns off upstream events HOT 1
- [Question] will-change size HOT 2
- [Question] How to populate the div within a Surface using Javascript HOT 8
- React Native HOT 3
- Manipulating StyleSheets instead of inline styles HOT 4
- Views added to context after context has been mounted need a resize event to be render HOT 2
- Question : Can Samsara leverage the capabilities of shadow-dom ?? HOT 1
- FYI - FastDom HOT 1
- SequentialLayout can't be align to bottom HOT 7
- Scrollview.goTo(x) goes bananas on iOS HOT 6
- Paginated Scrollview can't handle resize/orientation change HOT 1
- Scrollview bug IE11
- set/toggle/remove classes bug
- Awesome work HOT 2
- Non-nested CSS3D seems to be getting bad in Chrome. HOT 5
- Is Samsara viable when implementing animations designed in Framer? HOT 1
- misalignment with Cube demo HOT 3
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 samsara.