From 41e5c035dcf75c1f1d4c04673d3db255e439d452 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Wed, 11 Mar 2020 17:30:06 +0800 Subject: [PATCH] fix(Sticky): should not detect scroll when hidden --- src/sticky/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sticky/index.js b/src/sticky/index.js index f1a496751..6379b58ac 100644 --- a/src/sticky/index.js +++ b/src/sticky/index.js @@ -1,6 +1,7 @@ +import { isHidden } from '../utils/dom/style'; import { createNamespace, isDef } from '../utils'; -import { BindEventMixin } from '../mixins/bind-event'; import { getScrollTop, getElementTop, getScroller } from '../utils/dom/scroll'; +import { BindEventMixin } from '../mixins/bind-event'; const [createComponent, bem] = createNamespace('sticky'); @@ -59,6 +60,10 @@ export default createComponent({ methods: { onScroll() { + if (isHidden(this.$el)) { + return; + } + this.height = this.$el.offsetHeight; const { container } = this;