tecitheme 0.14.1 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getColorStyles, getGridItemSizeStyles, getGridSizeStyles, getTeciImageURL, makeIdString, triggerWhenVisible } from "../utils";
|
|
2
|
+
import { conditionalTransition, getColorStyles, getGridItemSizeStyles, getGridSizeStyles, getTeciImageURL, makeIdString, triggerWhenVisible } from "../utils";
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
import { cubicInOut } from "svelte/easing";
|
|
5
5
|
import { writable } from "svelte/store";
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
rows,
|
|
18
18
|
button,
|
|
19
19
|
items,
|
|
20
|
-
animateOnScroll = true
|
|
20
|
+
animateOnScroll = true,
|
|
21
|
+
animate = true,
|
|
21
22
|
} = data;
|
|
22
23
|
|
|
23
24
|
let id = makeIdString(name);
|
|
@@ -25,7 +26,9 @@
|
|
|
25
26
|
// Detect if the heading is visible, then trigger animations
|
|
26
27
|
let scrollTargetVisible = writable(false);
|
|
27
28
|
onMount(() => {
|
|
28
|
-
|
|
29
|
+
if (animate) {
|
|
30
|
+
triggerWhenVisible(scrollTargetVisible, id+"Heading", !animateOnScroll)
|
|
31
|
+
}
|
|
29
32
|
})
|
|
30
33
|
</script>
|
|
31
34
|
|
|
@@ -42,9 +45,9 @@
|
|
|
42
45
|
<div class="mt-10 grid grid-cols-1 gap-4 sm:mt-16 {getGridSizeStyles(columns, rows)}">
|
|
43
46
|
|
|
44
47
|
{#each items as item, index}
|
|
45
|
-
{#if $scrollTargetVisible}
|
|
48
|
+
{#if $scrollTargetVisible || !animate}
|
|
46
49
|
<div class="relative {getGridItemSizeStyles(item.width, item.height)}"
|
|
47
|
-
in:
|
|
50
|
+
in:conditionalTransition={{ fn:fly, condition:animate, delay: index*100, duration: 1500, easing: cubicInOut, x:'100%'}}
|
|
48
51
|
>
|
|
49
52
|
<a class="relative flex h-full flex-col overflow-hidden shadow ring-1 ring-black/5 {item.url ? "hover:scale-105 transition ease-in-out delay-75" : ""}" href={item.url} rel="external">
|
|
50
53
|
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
color,
|
|
18
18
|
image,
|
|
19
19
|
button,
|
|
20
|
-
animateOnScroll = true
|
|
20
|
+
animateOnScroll = true,
|
|
21
|
+
animate = true
|
|
21
22
|
} = data;
|
|
22
23
|
|
|
23
24
|
let id = makeIdString(name);
|
|
@@ -25,7 +26,9 @@
|
|
|
25
26
|
// Detect if the heading is visible, then trigger animations
|
|
26
27
|
let scrollTargetVisible = writable(false);
|
|
27
28
|
onMount(() => {
|
|
28
|
-
|
|
29
|
+
if (animate) {
|
|
30
|
+
triggerWhenVisible(scrollTargetVisible, id+"Heading", !animateOnScroll)
|
|
31
|
+
}
|
|
29
32
|
})
|
|
30
33
|
|
|
31
34
|
</script>
|
|
@@ -47,7 +50,7 @@
|
|
|
47
50
|
<!-- Heading -->
|
|
48
51
|
<a id={id+"Heading"} href={`#${id}`} class="text-4xl font-semibold tracking-tight text-pretty sm:text-5xl">{heading}</a>
|
|
49
52
|
|
|
50
|
-
{#if $scrollTargetVisible}
|
|
53
|
+
{#if $scrollTargetVisible || !animate}
|
|
51
54
|
<!-- Text -->
|
|
52
55
|
<p
|
|
53
56
|
class="mt-6 text-lg/8 text-pretty"
|
|
@@ -69,12 +72,12 @@
|
|
|
69
72
|
</li>
|
|
70
73
|
{/each}
|
|
71
74
|
</ul>
|
|
72
|
-
{:else}
|
|
75
|
+
{:else if animate}
|
|
73
76
|
<div class="h-32"></div>
|
|
74
77
|
{/if}
|
|
75
78
|
|
|
76
79
|
<!-- Button -->
|
|
77
|
-
{#if $scrollTargetVisible}
|
|
80
|
+
{#if $scrollTargetVisible || !animate}
|
|
78
81
|
<div
|
|
79
82
|
class="mt-10 flex"
|
|
80
83
|
in:fly={{ delay: 300, duration: 1750, easing: cubicInOut, x:"100%"}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getColorStyles, makeIdString, triggerWhenVisible } from "../utils";
|
|
2
|
+
import { conditionalTransition, getColorStyles, makeIdString, triggerWhenVisible } from "../utils";
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
import { fly, fade } from "svelte/transition";
|
|
5
5
|
import Button from "./Button.svelte";
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
icon,
|
|
20
20
|
testimonial,
|
|
21
21
|
textPosition,
|
|
22
|
-
animateOnScroll = true
|
|
22
|
+
animateOnScroll = true,
|
|
23
|
+
animate = true
|
|
23
24
|
} = data;
|
|
24
25
|
|
|
25
26
|
// Initialize Text Position if left undefined
|
|
@@ -28,7 +29,9 @@
|
|
|
28
29
|
// Detect if the heading is visible, then trigger animations
|
|
29
30
|
let scrollTargetVisible = writable(false);
|
|
30
31
|
onMount(() => {
|
|
31
|
-
|
|
32
|
+
if (animate) {
|
|
33
|
+
triggerWhenVisible(scrollTargetVisible, id+"text", !animateOnScroll)
|
|
34
|
+
}
|
|
32
35
|
})
|
|
33
36
|
|
|
34
37
|
</script>
|
|
@@ -40,7 +43,7 @@
|
|
|
40
43
|
|
|
41
44
|
<!-- Text -->
|
|
42
45
|
<div id={id+"text"} class="mx-auto max-w-xl px-6 lg:mx-0 lg:max-w-none lg:px-0 lg:py-16 {textPosition == "left" ? "" : "lg-col-start-2"} relative">
|
|
43
|
-
{#if !$scrollTargetVisible}
|
|
46
|
+
{#if !$scrollTargetVisible && animate}
|
|
44
47
|
<div
|
|
45
48
|
out:fade={{delay: 0, duration: 500, easing:cubicInOut}}
|
|
46
49
|
class="absolute top-0 bottom-0 w-full bg-gray-200 animate-pulse my-16"
|
|
@@ -50,22 +53,22 @@
|
|
|
50
53
|
<div>
|
|
51
54
|
|
|
52
55
|
<!-- Icon -->
|
|
53
|
-
{#if icon && $scrollTargetVisible}
|
|
56
|
+
{#if icon && ($scrollTargetVisible || !animate)}
|
|
54
57
|
<div
|
|
55
58
|
class="hidden sm:flex size-16 items-center justify-center sm:shrink-0 flex-shrink-0 {getColorStyles("background", color)} text-3xl"
|
|
56
|
-
in:
|
|
57
|
-
out:
|
|
59
|
+
in:conditionalTransition={{ fn: fade, condition: animate, delay: 200, duration: 750, easing:cubicInOut}}
|
|
60
|
+
out:conditionalTransition={{fn: fade, condition: animate, delay: 200, duration: 750, easing:cubicInOut}}
|
|
58
61
|
>
|
|
59
62
|
<Icon icon={icon.name} classes={"m-8 " + (icon.classes != undefined ? icon.classes : "")}/>
|
|
60
63
|
</div>
|
|
61
64
|
{/if}
|
|
62
65
|
|
|
63
66
|
<!-- Heading, Text, and Button -->
|
|
64
|
-
{#if $scrollTargetVisible}
|
|
67
|
+
{#if $scrollTargetVisible || !animate}
|
|
65
68
|
<div
|
|
66
69
|
class="mt-6"
|
|
67
|
-
in:
|
|
68
|
-
out:
|
|
70
|
+
in:conditionalTransition={{ fn: fade, condition: animate, delay: 200, duration: 750, easing:cubicInOut}}
|
|
71
|
+
out:conditionalTransition={{fn: fade, condition: animate, delay: 200, duration: 750, easing:cubicInOut}}
|
|
69
72
|
>
|
|
70
73
|
<a href={`#${id}`} class="text-3xl font-bold tracking-tight text-gray-900">{heading}</a>
|
|
71
74
|
<p class="mt-4 text-lg text-gray-500">{text}</p>
|
|
@@ -77,11 +80,11 @@
|
|
|
77
80
|
</div>
|
|
78
81
|
|
|
79
82
|
<!-- Testimonial -->
|
|
80
|
-
{#if testimonial && $scrollTargetVisible}
|
|
83
|
+
{#if testimonial && ($scrollTargetVisible || !animate)}
|
|
81
84
|
<div
|
|
82
85
|
class="mt-8 border-t border-gray-200 pt-6"
|
|
83
|
-
in:
|
|
84
|
-
out:
|
|
86
|
+
in:conditionalTransition={{ fn: fade, condition: animate, delay: 300, duration: 1750, easing:cubicInOut, x: textPosition == "left" ? '-100%' : '100%'}}
|
|
87
|
+
out:conditionalTransition={{fn: fade, condition: animate, delay: 300, duration: 1750, easing:cubicInOut, x: textPosition == "left" ? '-100%' : '100%'}}
|
|
85
88
|
>
|
|
86
89
|
<blockquote>
|
|
87
90
|
<div>
|
|
@@ -107,15 +110,15 @@
|
|
|
107
110
|
<!-- Image -->
|
|
108
111
|
<div id={id + "image"} class="relative mt-12 sm:mt-16 lg:mt-0 {textPosition == "left" ? "" : "lg:col-start-1"}"
|
|
109
112
|
>
|
|
110
|
-
{#if $scrollTargetVisible}
|
|
113
|
+
{#if $scrollTargetVisible || !animate}
|
|
111
114
|
<div
|
|
112
115
|
class="{textPosition == "left" ? "-mr-48 pl-6 md:-mr-16" : "-ml-48 pr-6 md:-ml-16"} lg:relative lg:m-0 lg:h-full lg:px-0"
|
|
113
|
-
in:
|
|
114
|
-
out:
|
|
116
|
+
in:conditionalTransition={{ fn: fade, condition: animate, delay: 200, duration: 1250, easing:cubicInOut, x: textPosition == "left" ? '100%' : '-100%'}}
|
|
117
|
+
out:conditionalTransition={{fn: fade, condition: animate, delay: 200, duration: 1250, easing:cubicInOut, x: textPosition == "left" ? '100%' : '-100%'}}
|
|
115
118
|
>
|
|
116
119
|
<img class="w-full shadow-xl ring-1 ring-black/5 lg:absolute {textPosition == "left" ? "lg:left-0" : "right-0"} lg:h-full lg:w-auto lg:max-w-none" src="https://files.thunderheadeng.com/www/images/{image.url}?fmt=auto" alt={image.alt}>
|
|
117
120
|
</div>
|
|
118
|
-
{:else}
|
|
121
|
+
{:else if animate}
|
|
119
122
|
<div
|
|
120
123
|
out:fly={{ delay: 0, duration: 500, easing: cubicInOut, x: textPosition == "left" ? '100%' : '-100%' }}
|
|
121
124
|
class="absolute top-0 bottom-0 w-full bg-gray-200 animate-pulse my-16"
|
package/dist/utils.d.ts
CHANGED
|
@@ -58,3 +58,10 @@ export function getTeciImageURL(imageSrc: any, site?: any): any;
|
|
|
58
58
|
* @param {*} latch If true, the state will always be set to true after the page loads
|
|
59
59
|
*/
|
|
60
60
|
export function triggerWhenVisible(store: any, elementId: any, latch?: any): void;
|
|
61
|
+
/** Simplifies the logic of conditionally animating an element using Svelte transitions. If options.condition is true, options.fn is run, passing options as an argument.
|
|
62
|
+
*
|
|
63
|
+
* @param {*} node The node that passed to this function (provided by svelte)
|
|
64
|
+
* @param {*} options Options to pass to the transition function. Should always define the properties options.condition and options.fn.
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
export function conditionalTransition(node: any, options: any): any;
|
package/dist/utils.js
CHANGED
|
@@ -485,4 +485,16 @@ export function triggerWhenVisible(store, elementId, latch = false) {
|
|
|
485
485
|
addEventListener("scroll", (event) => {
|
|
486
486
|
updateVisibility()
|
|
487
487
|
})
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/** Simplifies the logic of conditionally animating an element using Svelte transitions. If options.condition is true, options.fn is run, passing options as an argument.
|
|
491
|
+
*
|
|
492
|
+
* @param {*} node The node that passed to this function (provided by svelte)
|
|
493
|
+
* @param {*} options Options to pass to the transition function. Should always define the properties options.condition and options.fn.
|
|
494
|
+
* @returns
|
|
495
|
+
*/
|
|
496
|
+
export function conditionalTransition(node, options) {
|
|
497
|
+
if (options.condition) {
|
|
498
|
+
return options.fn(node, options)
|
|
499
|
+
}
|
|
488
500
|
}
|