Behaviour
Inspired by my library modular behaviour, simply bind js code to
html nodes with data-behaviour=name_of_my_func
!
Pass config as json or in simple config format in data-behaviour-config
.
Nodes with data-lazy
are initialized when in the viewport.
Demo
Some content here
Countup demo
In this demo, count up is loaded as a global var. It's init function is defined 1s after load, and it will be detected by our library.
You always need to wrap the library in with a function call to initiliaze. This function should return a proper cleanup callback.
0000Scroll below to see lazy countup using data-lazy
.
0000
Moving doesn't reset counting except if it takes longer than a microtask