Interactive iOS Safari Download Button With jQuery/CSS/SVG
File Size: | 5.54 KB |
---|---|
Views Total: | 1006 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
This is a small script created by Andreas Storm that helps you create an iOS Safari style download button interaction using jQuery, CSS3 animations, and SVG path drawing animations.
How to use it:
1. Insert an SVG based iOS safari style down button together with circular & linear progress bar into the HTML.
<a class="btn" href="#"> <span class="circle"></span> <svg width="20" height="26" viewbox="0 0 20 26"> <path d="M1.5 16.5L10 24.5L18.5 16.5"></path> <path d="M10 1.5V24"></path> </svg> <span class="progress"></span> </a>
2. Style the down button in the CSS.
.btn { position: relative; display: inline-block; width: 48px; height: 48px; border-radius: 24px; } .btn svg { fill: none; width: 20px; height: 26px; margin: 11px 0 0 14px; transform: translate3d(0, 0, 0); } .btn svg path { stroke: #fdd7d2; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.3s ease; } .btn .circle { position: absolute; display: block; top: 0; left: 0; height: 48px; width: 48px; border-radius: 24px; border: 3px solid #fdd7d2; transition: border 0.3s ease; } .btn .progress { position: absolute; display: block; bottom: -10px; left: 0; height: 3px; width: 48px; border-radius: 3px; background: rgba(253, 215, 210, 0.2); opacity: 0; pointer-events: none; overflow: hidden; }
3. Animate the download button using CSS3 animations and SVG path animations.
.btn .progress:after { content: ""; display: block; width: 100%; height: 3px; border-radius: 2px; background: #ff9b8b; transform-origin: left; transform: scaleX(0); transition: transform 2s linear; } .btn .progress.active { opacity: 1; } .btn .progress.active::after { transform: scaleX(1); } .btn:hover .circle { border-color: #ff9b8b; } .btn:hover svg path { stroke: #ff9b8b; } .btn:active svg { transform: translateY(2px); } .btn.pending .circle { border-color: #ff9b8b; animation: animC 0.6s ease-out; animation-delay: 2.35s; } .btn.pending svg { animation: animS 0.6s ease-in; animation-delay: 2.15s; } .btn.pending svg path { stroke: #ff9b8b; } @keyframes animS { 5% { transform: scale(0.9); } 50% { transform: translateY(12px); } 80% { transform: translateY(-4px); } } @keyframes animC { 50% { transform: translateY(6px); } 80% { transform: translateY(-4px); } }
4. Insert the necessary jQuery library into the HTML.
<script src="/path/to/cdn/jquery.min.js"></script>
5. The main script to activate the download button interaction.
(function() { $('.btn').click(function() { $('.btn').addClass('pending'); $('.progress').addClass('active'); setTimeout((function() { return $('.progress').removeClass('active'); }), 2300); return setTimeout((function() { return $('.btn').removeClass('pending'); }), 3600); }); }).call(this);
This awesome jQuery plugin is developed by Andreas Storm. For more Advanced Usages, please check the demo page or visit the official website.