button-animation
Advanced tools
Comparing version 1.0.1 to 1.0.2
export function buttonAnimation (e) { | ||
e.target.style.position = 'relative' | ||
e.target.style.overflow = 'hidden' | ||
let style = document.querySelector('style') | ||
style.innerHTML += | ||
'.buttonAnimation { \n' + | ||
' position: absolute; \n' + | ||
' height: 400px; \n' + | ||
' width: 400px; \n' + | ||
' background: #fff; \n' + | ||
' top: 0; \n' + | ||
' left: 0; \n' + | ||
' border-radius: 50%; \n' + | ||
' transform: translate(-50%, -50%); \n' + | ||
' opacity: 0.5; \n' + | ||
' animation: buttonAnimation 0.5s linear infinite; \n' + | ||
'} \n' + | ||
'@keyframes buttonAnimation { \n' + | ||
' 0% { \n' + | ||
' height: 0px; \n' + | ||
' width: 0px; \n' + | ||
' opacity: 0.5; \n' + | ||
' } \n' + | ||
' 100% { \n' + | ||
' height: 400px; \n' + | ||
' width: 400px; \n' + | ||
' opacity: 0; \n' + | ||
' } \n' + | ||
'} \n' | ||
const style = document.createElement('style') | ||
style.innerHTML = '.buttonAnimation {' + | ||
' position: absolute;' + | ||
' height: 400px;' + | ||
' width: 400px;' + | ||
' background: #fff;' + | ||
' top: 0;' + | ||
' left: 0;' + | ||
' border-radius: 50%;' + | ||
' transform: translate(-50%, -50%);' + | ||
' opacity: 0.5;' + | ||
' animation: buttonAnimation 0.5s linear infinite;' + | ||
'}' + | ||
'@keyframes buttonAnimation {' + | ||
' 0% {' + | ||
' height: 0px;' + | ||
' width: 0px;' + | ||
' opacity: 0.5;' + | ||
' }' + | ||
' 100% {' + | ||
' height: 400px;' + | ||
' width: 400px;' + | ||
' opacity: 0;' + | ||
' }' + | ||
'}' | ||
e.target.appendChild(style) | ||
e.target.style.cssText = 'position:relative;overflow:hidden;' | ||
const overlay = document.createElement('span') | ||
@@ -39,3 +38,4 @@ overlay.classList.add('buttonAnimation') | ||
overlay.remove() | ||
style.remove() | ||
}, 500) | ||
} |
{ | ||
"name": "button-animation", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "一个b站上学习到的按钮点击动画", | ||
@@ -5,0 +5,0 @@ "main": "btnAnimation.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2393