Comments (2)
The reason I ask, which might be accomplished a better way:
I'm trying to selectively ignore resize notifications that are caused by a specific function/block.
const eventBus = new EventEmitter();
const el = document.createElement('div');
const observer = new ResizeObserver(() => {
if (someCondition()) {
eventBus.emit('resize')
}
})
observer.observe(el);
modifySizeWithoutTriggeringResize(() => {
// modifications to the size of the element can be made within this function
// and will not trigger a "resize" event on the event bus
$(el).height(100);
});
In order to accomplish this I am thinking that I will:
- Run the function passed to
modifyWithoutTriggeringResize()
to completion - Create an
expectedContentRects
map, mapping all tracked elements to their currentcontentRect
- On the next notification from the ResizeObserver, ignore any resize entry with a
contentRect
that matches the rect in theexpectedContentRects
map. - If all resize entries are ignored, do not emit the
"resize"
event on the bus.
from resize-observer-polyfill.
Decided to use the same function to get the size of the element before the notification and within the notification so that I'm not reliant on the implementation here. Sorry for the noise.
from resize-observer-polyfill.
Related Issues (20)
- Support ResizeObserverBoxOptions HOT 1
- Travis CI Build Failed
- The resize-observer-polyfill plugin is able to add support for listening to css3 "animation" to change element size? HOT 2
- Doesn't work in Safari HOT 2
- how to detect need? HOT 1
- inotify - windows incompatible module HOT 1
- Why is Demo site minified? HOT 2
- Update readme.md to indicate that this project is a ponyfill by default HOT 1
- Cannot read property 'flags' of undefined when imported in a typescript file
- Check for `Element` prevents correctly working under jsdom
- DOMRectReadOnly is not compatible with native TypeScript type
- Browser support widget is broken in the README
- Spec refresh for borderBoxSize and contentBoxSize
- Support shadow DOM and same-origin iframes
- Error when compiling: Property 'contentRect' must be of type 'DOMRectReadOnly' HOT 18
- Typings collide with Typescripts DOM typings for ResizeObserver HOT 15
- Questions about test cases
- What is the version range of chrome that can support this plug-in function
- Use different approach to check instanceof Element HOT 1
- ResizeObserver loop limit exceeded
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 resize-observer-polyfill.