-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SVG object loading #14
Comments
your would this work instead? const svg_test=(id,path)=> html`
<object
type="image/svg+xml"
.data=${path}
onload=${dispatch(id)}
/> |
Sorry, bad copy/paste. |
here it is : https://codepen.io/thipages/pen/XWXKgBw |
OK, this is an expected behavior, see the following code that uses zero libraries: document.body.innerHTML = `<object height="100px" type="image/svg+xml"></object>`;
const object = document.body.firstElementChild;
const m= {
id: '_svg_',
path: 'https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/ruby.svg'
};
const update = () => {
object.onload = () => {
document.dispatchEvent(new CustomEvent(m.id, {detail: null}));
};
object.data = m.path;
};
document.addEventListener(m.id, () => {
setTimeout(()=> {
console.log("loaded");
// do some work here like changing the svgs height/scale
update();
},1000);
});
update(); setting the So, latest version of uhtml allows you to use TL;DR this now works: const svg_test=(id,path)=> html`
<object
type="image/svg+xml"
data=${path}
onload=${dispatch(id)}
/>
`; |
great! Thank you |
Hi,
I tried to render an interactive svg with the following code
the issue : it loops (n loaded on console, blinking on screen).
Thank you.
I can write a code pen if needed.
The text was updated successfully, but these errors were encountered: