This is how I setup every plugin I create:
Initialize function:
instance.data.i = 0
instance.data.time = Date.now()
Update function:
if(instance.data.i === 0) {
instance.data.i++
// create element here with id = `super-cool-element-${instance.data.time}`
}
else{
// code has already run one time, so we won't create a new element
const element = document.getElementbyID(`super-cool-element-${instance.data.time}`)
// do the rest ...
}
This logic will help you understand how to create bubble plugins.
Wishing you luck!
1 Like