perf(@vant/use): reduce usePageVisibility event binding (#9835)
* perf(@vant/use): reduce usePageVisibility event binding * chore: update
This commit is contained in:
@@ -1,19 +1,16 @@
|
||||
import { Ref, unref } from 'vue';
|
||||
|
||||
function isWindow(val: unknown): val is Window {
|
||||
return val === window;
|
||||
}
|
||||
const isWindow = (val: unknown): val is Window => val === window;
|
||||
|
||||
function makeDOMRect(width: number, height: number) {
|
||||
return {
|
||||
const makeDOMRect = (width: number, height: number) =>
|
||||
({
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: width,
|
||||
bottom: height,
|
||||
width,
|
||||
height,
|
||||
} as DOMRect;
|
||||
}
|
||||
} as DOMRect);
|
||||
|
||||
export const useRect = (
|
||||
elementOrRef: Element | Window | Ref<Element | Window | undefined>
|
||||
@@ -26,7 +23,7 @@ export const useRect = (
|
||||
return makeDOMRect(width, height);
|
||||
}
|
||||
|
||||
if (element && element.getBoundingClientRect) {
|
||||
if (element?.getBoundingClientRect) {
|
||||
return element.getBoundingClientRect();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user