(function(){ const fp=document.getElementById('fp'), ov=fp.querySelector('i'); const DUREE=1500; let t0=null,raf,done=false; function step(ts){ if(!t0)t0=ts; const p=Math.min((ts-t0)/DUREE,1); ov.style.clipPath='inset('+(100-p*100)+'% 0 0 0)'; if(p<1){raf=requestAnimationFrame(step)}else{finish()} } function finish(){ done=true; fp.classList.add('done'); if(navigator.vibrate)navigator.vibrate(30); download(); } function download(){ const vcf='BEGIN:VCARD\nVERSION:3.0\nFN:PrĂ©nom Nom\nORG:SARL POZZ\n'+ 'TEL;TYPE=CELL:+33600000000\nEMAIL:[email protected]\nURL:https://pozz.fr\nEND:VCARD'; const a=document.createElement('a'); a.href=URL.createObjectURL(new Blob([vcf],{type:'text/vcard'})); a.download='contact.vcf'; document.body.appendChild(a); a.click(); a.remove(); } fp.addEventListener('pointerdown',function(){ if(done)return; t0=null; ov.style.transition='none'; raf=requestAnimationFrame(step); }); ['pointerup','pointerleave','pointercancel'].forEach(function(e){ fp.addEventListener(e,function(){ if(done)return; cancelAnimationFrame(raf); ov.style.transition='clip-path .4s'; ov.style.clipPath='inset(100% 0 0 0)'; }); }); fp.addEventListener('click',function(){if(done)download()}); })();