Major overhaul to the theme and now functioning.
This commit is contained in:
1 parent
5823ca3c39
commit
a475dfeab6
5218 files changed
+1643729
-13229
No files matched your search
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
.v-parallax {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.v-parallax--active > .v-img__img {
|
||||
will-change: transform;
|
||||
}
|
||||
Generated
Vendored
+176
@@ -0,0 +1,176 @@
|
||||
// Styles
|
||||
|
||||
export declare const makeVParallaxProps: <Defaults extends {
|
||||
class?: unknown;
|
||||
style?: unknown;
|
||||
scale?: unknown;
|
||||
} = {}>(defaults?: Defaults | undefined) => {
|
||||
class: unknown extends Defaults["class"] ? import("vue").PropType<any> : {
|
||||
type: import("vue").PropType<unknown extends Defaults["class"] ? any : any>;
|
||||
default: unknown extends Defaults["class"] ? any : any;
|
||||
};
|
||||
style: unknown extends Defaults["style"] ? {
|
||||
type: import("vue").PropType<import("vue").StyleValue>;
|
||||
default: null;
|
||||
} : Omit<{
|
||||
type: import("vue").PropType<import("vue").StyleValue>;
|
||||
default: null;
|
||||
}, "default" | "type"> & {
|
||||
type: import("vue").PropType<unknown extends Defaults["style"] ? import("vue").StyleValue : Defaults["style"] | import("vue").StyleValue>;
|
||||
default: unknown extends Defaults["style"] ? import("vue").StyleValue : Defaults["style"] | NonNullable<import("vue").StyleValue>;
|
||||
};
|
||||
scale: unknown extends Defaults["scale"] ? {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
} : Omit<{
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
}, "default" | "type"> & {
|
||||
type: import("vue").PropType<unknown extends Defaults["scale"] ? string | number : string | number | Defaults["scale"]>;
|
||||
default: unknown extends Defaults["scale"] ? string | number : Defaults["scale"] | NonNullable<string | number>;
|
||||
};
|
||||
};
|
||||
export declare const VParallax: {
|
||||
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<{
|
||||
style: string | false | import("vue").StyleValue[] | import("vue").CSSProperties | null;
|
||||
scale: string | number;
|
||||
} & {
|
||||
class?: any;
|
||||
} & {
|
||||
$children?: {
|
||||
default?: (() => import("vue").VNodeChild) | undefined;
|
||||
placeholder?: (() => import("vue").VNodeChild) | undefined;
|
||||
error?: (() => import("vue").VNodeChild) | undefined;
|
||||
sources?: (() => import("vue").VNodeChild) | undefined;
|
||||
} | {
|
||||
$stable?: boolean | undefined;
|
||||
} | (() => import("vue").VNodeChild) | import("vue").VNodeChild;
|
||||
"v-slots"?: {
|
||||
default?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
placeholder?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
error?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
sources?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
} | undefined;
|
||||
} & {
|
||||
"v-slot:default"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
"v-slot:error"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
"v-slot:placeholder"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
"v-slot:sources"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, {
|
||||
style: import("vue").StyleValue;
|
||||
scale: string | number;
|
||||
}, true, {}, import("vue").SlotsType<Partial<{
|
||||
default: () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[];
|
||||
placeholder: () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[];
|
||||
error: () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[];
|
||||
sources: () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[];
|
||||
}>>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
||||
P: {};
|
||||
B: {};
|
||||
D: {};
|
||||
C: {};
|
||||
M: {};
|
||||
Defaults: {};
|
||||
}, {
|
||||
style: string | false | import("vue").StyleValue[] | import("vue").CSSProperties | null;
|
||||
scale: string | number;
|
||||
} & {
|
||||
class?: any;
|
||||
} & {
|
||||
$children?: {
|
||||
default?: (() => import("vue").VNodeChild) | undefined;
|
||||
placeholder?: (() => import("vue").VNodeChild) | undefined;
|
||||
error?: (() => import("vue").VNodeChild) | undefined;
|
||||
sources?: (() => import("vue").VNodeChild) | undefined;
|
||||
} | {
|
||||
$stable?: boolean | undefined;
|
||||
} | (() => import("vue").VNodeChild) | import("vue").VNodeChild;
|
||||
"v-slots"?: {
|
||||
default?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
placeholder?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
error?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
sources?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
} | undefined;
|
||||
} & {
|
||||
"v-slot:default"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
"v-slot:error"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
"v-slot:placeholder"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
"v-slot:sources"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
}, {}, {}, {}, {}, {
|
||||
style: import("vue").StyleValue;
|
||||
scale: string | number;
|
||||
}>;
|
||||
__isFragment?: undefined;
|
||||
__isTeleport?: undefined;
|
||||
__isSuspense?: undefined;
|
||||
} & import("vue").ComponentOptionsBase<{
|
||||
style: string | false | import("vue").StyleValue[] | import("vue").CSSProperties | null;
|
||||
scale: string | number;
|
||||
} & {
|
||||
class?: any;
|
||||
} & {
|
||||
$children?: {
|
||||
default?: (() => import("vue").VNodeChild) | undefined;
|
||||
placeholder?: (() => import("vue").VNodeChild) | undefined;
|
||||
error?: (() => import("vue").VNodeChild) | undefined;
|
||||
sources?: (() => import("vue").VNodeChild) | undefined;
|
||||
} | {
|
||||
$stable?: boolean | undefined;
|
||||
} | (() => import("vue").VNodeChild) | import("vue").VNodeChild;
|
||||
"v-slots"?: {
|
||||
default?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
placeholder?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
error?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
sources?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
} | undefined;
|
||||
} & {
|
||||
"v-slot:default"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
"v-slot:error"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
"v-slot:placeholder"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
"v-slot:sources"?: false | (() => import("vue").VNodeChild) | undefined;
|
||||
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, {
|
||||
style: import("vue").StyleValue;
|
||||
scale: string | number;
|
||||
}, {}, string, import("vue").SlotsType<Partial<{
|
||||
default: () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[];
|
||||
placeholder: () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[];
|
||||
error: () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[];
|
||||
sources: () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[];
|
||||
}>>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & import("../../util/index.js").FilterPropsOptions<{
|
||||
class: import("vue").PropType<any>;
|
||||
style: {
|
||||
type: import("vue").PropType<import("vue").StyleValue>;
|
||||
default: null;
|
||||
};
|
||||
scale: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
}, import("vue").ExtractPropTypes<{
|
||||
class: import("vue").PropType<any>;
|
||||
style: {
|
||||
type: import("vue").PropType<import("vue").StyleValue>;
|
||||
default: null;
|
||||
};
|
||||
scale: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
}>>;
|
||||
export type VParallax = InstanceType<typeof VParallax>;
|
||||
Generated
Vendored
+96
@@ -0,0 +1,96 @@
|
||||
import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createVNode as _createVNode } from "vue";
|
||||
// Styles
|
||||
import "./VParallax.css";
|
||||
|
||||
// Components
|
||||
import { VImg } from "../VImg/index.js"; // Composables
|
||||
import { useDisplay } from "../../composables/index.js";
|
||||
import { makeComponentProps } from "../../composables/component.js";
|
||||
import { useIntersectionObserver } from "../../composables/intersectionObserver.js";
|
||||
import { useResizeObserver } from "../../composables/resizeObserver.js"; // Utilities
|
||||
import { computed, onBeforeUnmount, ref, watch, watchEffect } from 'vue';
|
||||
import { clamp, genericComponent, getScrollParent, PREFERS_REDUCED_MOTION, propsFactory, useRender } from "../../util/index.js"; // Types
|
||||
function floor(val) {
|
||||
return Math.floor(Math.abs(val)) * Math.sign(val);
|
||||
}
|
||||
export const makeVParallaxProps = propsFactory({
|
||||
scale: {
|
||||
type: [Number, String],
|
||||
default: 0.5
|
||||
},
|
||||
...makeComponentProps()
|
||||
}, 'VParallax');
|
||||
export const VParallax = genericComponent()({
|
||||
name: 'VParallax',
|
||||
props: makeVParallaxProps(),
|
||||
setup(props, _ref) {
|
||||
let {
|
||||
slots
|
||||
} = _ref;
|
||||
const {
|
||||
intersectionRef,
|
||||
isIntersecting
|
||||
} = useIntersectionObserver();
|
||||
const {
|
||||
resizeRef,
|
||||
contentRect
|
||||
} = useResizeObserver();
|
||||
const {
|
||||
height: displayHeight
|
||||
} = useDisplay();
|
||||
const root = ref();
|
||||
watchEffect(() => {
|
||||
intersectionRef.value = resizeRef.value = root.value?.$el;
|
||||
});
|
||||
let scrollParent;
|
||||
watch(isIntersecting, val => {
|
||||
if (val) {
|
||||
scrollParent = getScrollParent(intersectionRef.value);
|
||||
scrollParent = scrollParent === document.scrollingElement ? document : scrollParent;
|
||||
scrollParent.addEventListener('scroll', onScroll, {
|
||||
passive: true
|
||||
});
|
||||
onScroll();
|
||||
} else {
|
||||
scrollParent.removeEventListener('scroll', onScroll);
|
||||
}
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
scrollParent?.removeEventListener('scroll', onScroll);
|
||||
});
|
||||
watch(displayHeight, onScroll);
|
||||
watch(() => contentRect.value?.height, onScroll);
|
||||
const scale = computed(() => {
|
||||
return 1 - clamp(Number(props.scale));
|
||||
});
|
||||
let frame = -1;
|
||||
function onScroll() {
|
||||
if (!isIntersecting.value || PREFERS_REDUCED_MOTION()) return;
|
||||
cancelAnimationFrame(frame);
|
||||
frame = requestAnimationFrame(() => {
|
||||
const el = (root.value?.$el).querySelector('.v-img__img');
|
||||
if (!el) return;
|
||||
const scrollHeight = scrollParent instanceof Document ? document.documentElement.clientHeight : scrollParent.clientHeight;
|
||||
const scrollPos = scrollParent instanceof Document ? window.scrollY : scrollParent.scrollTop;
|
||||
const top = intersectionRef.value.getBoundingClientRect().top + scrollPos;
|
||||
const height = contentRect.value.height;
|
||||
const center = top + (height - scrollHeight) / 2;
|
||||
const translate = floor((scrollPos - center) * scale.value);
|
||||
const sizeScale = Math.max(1, (scale.value * (scrollHeight - height) + height) / height);
|
||||
el.style.setProperty('transform', `translateY(${translate}px) scale(${sizeScale})`);
|
||||
});
|
||||
}
|
||||
useRender(() => _createVNode(VImg, {
|
||||
"class": _normalizeClass(['v-parallax', {
|
||||
'v-parallax--active': isIntersecting.value
|
||||
}, props.class]),
|
||||
"style": _normalizeStyle(props.style),
|
||||
"ref": root,
|
||||
"cover": true,
|
||||
"onLoadstart": onScroll,
|
||||
"onLoad": onScroll
|
||||
}, slots));
|
||||
return {};
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=VParallax.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"VParallax.js","names":["VImg","useDisplay","makeComponentProps","useIntersectionObserver","useResizeObserver","computed","onBeforeUnmount","ref","watch","watchEffect","clamp","genericComponent","getScrollParent","PREFERS_REDUCED_MOTION","propsFactory","useRender","floor","val","Math","abs","sign","makeVParallaxProps","scale","type","Number","String","default","VParallax","name","props","setup","_ref","slots","intersectionRef","isIntersecting","resizeRef","contentRect","height","displayHeight","root","value","$el","scrollParent","document","scrollingElement","addEventListener","onScroll","passive","removeEventListener","frame","cancelAnimationFrame","requestAnimationFrame","el","querySelector","scrollHeight","Document","documentElement","clientHeight","scrollPos","window","scrollY","scrollTop","top","getBoundingClientRect","center","translate","sizeScale","max","style","setProperty","_createVNode","_normalizeClass","class","_normalizeStyle"],"sources":["../../../src/components/VParallax/VParallax.tsx"],"sourcesContent":["// Styles\nimport './VParallax.sass'\n\n// Components\nimport { VImg } from '@/components/VImg'\n\n// Composables\nimport { useDisplay } from '@/composables'\nimport { makeComponentProps } from '@/composables/component'\nimport { useIntersectionObserver } from '@/composables/intersectionObserver'\nimport { useResizeObserver } from '@/composables/resizeObserver'\n\n// Utilities\nimport { computed, onBeforeUnmount, ref, watch, watchEffect } from 'vue'\nimport { clamp, genericComponent, getScrollParent, PREFERS_REDUCED_MOTION, propsFactory, useRender } from '@/util'\n\n// Types\nimport type { VImgSlots } from '@/components/VImg/VImg'\n\nfunction floor (val: number) {\n return Math.floor(Math.abs(val)) * Math.sign(val)\n}\n\nexport const makeVParallaxProps = propsFactory({\n scale: {\n type: [Number, String],\n default: 0.5,\n },\n\n ...makeComponentProps(),\n}, 'VParallax')\n\nexport const VParallax = genericComponent<VImgSlots>()({\n name: 'VParallax',\n\n props: makeVParallaxProps(),\n\n setup (props, { slots }) {\n const { intersectionRef, isIntersecting } = useIntersectionObserver()\n const { resizeRef, contentRect } = useResizeObserver()\n const { height: displayHeight } = useDisplay()\n\n const root = ref<VImg>()\n\n watchEffect(() => {\n intersectionRef.value = resizeRef.value = root.value?.$el\n })\n\n let scrollParent: Element | Document\n watch(isIntersecting, val => {\n if (val) {\n scrollParent = getScrollParent(intersectionRef.value)\n scrollParent = scrollParent === document.scrollingElement ? document : scrollParent\n scrollParent.addEventListener('scroll', onScroll, { passive: true })\n onScroll()\n } else {\n scrollParent.removeEventListener('scroll', onScroll)\n }\n })\n\n onBeforeUnmount(() => {\n scrollParent?.removeEventListener('scroll', onScroll)\n })\n\n watch(displayHeight, onScroll)\n watch(() => contentRect.value?.height, onScroll)\n\n const scale = computed(() => {\n return 1 - clamp(Number(props.scale))\n })\n\n let frame = -1\n function onScroll () {\n if (!isIntersecting.value || PREFERS_REDUCED_MOTION()) return\n\n cancelAnimationFrame(frame)\n frame = requestAnimationFrame(() => {\n const el: HTMLElement | null = (root.value?.$el as Element).querySelector('.v-img__img')\n if (!el) return\n\n const scrollHeight = scrollParent instanceof Document ? document.documentElement.clientHeight : scrollParent.clientHeight\n const scrollPos = scrollParent instanceof Document ? window.scrollY : scrollParent.scrollTop\n const top = intersectionRef.value!.getBoundingClientRect().top + scrollPos\n const height = contentRect.value!.height\n\n const center = top + (height - scrollHeight) / 2\n const translate = floor((scrollPos - center) * scale.value)\n const sizeScale = Math.max(1, (scale.value * (scrollHeight - height) + height) / height)\n\n el.style.setProperty('transform', `translateY(${translate}px) scale(${sizeScale})`)\n })\n }\n\n useRender(() => (\n <VImg\n class={[\n 'v-parallax',\n { 'v-parallax--active': isIntersecting.value },\n props.class,\n ]}\n style={ props.style }\n ref={ root }\n cover\n onLoadstart={ onScroll }\n onLoad={ onScroll }\n v-slots={ slots }\n />\n ))\n\n return {}\n },\n})\n\nexport type VParallax = InstanceType<typeof VParallax>\n"],"mappings":";AAAA;AACA;;AAEA;AAAA,SACSA,IAAI,4BAEb;AAAA,SACSC,UAAU;AAAA,SACVC,kBAAkB;AAAA,SAClBC,uBAAuB;AAAA,SACvBC,iBAAiB,+CAE1B;AACA,SAASC,QAAQ,EAAEC,eAAe,EAAEC,GAAG,EAAEC,KAAK,EAAEC,WAAW,QAAQ,KAAK;AAAA,SAC/DC,KAAK,EAAEC,gBAAgB,EAAEC,eAAe,EAAEC,sBAAsB,EAAEC,YAAY,EAAEC,SAAS,+BAElG;AAGA,SAASC,KAAKA,CAAEC,GAAW,EAAE;EAC3B,OAAOC,IAAI,CAACF,KAAK,CAACE,IAAI,CAACC,GAAG,CAACF,GAAG,CLine truncated
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
@use '../../styles/tools'
|
||||
|
||||
@include tools.layer('components')
|
||||
.v-parallax
|
||||
position: relative
|
||||
overflow: hidden
|
||||
|
||||
&--active > .v-img__img
|
||||
will-change: transform
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export { VParallax } from './VParallax.js';
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export { VParallax } from "./VParallax.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["VParallax"],"sources":["../../../src/components/VParallax/index.ts"],"sourcesContent":["export { VParallax } from './VParallax'\n"],"mappings":"SAASA,SAAS","ignoreList":[]}
|
||||
Reference in new issue
Block a user