mirror of
https://github.com/youzan/vant.git
synced 2025-10-17 00:14:18 +00:00
Revert "fix(@vant/use): useRect should always return DOMRect (#8147)"
This reverts commit 0d0310d34e
.
This commit is contained in:
@@ -12,12 +12,27 @@ 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 new DOMRect(0, 0, 0, 0);
|
return {
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user