canvas-splash-screen
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -10,3 +10,3 @@ type CanvasSplashScreenConfig = { | ||
offsetY?: number; | ||
maxSize?: number; | ||
sizeMultiplier?: number; | ||
}; | ||
@@ -13,0 +13,0 @@ declare function createSplashScreen(configuration?: Partial<CanvasSplashScreenConfig>): { |
@@ -29,4 +29,4 @@ "use strict"; | ||
let defaultConfig = { | ||
logoUrl: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTM0IiBoZWlnaHQ9IjgwMCIgdmlld0JveD0iMCAwIDUzNCA4MDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik0wLjMzMzI1MiAwSDUzMy42NjdWMjY2LjY2N0gyNjdMMC4zMzMyNTIgMFpNMC4zMzMyNTIgMjY2LjY2N0gyNjdMNTMzLjY2NyA1MzMuMzMzSDAuMzMzMjUyVjI2Ni42NjdaTTAuMzMzMjUyIDUzMy4zMzNIMjY3VjgwMEwwLjMzMzI1MiA1MzMuMzMzWiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+Cg==", | ||
animationDuration: 2.2, | ||
logoUrl: "", | ||
animationDuration: 1.8, | ||
logoSize: 50, | ||
@@ -37,3 +37,3 @@ angle: 360, | ||
offsetY: 0, | ||
maxSize: 20 | ||
sizeMultiplier: 20 | ||
}; | ||
@@ -46,3 +46,3 @@ const config = { ...defaultConfig, ...configuration }; | ||
logoSize: size, | ||
maxSize | ||
sizeMultiplier | ||
} = config; | ||
@@ -55,3 +55,2 @@ if (!canvasElement) { | ||
fallbackCanvas.style.inset = "0"; | ||
fallbackCanvas.style.pointerEvents = "none"; | ||
canvasElement = fallbackCanvas; | ||
@@ -74,3 +73,3 @@ document.body.appendChild(fallbackCanvas); | ||
let centerY = canvasElement.height / 2; | ||
maxSize = Math.max(canvasElement.width, canvasElement.height) * (maxSize ?? 20); | ||
sizeMultiplier = Math.max(canvasElement.width, canvasElement.height) * (sizeMultiplier ?? 20); | ||
const animationProps = { size, angle: 0, opacity: 1 }; | ||
@@ -85,3 +84,3 @@ const svgImage = new Image(); | ||
tl.to(animationProps, { | ||
size: 45, | ||
size: size - size * 0.1, | ||
duration: 0.3, | ||
@@ -92,3 +91,3 @@ ease: import_gsap.Power1.easeInOut, | ||
tl.to(animationProps, { | ||
size: maxSize, | ||
size: sizeMultiplier, | ||
angle: 180, | ||
@@ -108,7 +107,7 @@ duration: animationDuration, | ||
opacity: 0, | ||
duration: 0.8, | ||
ease: import_gsap.Power1.easeInOut, | ||
duration: 0.5, | ||
ease: import_gsap.Power1.easeIn, | ||
onUpdate: draw | ||
}, | ||
"<-0.1" | ||
"-=0.3" | ||
); | ||
@@ -141,3 +140,3 @@ }; | ||
} | ||
window.addEventListener("resize", () => { | ||
const onResize = () => { | ||
if (!canvasElement) | ||
@@ -149,3 +148,4 @@ return; | ||
centerY = canvasElement.height / 2; | ||
}); | ||
}; | ||
window.addEventListener("resize", onResize); | ||
return { | ||
@@ -172,2 +172,3 @@ tl, | ||
return; | ||
window.removeEventListener("resize", onResize); | ||
canvasElement.remove(); | ||
@@ -174,0 +175,0 @@ } |
{ | ||
"name": "canvas-splash-screen", | ||
"author": "Julio Merisio <contatomerisio@gmail.com>", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "A canvas splash screen animation", | ||
"scripts": { | ||
"build": "tsup ./src" | ||
}, | ||
"keywords": [ | ||
@@ -11,5 +14,6 @@ "canvas", | ||
"animation", | ||
"into", | ||
"gsap" | ||
], | ||
"license": "ISC", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
@@ -36,7 +40,3 @@ "gsap": ">=3" | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"scripts": { | ||
"test": "vitest", | ||
"build": "tsup ./src" | ||
} | ||
} | ||
"types": "./dist/index.d.ts" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
26662