You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/rate/util.js

40 lines
926 B

function getScroll (w, top) {
let ret = top ? w.pageYOffset : w.pageXOffset
const method = top ? 'scrollTop' : 'scrollLeft'
7 years ago
if (typeof ret !== 'number') {
const d = w.document
7 years ago
// ie6,7,8 standard mode
ret = d.documentElement[method]
7 years ago
if (typeof ret !== 'number') {
// quirks mode
ret = d.body[method]
7 years ago
}
}
return ret
7 years ago
}
function getClientPosition (elem) {
let x
let y
const doc = elem.ownerDocument
const body = doc.body
const docElem = doc && doc.documentElement
const box = elem.getBoundingClientRect()
x = box.left
y = box.top
x -= docElem.clientLeft || body.clientLeft || 0
y -= docElem.clientTop || body.clientTop || 0
7 years ago
return {
left: x,
top: y,
}
7 years ago
}
7 years ago
export function getOffsetLeft (el) {
const pos = getClientPosition(el)
const doc = el.ownerDocument
const w = doc.defaultView || doc.parentWindow
pos.left += getScroll(w)
return pos.left
7 years ago
}