Skip to content

Commit 733c8fc

Browse files
committed
perf: update affix
1 parent e2c86fe commit 733c8fc

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

components/affix/index.jsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,12 @@ const Affix = {
131131
measure() {
132132
const { status, lastAffix } = this;
133133
const { target } = this;
134-
if (status !== AffixStatus.Prepare || !this.$refs.fixedNode || !this.$el || !target) {
134+
if (
135+
status !== AffixStatus.Prepare ||
136+
!this.$refs.fixedNode ||
137+
!this.$refs.placeholderNode ||
138+
!target
139+
) {
135140
return;
136141
}
137142

@@ -147,7 +152,7 @@ const Affix = {
147152
status: AffixStatus.None,
148153
};
149154
const targetRect = getTargetRect(targetNode);
150-
const placeholderReact = getTargetRect(this.$el);
155+
const placeholderReact = getTargetRect(this.$refs.placeholderNode);
151156
const fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
152157
const fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);
153158
if (fixedTop !== undefined) {
@@ -209,9 +214,9 @@ const Affix = {
209214
const offsetBottom = this.getOffsetBottom();
210215

211216
const targetNode = target();
212-
if (targetNode && this.$el) {
217+
if (targetNode && this.$refs.placeholderNode) {
213218
const targetRect = getTargetRect(targetNode);
214-
const placeholderReact = getTargetRect(this.$el);
219+
const placeholderReact = getTargetRect(this.$refs.placeholderNode);
215220
const fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
216221
const fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);
217222

@@ -234,7 +239,6 @@ const Affix = {
234239
const className = classNames({
235240
[getPrefixCls('affix', prefixCls)]: affixStyle,
236241
});
237-
238242
const props = omit($props, ['prefixCls', 'offsetTop', 'offsetBottom', 'target']);
239243
return (
240244
<ResizeObserver

components/vc-resize-observer/index.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const VueResizeObserver = {
66
name: 'ResizeObserver',
77
props: {
88
disabled: Boolean,
9+
onResize: Function,
910
},
1011
data() {
1112
this.currentElement = null;
@@ -45,12 +46,12 @@ const VueResizeObserver = {
4546
}
4647

4748
if (!this.resizeObserver && element) {
48-
this.resizeObserver = new ResizeObserver(this.onResize);
49+
this.resizeObserver = new ResizeObserver(this.handleResize);
4950
this.resizeObserver.observe(element);
5051
}
5152
},
5253

53-
onResize(entries) {
54+
handleResize(entries) {
5455
const { target } = entries[0];
5556
const { width, height } = target.getBoundingClientRect();
5657
/**

0 commit comments

Comments
 (0)