1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-28 22:39:11 +02:00

rewritten scrollspy without jquery

This commit is contained in:
Alessandro Chitolina
2017-09-25 09:09:01 +02:00
committed by XhmikosR
parent 9744886519
commit 0263d1742c
5 changed files with 117 additions and 49 deletions

View File

@@ -40,6 +40,22 @@ const Manipulator = {
element.removeAttribute(`data-${key.replace(/[A-Z]/g, (chr) => `-${chr.toLowerCase()}`)}`)
},
offset(element) {
const rect = element.getBoundingClientRect()
return {
top: rect.top + document.body.scrollTop,
left: rect.left + document.body.scrollLeft
}
},
position(element) {
return {
top: element.offsetTop,
left: element.offsetLeft
}
},
toggleClass(element, className) {
if (typeof element === 'undefined' || element === null) {
return