hooks icon indicating copy to clipboard operation
hooks copied to clipboard

[Feature Request] useSize() `options` support

Open kkimdev opened this issue 2 years ago • 6 comments

ResizeObserver.observe() has options https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/observe , but that's not configurable from useSize() currently.

My usecase is using border-box option.

kkimdev avatar Jun 21 '23 04:06 kkimdev

It's a great suggestion, we'll add it in the future version.

liuyib avatar Jun 21 '23 07:06 liuyib

It's a great suggestion, we'll add it in the future version.

ahooks relies on the resize-observer-polyfill package, but the author of resize-observer-polyfill hasn't maintained it for a long time, so it doesn't support the options parameter for observe(). I'm wondering if there's an alternative solution, such as using @juggle/resize-observer.

askwuxue avatar Jun 25 '23 10:06 askwuxue

It's a great suggestion, we'll add it in the future version.

ahooks relies(依赖) on the resize-observer-polyfill package, but the author of resize-observer-polyfill hasn't maintained(保持) it for a long time, so it doesn't support the options parameter for observe(). I'm wondering if there's an alternative(替代品) solution, such as using @juggle/resize-observer.

但这是一个Break change。原因是resize-observer-polyfill这个库在计算时,是 content width + padding。

askwuxue avatar Jun 26 '23 01:06 askwuxue

但这是一个Break change。原因是resize-observer-polyfill这个库在计算时,是 content width + padding。

这俩个库哪个是按照规范来的呢?


我看到 @juggle/resize-observer 是按照最新的规范来的,但是其 READMD 注明了最新的规范还没完成: image

liuyib avatar Jun 26 '23 07:06 liuyib

但这是一个Break change。原因是resize-observer-polyfill这个库在计算时,是 content width + padding。

这俩个库哪个是按照规范来的呢?

我看到 @juggle/resize-observer 是按照最新的规范来的,但是其 READMD 注明了最新的规范还没完成: image

如果按照MDN当前定义的规范的话,@juggle/resize-observer 是符合规范来的。至少是支持options选项的。

askwuxue avatar Jun 26 '23 09:06 askwuxue

如果按照MDN当前定义的规范的话,@juggle/resize-observer 是符合规范来的。至少是支持options选项的。

Get! 感谢你提供的参考建议~

liuyib avatar Jun 27 '23 15:06 liuyib