Junp to the file: https://gist.github.com/MartinMuzatko/4bfc559a0158c4652c2c#file-interact-js
<my-tag>
<div name="items" each={set in data}>{set}</div>
<script>
this.mixin(interact)
this.data = {your:'data', is:'an', object : ['or', 'an', 'array']}
this.on(
'mount',
function()
{
// Important! You don't insert the data in the function,
// but the element/DOM node it affects (hence name="items" and this.items)
this.dataFade = new this.interaction(this.items)
}
)
</script>
</my-tag>
The DOM node you define with name="example"
or id="example"
- this.example
The animation classes, this example works with animate.css - but you can add your own animations if you want to. Just add the classes as array
Default: ['animated', 'fadeOut']
When creating the Interaction Object, you'll retrieve an Object with these methods
Gets called when setting up the interaction. Creates the MutationObserver and the underlying logic
Gets called after successful Setup, you need this if you want to reconnect to the observer
Disconnecting the observer - no more mutations get observed and reacted upon.
The method that is called whenever a mutation is made (no matter if element added or removed or changed) You can overwrite this if you want to. The first argument are the mutations, retrieved by the MutationObserver the second argument is the observer (so you can disconnect and reconnect if you want to avoid having the listener to listen to your own changes
e.g.:
observer.disconnect()
node.remove()
observer.observe()
Thats it! Have fun with it.
License: MIT