mini页面
This commit is contained in:
@@ -105,6 +105,7 @@ export default {
|
||||
isActive: false,
|
||||
transition,
|
||||
}
|
||||
console.log(config)
|
||||
els.set(el, config)
|
||||
add(el, root, config)
|
||||
},
|
||||
@@ -176,14 +177,21 @@ async function handleScroll({ target: root }) {
|
||||
const offsetHeight = root === document ? window.innerHeight : rootEl.offsetHeight
|
||||
const offsetTop = rootEl.offsetTop
|
||||
const scrollTop = rootEl.scrollTop
|
||||
const elTop_bottom = offsetHeight - (el.offsetTop - offsetTop - rootEl.scrollTop)
|
||||
const elTop_bottom = offsetHeight - (getDocumentTop(el) - offsetTop - rootEl.scrollTop)
|
||||
const maxHeight = offsetHeight + el.offsetHeight
|
||||
const p = Math.min(1, Math.max(0, elTop_bottom / maxHeight))
|
||||
console.log(p)
|
||||
children.forEach((item) => {
|
||||
setDocumentStyles(el, item, p)
|
||||
})
|
||||
})
|
||||
}
|
||||
function getDocumentTop(el, root = document, offset = 0) {
|
||||
const parent = el.parentElement
|
||||
offset = offset + el.offsetTop
|
||||
if (parent && parent !== document.documentElement) return getDocumentTop(parent, root, offset)
|
||||
return offset
|
||||
}
|
||||
function getChildren(el, oneself = true) {
|
||||
const children = Array.from(el.querySelectorAll(typesStr))
|
||||
if (oneself && Object.values(T).some(v => hasAttr(el, v))) children.push(el)
|
||||
|
||||
Reference in New Issue
Block a user