Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Motion Bank
Applications
Systems Frontend
Commits
7a445a07
Commit
7a445a07
authored
Oct 24, 2019
by
christianrhansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first steps in intersection-observer directive
parent
65f01ca8
Pipeline
#17281
passed with stage
in 2 minutes and 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
src/plugins/intersection-observer.js
src/plugins/intersection-observer.js
+18
-1
No files found.
src/plugins/intersection-observer.js
View file @
7a445a07
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
)
}
})
}
}
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment