mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(@vant/use): useRect should always return DOMRect (#8147)
This commit is contained in:
parent
7ec644c3bc
commit
0d0310d34e
@ -12,27 +12,12 @@ export const useRect = (
|
|||||||
if (isWindow(element)) {
|
if (isWindow(element)) {
|
||||||
const width = element.innerWidth;
|
const width = element.innerWidth;
|
||||||
const height = element.innerHeight;
|
const height = element.innerHeight;
|
||||||
|
return new DOMRect(0, 0, width, height);
|
||||||
return {
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
right: width,
|
|
||||||
bottom: height,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element && element.getBoundingClientRect) {
|
if (element && element.getBoundingClientRect) {
|
||||||
return element.getBoundingClientRect();
|
return element.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return new DOMRect(0, 0, 0, 0);
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 0,
|
|
||||||
width: 0,
|
|
||||||
height: 0,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user