SVG morph anim with Snap.svg

Developer
Size
2,213 Kb
Views
6,072

How do I make an svg morph anim with snap.svg?

What is a svg morph anim with snap.svg? How do you make a svg morph anim with snap.svg? This script and codes were developed by Iharosi on 16 January 2023, Monday.

SVG morph anim with Snap.svg Previews

SVG morph anim with Snap.svg - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>SVG morph anim with Snap.svg</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="svg-morph" data-state="first" data-morph-first="M11.1111111,11.1111111 C36.1111111,-13.8888889 111.111111,11.1111111 111.111111,11.1111111 C111.111111,11.1111111 136.111111,86.1111111 111.111111,111.111111 C86.1111111,136.111111 11.1111111,111.111111 11.1111111,111.111111 C11.1111111,111.111111 -13.8888889,36.1111111 11.1111111,11.1111111 Z" data-morph-second="M11.1111111,11.1111111 C11.1111111,11.1111111 86.1111111,-13.8888889 111.111111,11.1111111 C136.111111,36.1111111 111.111111,111.111111 111.111111,111.111111 C111.111111,111.111111 36.1111111,136.111111 11.1111111,111.111111 C-13.8888889,86.1111111 11.1111111,11.1111111 11.1111111,11.1111111 Z"> <svg xmlns="http://www.w3.org/2000/svg" width="50%" height="50%" viewBox="0 0 123 123" preserveAspectRatio="none"><path d="M11.1111111,11.1111111 C36.1111111,-13.8888889 111.111111,11.1111111 111.111111,11.1111111 C111.111111,11.1111111 136.111111,86.1111111 111.111111,111.111111 C86.1111111,136.111111 11.1111111,111.111111 11.1111111,111.111111 C11.1111111,111.111111 -13.8888889,36.1111111 11.1111111,11.1111111 Z" /></svg>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.3.0/snap.svg-min.js'></script> <script src="js/index.js"></script>
</body>
</html>

SVG morph anim with Snap.svg - Script Codes CSS Codes

html, body { height: 100%;
}
body { background-image: url('http://ajr.org/wp-content/uploads/2014/09/selfie1.jpg'); background-size: cover; background-repeat: no-repeat; background-position: center;
}
#svg-morph { text-align: center;
}
svg>path { fill: rgba(0, 60, 200, 0.3);
}

SVG morph anim with Snap.svg - Script Codes JS Codes

var svgContainer = document.querySelector('#svg-morph');
var svg = svgContainer.querySelector('svg');
var paths = { first: svgContainer.getAttribute('data-morph-first'), second: svgContainer.getAttribute('data-morph-second')
}
var s = Snap(svg.querySelector('path'));
document.addEventListener('click', function() { var path; if (svgContainer.getAttribute('data-state') === 'first') { path = paths.second; svgContainer.setAttribute('data-state', 'second'); } else { path = paths.first; svgContainer.setAttribute('data-state', 'first'); } s.stop().animate({ 'd': path }, 1000, mina.elastic);
});
SVG morph anim with Snap.svg - Script Codes
SVG morph anim with Snap.svg - Script Codes
Home Page Home
Developer Iharosi
Username iharosi
Uploaded January 16, 2023
Rating 3
Size 2,213 Kb
Views 6,072
Do you need developer help for SVG morph anim with Snap.svg?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Iharosi (iharosi) Script Codes
Create amazing captions with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!