canvas-splash-screen
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -10,2 +10,3 @@ type CanvasSplashScreenConfig = { | ||
offsetY?: number; | ||
maxSize?: number; | ||
}; | ||
@@ -12,0 +13,0 @@ declare function createSplashScreen(configuration?: Partial<CanvasSplashScreenConfig>): { |
@@ -35,3 +35,4 @@ "use strict"; | ||
offsetX: 0, | ||
offsetY: 0 | ||
offsetY: 0, | ||
maxSize: 20 | ||
}; | ||
@@ -44,5 +45,3 @@ const config = { ...defaultConfig, ...configuration }; | ||
logoSize: size, | ||
angle, | ||
offsetX, | ||
offsetY | ||
maxSize | ||
} = config; | ||
@@ -73,4 +72,4 @@ if (!canvasElement) { | ||
let centerY = canvasElement.height / 2; | ||
const maxSize = Math.max(canvasElement.width, canvasElement.height) * 20; | ||
const animationProps = { size, angle: 0, opacity: 1, offsetX, offsetY }; | ||
maxSize = Math.max(canvasElement.width, canvasElement.height) * (maxSize ?? 20); | ||
const animationProps = { size, angle: 0, opacity: 1 }; | ||
const svgImage = new Image(); | ||
@@ -91,5 +90,3 @@ svgImage.src = svgBase64; | ||
size: maxSize, | ||
angle, | ||
offsetX, | ||
offsetY, | ||
angle: 180, | ||
duration: animationDuration, | ||
@@ -123,2 +120,3 @@ ease: import_gsap.Power1.easeIn | ||
ctx.fillRect(0, 0, canvasElement.width, canvasElement.height); | ||
ctx.save(); | ||
ctx.translate(centerX, centerY); | ||
@@ -140,3 +138,3 @@ ctx.rotate(animationProps.angle * Math.PI / 180); | ||
} | ||
const resize = () => { | ||
window.addEventListener("resize", () => { | ||
if (!canvasElement) | ||
@@ -148,4 +146,3 @@ return; | ||
centerY = canvasElement.height / 2; | ||
}; | ||
window.addEventListener("resize", resize); | ||
}); | ||
return { | ||
@@ -172,3 +169,2 @@ tl, | ||
return; | ||
window.removeEventListener("resize", resize); | ||
canvasElement.remove(); | ||
@@ -175,0 +171,0 @@ } |
{ | ||
"name": "canvas-splash-screen", | ||
"author": "Julio Merisio <contatomerisio@gmail.com>", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A canvas splash screen animation", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
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
28077
332