From 5d72fa6b64d1bb97e56505cb32919be614901be0 Mon Sep 17 00:00:00 2001 From: alikia2x Date: Mon, 26 Aug 2024 02:18:15 +0800 Subject: [PATCH] add: docker support --- Dockerfile | 20 ++++++++++++++++++++ docker-compose.yml | 15 +++++++++++++++ package.json | 2 +- src/lib/graphics/smoothScroll.ts | 25 +++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 src/lib/graphics/smoothScroll.ts diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9bca757 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Use the official Bun image as the base image +FROM oven/bun:latest + +# Set the working directory inside the container +WORKDIR /app + +# Copy the package.json and bun.lockb files to the working directory +COPY package.json bun.lockb ./ + +# Install dependencies +RUN bun install + +# Copy the rest of the application code +COPY . . + +# Expose the port the app runs on +EXPOSE 4173 + +# Command to run the application +CMD ["bun", "go"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..05e4800 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3.8' + +services: + aquavox: + build: . + ports: + - "4173:4173" + environment: + - NODE_ENV=production + volumes: + - .:/app + command: ["bun", "go"] + +volumes: + node_modules: diff --git a/package.json b/package.json index db47cc3..d192454 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aquavox", - "version": "2.0.2", + "version": "2.0.3", "private": false, "scripts": { "dev": "vite dev", diff --git a/src/lib/graphics/smoothScroll.ts b/src/lib/graphics/smoothScroll.ts new file mode 100644 index 0000000..d49a875 --- /dev/null +++ b/src/lib/graphics/smoothScroll.ts @@ -0,0 +1,25 @@ +import BezierEasing from 'bezier-easing'; + +export function smoothScrollTo(element: HTMLElement, to: number, duration: number, timingFunction: Function) { + const start = element.scrollTop; + const change = to - start; + const startTime = performance.now(); + + function animateScroll(timestamp: number) { + const elapsedTime = timestamp - startTime; + const progress = Math.min(elapsedTime / duration, 1); + const easedProgress = timingFunction(progress, 0.38, 0, 0.24, 0.99); + element.scrollTop = start + change * easedProgress; + + if (elapsedTime < duration) { + requestAnimationFrame(animateScroll); + } + } + + requestAnimationFrame(animateScroll); +} + +// Define your custom Bézier curve function +export function customBezier(progress: number, p1x: number, p1y: number, p2x: number, p2y: number) { + return BezierEasing(p1x, p1y, p2x, p2y)(progress); +} \ No newline at end of file