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
Add a link #63
Comments
Hi there, Your HTML <div id="my-container"></div> Your script new Vivus('my-container', {
type: 'delayed',
duration: 200,
animTimingFunction: Vivus.EASE,
file: '/link/to/my.svg'
}); |
Thank you for your help. I wand to add URL link that people can click on SVG to open a page or a website. is that possible? |
Oh sorry, my bad. var myAnimation = new Vivus('my-container', {
type: 'delayed',
duration: 200,
animTimingFunction: Vivus.EASE,
file: '/link/to/my.svg'
});
myAnimation.el.addEventListener('click', function () {
document.location = '//github.com';
}); It's not really cool because we loose a bit of accessibility but it works. Otherwise I would recommend you to wrap the SVG container into a <a href="//github.com">
<div id="my-container"></div>
</a> |
I will try both options and get back. I tried the second option but it didn't work for me. |
it's not working for me. here is a live demo for option 2 http://020018.businesscatalyst.com/index.html I hope you can help |
You made a mistake on the option 1. You set the listener on |
Any luck? |
Sorry, I was out of town. |
Oh.. I realised my mistake. You will need to do it when the SVG is loaded: var svg1 = new Vivus('svg1', {
type: 'delayed',
delay: 100,
duration: 200,
start: 'inViewport',
animTimingFunction: Vivus.LINEAR,
file: '/assets/enter.svg',
onReady: function (mySvg) {
mySvg.el.addEventListener('click', function () {
document.location = '//github.com';
});
}
});
|
it is not working any more :) |
It's a syntax error. You forgot a comma after the filename.
|
great!!! thanks |
it this method not really cool because we loose a bit of accessibility but it works or that's why now? |
In the mySvg.el.style.cursor = 'pointer'; then your code should look like this: var svg1 = new Vivus('svg1', {
type: 'delayed',
delay: 100,
duration: 200,
start: 'inViewport',
animTimingFunction: Vivus.LINEAR,
file: '/assets/enter.svg',
onReady: function (mySvg) {
mySvg.el.style.cursor = 'pointer';
mySvg.el.addEventListener('click', function () {
document.location = '//github.com';
});
}
}); When I mention loosing accessibility, I'm talking about respecting HTML standards instead of mimic the natural behavior in JavaScript. For example, a user cannot make a right click on your SVG, then choose |
Any updates? |
Great! Thank you for your help. I appreciate it. |
Hi,
Could you please help me to add a link to an animated SVG file? Is it possible to add url parameter in this code?
new Vivus('my-svg-id', {
type: 'delayed',
duration: 200,
animTimingFunction: Vivus.EASE
},);
Thanks
The text was updated successfully, but these errors were encountered: