feat: resize add offse value

pull/4001/head
tanjinzhou 2021-04-25 13:24:34 +08:00
parent 184f6cac2f
commit 5295279a76
1 changed files with 2 additions and 1 deletions

View File

@ -58,6 +58,7 @@ const VueResizeObserver = defineComponent({
handleResize(entries) { handleResize(entries) {
const { target } = entries[0]; const { target } = entries[0];
const { width, height } = target.getBoundingClientRect(); const { width, height } = target.getBoundingClientRect();
const { offsetWidth, offsetHeight } = target;
/** /**
* Resize observer trigger when content size changed. * Resize observer trigger when content size changed.
* In most case we just care about element size, * In most case we just care about element size,
@ -67,7 +68,7 @@ const VueResizeObserver = defineComponent({
const fixedHeight = Math.floor(height); const fixedHeight = Math.floor(height);
if (this.width !== fixedWidth || this.height !== fixedHeight) { if (this.width !== fixedWidth || this.height !== fixedHeight) {
const size = { width: fixedWidth, height: fixedHeight }; const size = { width: fixedWidth, height: fixedHeight, offsetWidth, offsetHeight };
this.width = fixedWidth; this.width = fixedWidth;
this.height = fixedHeight; this.height = fixedHeight;
this.__emit('resize', size); this.__emit('resize', size);