gsap实现图片拖动上传动画效果代码
代码语言:html
所属分类:上传
代码描述:gsap实现图片拖动上传动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url("https://fonts.googleapis.com/css?family=Nunito:400,600,700&display=swap"); * { box-sizing: border-box; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } body { background-image: linear-gradient(102.7deg, #fddaff 8.2%, #dfadfc 19.6%, #adcdfc 36.8%, #adfcf4 73.2%, #caf8d0 90.9%); background-attachment: fixed; background-repeat: no-repeat; background-size: cover; font-family: "Nunito", sans-serif; color: #4f555f; display: flex; flex-direction: column; padding: 20px; height: 100vh; overflow: hidden; } .droppable { max-width: 400px; width: 100%; height: 360px; background-color: #fff; margin: auto; display: flex; flex-wrap: wrap; position: relative; border-radius: 12px; align-content: flex-start; overflow: hidden; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); transition: 0.3s; } .droppable.is-dragging .list > * { pointer-events: none; } .list { overflow: auto; width: 100%; height: 100%; padding: 10px 0; scroll-behavior: smooth; } .droppable.is-over { box-shadow: 0px 10px 26px rgba(30, 24, 37, 0.33), 0 0 0px 15px rgba(53, 40, 66, 0.07); } .item { padding: 10px 20px; width: 100%; display: flex; flex-wrap: wrap; align-items: center; overflow: hidden; } .item > * { opacity: 0; } .item-img { width: 60px; height: 48px; border-radius: 4px; overflow: hidden; } .loaded-image { position: absolute; top: 0; transform-origin: center; left: 0; opacity: 0; width: 60px; height: 48px; border-radius: 4px; overflow: hidden; background-image: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%); } .loaded-image > img { opacity: 0; filter: blur(10px); } .loaded-image > span { position: absolute; left: 50%; opacity: 0; width: 32px; height: 32px; transform: translate(-50%, -50%); transform-origin: center; top: 50%; } .loaded-image svg { width: 32px; height: 32px; } img { -o-object-fit: cover; object-fit: cover; -o-object-position: center; object-position: center; width: 100%; height: 100%; } img:before { position: absolute; content: ""; height: 100%; width: 100%; background-image: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%); } .item-details { flex: 1; padding-left: 16px; overflow: hidden; padding-right: 32px; } .item-name { font-size: 15px; margin-bottom: 4px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-weight: 600; } .item-size { font-size: 11px; letter-spacing: 1px; color: #9699b3; } .item-delete { border: 0; background-color: transparent; width: 18px; height: 18px; padding: 0; margin-right: 6px; color: transparent; white-space: nowrap; outline: 0; cursor: pointer; position: relative; } .item-delete:before { content: ""; position: absolute; left: 0; transition: 0.3s; top: 0; z-index: 1; width: 100%; height: 100%; background-size: cover; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg fill='%23bac1cb' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 438.5 438.5'%3e%3cpath d='M417.7 75.7A8.9 8.9 0 00411 73H323l-20-47.7c-2.8-7-8-13-15.4-18S272.5 0 264.9 0h-91.3C166 0 158.5 2.5 151 7.4c-7.4 5-12.5 11-15.4 18l-20 47.7H27.4a9 9 0 00-6.6 2.6 9 9 0 00-2.5 6.5v18.3c0 2.7.8 4.8 2.5 6.6a8.9 8.9 0 006.6 2.5h27.4v271.8c0 15.8 4.5 29.3 13.4 40.4a40.2 40.2 0 0032.3 16.7H338c12.6 0 23.4-5.7 32.3-17.2a64.8 64.8 0 0013.4-41V109.6h27.4c2.7 0 4.9-.8 6.6-2.5a8.9 8.9 0 002.6-6.6V82.2a9 9 0 00-2.6-6.5zm-248.4-36a8 8 0 014.9-3.2h90.5a8 8 0 014.8 3.2L283.2 73H155.3l14-33.4zm177.9 340.6a32.4 32.4 0 01-6.2 19.3c-1.4 1.6-2.4 2.4-3 2.4H100.5c-.6 0-1.6-.8-3-2.4a32.5 32.5 0 01-6.1-19.3V109.6h255.8v270.7z'/%3e%3cpath d='M137 347.2h18.3c2.7 0 4.9-.9 6.6-2.6a9 9 0 002.5-6.6V173.6a9 9 0 00-2.5-6.6 8.9 8.9 0 00-6.6-2.6H137c-2.6 0-4.8.9-6.5 2.6a8.9 8.9 0 00-2.6 6.6V338c0 2.7.9 4.9 2.6 6.6a8.9 8.9 0 006.5 2.6zM210.1 347.2h18.3a8.9 8.9 0 009.1-9.1V173.5c0-2.7-.8-4.9-2.5-6.6a8.9 8.9 0 00-6.6-2.6h-18.3a8.9 8.9 0 00-9.1 9.1V338a8.9 8.9 0 009.1 9.1zM283.2 347.2h18.3c2.7 0 4.8-.9 6.6-2.6a8.9 8.9 0 002.5-6.6V173.6c0-2.7-.8-4.9-2.5-6.6a8.9 8.9 0 00-6.6-2.6h-18.3a9 9 0 00-6.6 2.6 8.9 8.9 0 00-2.5 6.6V338a9 9 0 002.5 6.6 9 9 0 006.6 2.6z'/%3e%3c/svg%3e"); } .item-delete:after { content: ""; position: absolute; opacity: 0; left: 50%; top: 50%; width: 100%; height: 100%; transform: translate(-50%, -50%) scale(0); background-color: #f3dbff; border-radius: 50%; transition: 0.3s; } .item-delete:hover:after { transform: translate(-50%, -50%) scale(2.2); opacity: 1; } .item-delete:hover:before { background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg fill='%234f555f' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 438.5 438.5'%3e%3cpath d='M417.7 75.7A8.9 8.9 0 00411 73H323l-20-47.7c-2.8-7-8-13-15.4-18S272.5 0 264.9 0h-91.3C166 0 158.5 2.5 151 7.4c-7.4 5-12.5 11-15.4 18l-20 47.7H27.4a9 9 0 00-6.6 2.6 9 9 0 00-2.5 6.5v18.3c0 2.7.8 4.8 2.5 6.6a8.9 8.9 0 006.6 2.5h27.4v271.8c0 15.8 4.5 29.3 13.4 40.4a40.2 40.2 0 0032.3 16.7H338c12.6 0 23.4-5.7 32.3-17.2a64.8 64.8 0 0013.4-41V109.6h27.4c2.7 0 4.9-.8 6.6-2.5a8.9 8.9 0 002.6-6.6V82.2a9 9 0 00-2.6-6.5zm-248.4-36a8 8 0 014.9-3.2h90.5a8 8 0 014.8 3.2L283.2 73H155.3l14-33.4zm177.9 340.6a32.4 32.4 0 01-6.2 19.3c-1.4 1.6-2.4 2.4-3 2.4H100.5c-.6 0-1.6-.8-3-2.4a32.5 32.5 0 01-6.1-19.3V109.6h255.8v270.7z'/%3e%3cpath d='M137 347.2h18.3c2.7 0 4.9-.9 6.6-2.6a9 9 0 002.5-6.6V173.6a9 9 0 00-2.5-6.6 8.9 8.9 0 00-6.6-2.6H137c-2.6 0-4.8.9-6.5 2.6a8.9 8.9 0 00-2.6 6.6V338c0 2.7.9 4.9 2.6 6.6a8.9 8.9 0 006.5 2.6zM210.1 347.2h18.3a8.9 8.9 0 009.1-9.1V173.5c0-2.7-.8-4.9-2.5-6.6a8.9 8.9 0 00-6.6-2.6h-18.3a8.9 8.9 0 00-9.1 9.1V338a8.9 8.9 0 009.1 9.1zM283.2 347.2h18.3c2.7 0 4.8-.9 6.6-2.6a8.9 8.9 0 002.5-6.6V173.6c0-2.7-.8-4.9-2.5-6.6a8.9 8.9 0 00-6.6-2.6h-18.3a9 9 0 00-6.6 2.6 8.9 8.9 0 00-2.5 6.6V338a9 9 0 002.5 6.6 9 9 0 006.6 2.6z'/%3e%3c/svg%3e"); } .droppable.is-over .item { opacity: 0.5; transition: 0.3s; } .info { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: 0.4s; } .list:empty + .info { opacity: 1; } .info-item { position: absolute; left: 0; top: 0; height: 100%; width: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 20px; } .info-svg { width: 80px; margin-bottom: 20px; } .info-text { font-size: 20px; font-weight: 600; } </style> </head> <body> <div class="droppable"> <div class="list"></div> <div class="info"> <div class="info-drag info-item"> <svg class="info-svg" fill="#3f4754" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <path class="filled-ball" d="M149.332031 360.078125c0 41.238281-33.429687 74.667969-74.664062 74.667969C33.429688 434.746094 0 401.316406 0 360.078125c0-41.234375 33.429688-74.664063 74.667969-74.664063 41.234375 0 74.664062 33.429688 74.664062 74.664063zm0 0" fill="#e0c3fc"/> <path class="ball" d="M220.332031 304.078125c0 41.238281-33.429687 74.667969-74.664062 74.667969C104.429688 378.746094 71 345.316406 71 304.078125c0-41.234375 33.429688-74.664063 74.667969-74.664063 41.234375 0 74.664062 33.429688 74.664062 74.664063zm0 0" fill="#8ec5fc" opacity="0" /> <path class="hand" d="M331.734375 509.414062H202.667969c-5.890625 0-10.667969-4.78125-10.667969-10.667968 0-29.417969 23.9375-53.332032 53.332031-53.332032H262.25l-81.558594-81.558593c-12.96875-12.96875-12.96875-34.113281 0-47.082031 12.992188-12.949219 34.113282-12.949219 47.085938 0l19.132812 19.113281c1.625-3.625 3.90625-7.039063 6.890625-10.027344 7.40625-7.402344 18.050781-10.835937 28.203125-9.429687 1.21875-6.3125 4.246094-12.351563 9.132813-17.234376 9.320312-9.34375 22.824219-11.96875 34.496093-7.894531 1.554688-4.90625 4.289063-9.535156 8.167969-13.441406 12.972657-12.96875 34.113281-12.96875 47.085938 0l33.066406 33.089844C435.902344 332.902344 448 362.105469 448 393.167969c0 64.105469-52.160156 116.246093-116.265625 116.246093zm-116.585937-21.335937h116.585937c52.351563 0 94.933594-42.578125 94.933594-94.910156 0-25.367188-9.878907-49.214844-27.796875-67.113281l-33.070313-33.089844c-4.671875-4.671875-12.242187-4.671875-16.914062 0s-4.671875 12.246094 0 16.917968C350.953125 311.953125 352 314.683594 352 317.414062c0 2.730469-1.046875 5.460938-3.113281 7.550782-4.160157 4.160156-10.925781 4.160156-15.085938 0l-10.664062-10.667969c-4.671875-4.671875-12.246094-4.671875-16.917969 0-2.261719 2.242187-3.5 5.269531-3.5 8.449219 0 3.179687 1.238281 6.207031 3.5 8.449218l10.667969 10.664063C318.953125 343.953125 320 346.683594 320 349.414062c0 2.730469-1.046875 5.460938-3.113281 7.550782-4.160157 4.160156-10.925781 4.160156-15.085938 0l-16-16c-4.519531-4.5-12.394531-4.5-16.914062 0-2.261719 2.238281-3.5 5.269531-3.5 8.449218 0 3.175782 1.238281 6.164063 3.476562 8.445313l26.6875 26.691406c2.070313 2.066407 3.117188 4.796875 3.117188 7.527344s-1.046875 5.460937-3.117188 7.554687c-4.160156 4.160157-10.921875 4.160157-15.082031 0l-67.777344-67.777343c-4.671875-4.671875-12.242187-4.671875-16.914062 0-2.261719 2.238281-3.5 5.269531-3.5 8.449219 0 3.175781 1.238281 6.207031 3.5 8.445312l99.773437 99.777344c3.050781 3.050781 3.96875 7.636718 2.304688 11.625-1.640625 3.992187-5.546875 6.59375-9.855469 6.59375h-42.667969c-13.90625 0-25.769531 8.917968-30.183593 21.332031zm0 0"/> <path d="M74.667969 434.746094C33.492188 434.746094 0 401.253906 0 360.078125c0-41.171875 33.492188-74.664063 74.667969-74.664063 41.171875 0 74.664062 33.492188 74.664062 74.664063 0 41.175781-33.492187 74.667969-74.664062 74.667969zm0-128c-29.398438 0-53.335938 23.914062-53.335938 53.332031 0 29.421875 23.9375 53.335937 53.335938 53.335937C104.0625 413.414062 128 389.5 128 360.078125c0-29.417969-23.9375-53.332031-53.332031-53.332031zm0 0"/> <path d="M452.414062 144.976562c-4.796874 0-9.171874-3.265624-10.34375-8.148437-1.386718-5.742187 2.132813-11.5 7.851563-12.886719 5.78125-1.410156 11.261719-3.753906 16.253906-6.976562 4.949219-3.15625 11.5625-1.75 14.742188 3.199218 3.179687 4.949219 1.769531 11.5625-3.199219 14.742188-7 4.5-14.65625 7.785156-22.765625 9.769531-.851563.191407-1.707031.300781-2.539063.300781zm-41.703124-4.011718c-1.472657 0-2.988282-.320313-4.4375-.960938-7.554688-3.453125-14.464844-8.128906-20.503907-13.910156-4.265625-4.050781-4.414062-10.8125-.339843-15.082031 4.074218-4.265625 10.835937-4.4375 15.082031-.339844 4.308593 4.117187 9.238281 7.464844 14.65625 9.917969 5.355469 2.457031 7.703125 8.769531 5.269531 14.144531-1.792969 3.925781-5.675781 6.230469-9.726562 6.230469zm87.125-37.2.........完整代码请登录后点击上方下载按钮下载查看
网友评论0