From c1bb2f31bc2b10a3ec9f95456fd9592a8babd727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Sun, 19 Apr 2020 12:49:38 +0200 Subject: [PATCH] Place: Use Rellax to add some parallax effects - Added on title, switcher button and illustration - Not very suitable for photo number --- package.json | 1 + pnpm-lock.yaml | 6 ++++ src/animations/place.js | 9 ++++- src/routes/location/[country]/[place].svelte | 36 +++++++++++--------- src/style/pages/_place.scss | 9 +++-- 5 files changed, 41 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 96656b0..1bf7960 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "lazysizes": "^5.2.0", "normalize.css": "^8.0.1", "polka": "^1.0.0-next.11", + "rellax": "^1.12.1", "scroll-out": "^2.2.8", "sirv": "^0.4.2", "svelte-lazy": "^0.1.10", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f3f351c..8cd1a7f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,7 @@ dependencies: lazysizes: 5.2.0 normalize.css: 8.0.1 polka: 1.0.0-next.11 + rellax: 1.12.1 scroll-out: 2.2.8 sirv: 0.4.2 svelte-lazy: 0.1.10 @@ -3199,6 +3200,10 @@ packages: node: '>= 0.10' resolution: integrity: sha1-VNvzd+UUQKypCkzSdGANP/LYiKk= + /rellax/1.12.1: + dev: false + resolution: + integrity: sha512-XBIi0CDpW5FLTujYjYBn1CIbK2CJL6TsAg/w409KghP2LucjjzBjsujXDAjyBLWgsfupfUcL5WzdnIPcGfK7XA== /repeating/2.0.1: dependencies: is-finite: 1.1.0 @@ -3913,6 +3918,7 @@ specifiers: postcss: ^7.0.27 postcss-load-config: ^2.1.0 postcss-preset-env: ^6.7.0 + rellax: ^1.12.1 rollup: ^2.6.1 rollup-plugin-babel: ^4.4.0 rollup-plugin-glslify: ^1.2.0 diff --git a/src/animations/place.js b/src/animations/place.js index 79b8aad..3d012ca 100644 --- a/src/animations/place.js +++ b/src/animations/place.js @@ -1,4 +1,5 @@ import anime from 'animejs' +import Rellax from 'rellax' import { animDuration, animDelay } from 'utils/store' @@ -52,4 +53,10 @@ export const animateIn = () => { translateY: [24, 0], translateZ: [0, 0] }, 450) -} + + + /* + ** Parallax + */ + const rellax = new Rellax('[data-rellax-speed]') +} \ No newline at end of file diff --git a/src/routes/location/[country]/[place].svelte b/src/routes/location/[country]/[place].svelte index d21cacc..0da9808 100644 --- a/src/routes/location/[country]/[place].svelte +++ b/src/routes/location/[country]/[place].svelte @@ -53,6 +53,7 @@ pageAnimation.set(animateIn) let layoutSetting let windowWidth + $: latestPhoto = photos[0] // Update current location const location = $locations.find(loc => loc.slug === $page.params.place) @@ -61,7 +62,6 @@ currentPhotos.set(photos) // Define dates - $: latestPhoto = photos[0] $: latestPhotoModified = latestPhoto ? latestPhoto.modified_on.replace(' ', 'T') : '' $: dateUpdatedFull = latestPhoto ? formatDate(latestPhotoModified, 'FULL') : '' $: dateUpdatedDatetime = latestPhoto ? formatDate(latestPhotoModified, 'DATETIME') : '' @@ -110,7 +110,7 @@
-

+

Houses of @@ -120,15 +120,17 @@

- - - - Change - - - - - +
+ + + + Change + + + + + +
@@ -158,12 +160,14 @@
- {#if illu_desktop || illu_mobile} + {#if illu_desktop || illu_desktop_2x || illu_mobile}
-
+
+
+
{/if}
diff --git a/src/style/pages/_place.scss b/src/style/pages/_place.scss index 4167eb6..b66dd56 100644 --- a/src/style/pages/_place.scss +++ b/src/style/pages/_place.scss @@ -171,7 +171,11 @@ height: 100%; will-change: transform, opacity; - div { + .parallax { + width: 100%; + height: 100%; + } + &_img { position: relative; left: 50%; width: 100%; @@ -191,6 +195,5 @@ background-image: var(--url-desktop-2x); } } - } -} +} \ No newline at end of file