Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: (Sticky) 只能针对浏览器窗口进行定位(#1087) #1103

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"@babel/runtime": "^7.16.5",
"@types/lodash": "^4.14.178",
"@types/validator": "^13.6.3",
"@vueuse/core": "^8.2.5",
"@vueuse/core": "^10.4.1",
"dayjs": "^1.10.7",
"lodash": "^4.17.21",
"tdesign-icons-vue-next": "^0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/message/message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
onMounted,
} from 'vue';
import { CheckCircleFilledIcon, CloseIcon, InfoCircleFilledIcon } from 'tdesign-icons-vue-next';
import { isObject, isString } from '@vueuse/core';
import { isObject, isString } from 'lodash';

import Link from '../link';
import messageProps from './props';
Expand Down
6 changes: 5 additions & 1 deletion src/pull-down-refresh/__test__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ export class MockResizeObserver {
}

disconnect() {
this._element.removeEventListener('resize', this.trigger);
// unmount后监听的元素this._element可能为null,因此先判断元素是否为null,再依据此来是否执行removeEventListener
if (this._element) {
this._element.removeEventListener('resize', this.trigger);
}
this._element = null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/shared/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isNumber } from '@vueuse/core';
import isNumber from 'lodash/isNumber';
import config from '../config';

const { prefix } = config;
Expand Down
4 changes: 2 additions & 2 deletions src/sticky/sticky.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export default defineComponent({

// box 用于占位和记录边界
// content 用于实际定位
const boxRef = templateRef('boxRef');
const boxRef = templateRef<HTMLElement | null>('boxRef', null);
const { top: boxTop } = useElementBounding(boxRef);
const contentRef = templateRef('contentRef');
const contentRef = templateRef<HTMLElement | null>('contentRef', null);
const { top: contentTop, height } = useElementBounding(contentRef);

const boxStyles = computed(() => `height:${height.value}px;`);
Expand Down