Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
UPLOAD
css
@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700"); body{overflow: hidden} :root { --container-font-size: 28px; --container-background-color: #143982; --btn-upload-background-color: #0d5eff; --btn-upload-color: #ffffff; --btn-upload-width: 225px; --btn-upload-height: 80px; --btn-upload-border-radius: 0.75em; --btn-upload-transition-time: 50ms; --progress-width: 50px; --progress-height: 30px; --progress-top: -40px; --progress-arrow-color: #ffffff; --progress-arrow-background-color: #f53060; --progress-arrow-width: 8px; --progress-arrow-height: 8px; --check-width: 80px; --check-height: 45px; --check-stroke: 15px; } #container { font-family: "Open Sans", sans-serif; font-size: var(--container-font-size); background-color: var(--container-background-color); width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; overflow: hidden; } .btn-upload { color: var(--btn-upload-color); fill: var(--btn-upload-color); font-family: inherit; font-size: inherit; font-weight: bold; background-color: var(--btn-upload-background-color); width: var(--btn-upload-width); height: var(--btn-upload-height); padding: 0; border: 0; margin: 0; outline: 0; display: inline-flex; align-items: center; justify-content: center; position: relative; border-radius: var(--btn-upload-border-radius); box-shadow: 0 0.7em 1.2em rgba(25, 25, 25, 0.5); } .btn-upload:not(.btn-upload-uploading) { transition: box-shadow var(--btn-upload-transition-time) ease-out, transform var(--btn-upload-transition-time) ease-out; } .btn-upload:not(.btn-upload-uploading):hover { box-shadow: 0 0.7em 1.2em rgba(25, 25, 25, 0.8); } .btn-upload:not(.btn-upload-uploading):active { box-shadow: 0 0 0 rgba(25, 25, 25, 0.8); transform: translateY(0.2em); } .btn-upload > svg { fill: inherit; } .btn-upload > span { color: inherit; margin-left: 0.3em; } .progress { color: var(--progress-arrow-color); font-family: inherit; font-size: 50%; background-color: var(--progress-arrow-background-color); width: var(--progress-width); height: var(--progress-height); display: flex; align-items: center; justify-content: center; display: none; position: absolute; left: 0; top: var(--progress-top); border-radius: 0.5em; opacity: 0; transform-origin: center bottom; transform: translateX(-50%); filter: drop-shadow(0 0.7em 1.2em rgba(25, 25, 25, 0.5)); } .progress:after { content: ""; border-top: solid var(--progress-arrow-height) var(--progress-arrow-background-color); border-bottom: 0; border-left: solid calc(var(--progress-arrow-width) / 2) transparent; border-right: solid calc(var(--progress-arrow-width) / 2) transparent; position: absolute; top: calc(100% - 1px); } .check { width: var(--check-width); height: var(--check-height); display: none; position: absolute; top: calc(50% - calc(var(--check-width) / 2)); left: calc(50% - calc(var(--check-height) / 2)); transform-origin: center bottom; transform: rotate(-45deg); } .check > span { background-color: #ffffff; display: block; position: absolute; } .check > span:first-child { width: var(--check-stroke); height: 0; top: 0; left: 0; } .check > span:last-child { width: 0; height: var(--check-stroke); bottom: 0; left: 0; }
JavaScript
"use strict"; const BTN_COLOR = "#ffffff"; const BTN_BACKGROUND_COLOR = "#0d5eff"; const BTN_WIDTH = 225; const BTN_HEIGHT = 80; const BTN_BORDER_RADIUS = "0.75em"; const BTN_SIZE = 180; const ANIMATION_TIME = 0.4; const UPLOADING_BACKGROUND_COLOR = "#ffffff"; const UPLOADING_WIDTH = 320; const UPLOADING_HEIGHT = 30; const DEFAULT_CONTAINER_BACKGROUND_COLOR = "#143982"; const DEFAULT_BTN_UPLOAD_BACKGROUND_COLOR = "#0d5eff"; const COMPLETE_CONTAINER_BACKGROUND_COLOR = "#005e02"; const COMPLETE_BTN_UPLOAD_BACKGROUND_COLOR = "#0fe600"; const COMPLETE_SIZE = 180; const CHECK_WIDTH = "100%"; const CHECK_HEIGHT = "100%"; const PROGRESS_TIME = 2; const container = document.querySelector("#container"); const btnUpload = document.querySelector("#btn_upload"); const progress = btnUpload.querySelector(".progress"); const check = btnUpload.querySelector(".check"); const check1 = btnUpload.querySelector(".check > span:first-child"); const check2 = btnUpload.querySelector(".check > span:last-child"); const tl = gsap.timeline(); let uploading = false; function uploadStart() { // The button will become circle // The UPLOAD text will fade tl.to(btnUpload, { width: BTN_SIZE, height: BTN_SIZE, color: "transparent", fill: "transparent", borderRadius: "50%", duration: ANIMATION_TIME, ease: "elastic.out(1, 0.3)" }); // The button will become a progress bar tl.to(btnUpload, { backgroundColor: UPLOADING_BACKGROUND_COLOR, width: UPLOADING_WIDTH, height: UPLOADING_HEIGHT, borderRadius: "0.25em", duration: ANIMATION_TIME, ease: "power2.out", }); // Render the progress "speech bubble" tl.to(progress, { display: "flex" }); // Show the progress "speech bubble" (Fade in) tl.to(progress, { opacity: 1, duration: ANIMATION_TIME }); } function uploadProcess() { let uploadProgress = { val: 0 }; // Change the progress of upload tl.to(uploadProgress, PROGRESS_TIME, { val: 100, ease: "power4.inOut", onStart: function() { // Tilt the progress "speech bubble" tl.to(progress, { transform: "translateX(-50%) rotate(12deg)", delay: 0, ease: "power2.out" }, "-=" + PROGRESS_TIME); }, onUpdate: function() { let value = Math.floor(uploadProgress.val); // Increase the value of the progress (blue colored progress on progress bar) btnUpload.style.backgroundImage = "linear-gradient(to right, " + BTN_BACKGROUND_COLOR + " 0 " + value + "%, transparent " + value + "% 0)"; // Change the text of the progress "speech bubble" progress.innerText = value + "%"; // Change the position of the progress "speech bubble" progress.style.left = (UPLOADING_WIDTH * (value / 100)) + "px"; }, onComplete: function() { // Remove the tilting of the progress "speech bubble" tl.to(progress, { transform: "translateX(-50%)", }); uploadEnd(); } }); } function uploadEnd() { // Hide the progress "speech bubble" (Fade out) tl.to(progress, { opacity: 0, duration: ANIMATION_TIME, ease: "power2.out", onComplete: function() { btnUpload.style.backgroundImage = null; btnUpload.style.backgroundColor = BTN_BACKGROUND_COLOR; } }); // Change the background color of the container tl.to(container, { backgroundColor: COMPLETE_CONTAINER_BACKGROUND_COLOR, duration: ANIMATION_TIME, ease: "power2.out", }); // Change the background color, as well as the shape of the upload button // As the same time as the background color of the contaianer changes tl.to(btnUpload, { backgroundColor: COMPLETE_BTN_UPLOAD_BACKGROUND_COLOR, width: COMPLETE_SIZE, height: COMPLETE_SIZE, borderRadius: "50%", duration: ANIMATION_TIME, ease: "back.out", onComplete: function() { check.style.display = "block"; } }, "-=" + ANIMATION_TIME); // Show the tail of the completed check mark tl.to(check1, { height: CHECK_HEIGHT, duration: ANIMATION_TIME, ease: "power2.out" }); // Show the body of the completed check mark tl.to(check2, { width: CHECK_WIDTH, duration: ANIMATION_TIME, ease: "bounce.out", onComplete: function() { setTimeout(function() { // After 5000 milliseconds, return the button and // the container into original state initialize(); }, 5000); } }); } function initialize() { uploading = false; btnUpload.style.backgroundImage = null; progress.style.left = "0px"; progress.innerText = ""; tl.to(container, { backgroundColor: DEFAULT_CONTAINER_BACKGROUND_COLOR, duration: ANIMATION_TIME, ease: "power2.out", }); tl.to(btnUpload, { color: BTN_COLOR, fill: BTN_COLOR, backgroundColor: DEFAULT_BTN_UPLOAD_BACKGROUND_COLOR, width: BTN_WIDTH, height: BTN_HEIGHT, borderRadius: BTN_BORDER_RADIUS, duration: ANIMATION_TIME, ease: "bounce.out" }, "-=" + ANIMATION_TIME); tl.to(check, { opacity: 0, duration: ANIMATION_TIME, ease: "bounce.out", onComplete: function() { check.style.opacity = 1; check.style.display = "none"; check1.style.height = "0px"; check2.style.width = "0px"; } }, "-=" + ANIMATION_TIME); } btnUpload.addEventListener("click", function() { if (uploading === true) { return; } uploading = true; this.classList.add("btn-upload-uploading"); uploadStart(); uploadProcess(); });
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>使用GSAP上传进度动画微互动-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号