Commit 7a445a07 authored by christianrhansen's avatar christianrhansen

first steps in intersection-observer directive

parent 65f01ca8
Pipeline #17281 passed with stage
in 2 minutes and 15 seconds
export default ({ Vue }) => {
Vue.directive('intersection-observer', {
inserted: function (el) {
el.style.backgroundColor = 'green'
const options = {
root: null,
threshold: '0'
}
const observer = new IntersectionObserver(observerCallback, options)
observer.observe(el)
function observerCallback (entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
console.log('isIntersecting')
}
else {
console.log('nicht mehr intersecting')
console.log(entry.boundingClientRect.left)
}
})
}
}
})
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment