svelte-aos 0.0.2 → 0.0.3

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.
package/dist/aos.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { AnimationType, DisableOption, EasingType, AnchorPlacement } from './types.ts';
2
2
  /**
3
- * Create a Svelte attacheemnt that observes elements with `data-aos` and toggles
3
+ * Create a Svelte attachment that observes elements with `data-aos` and toggles
4
4
  * animation classes when they intersect the viewport.
5
5
  *
6
- * The attachement will:
6
+ * The attachment will:
7
7
  * - Apply per-element CSS variables (duration/delay) from `data-aos-*` attributes
8
8
  * or from the `params` defaults.
9
9
  * - Add the `.aos-animate` class when the element meets the `threshold`/`rootMargin` criteria.
package/dist/aos.js CHANGED
@@ -1,19 +1,5 @@
1
+ import { detectDeviceType } from "./utils.js";
1
2
  // import './styles.css';
2
- // TODO: Improve this device detection logic
3
- function detectDeviceType() {
4
- if (typeof navigator === 'undefined')
5
- return 'desktop';
6
- const ua = navigator.userAgent;
7
- if (/Mobi|Android/i.test(ua)) {
8
- return 'mobile';
9
- }
10
- else if (/Tablet|iPad/i.test(ua)) {
11
- return 'tablet';
12
- }
13
- else {
14
- return 'desktop';
15
- }
16
- }
17
3
  const computeRootMargin = (anchorPlacement, offset = 0) => {
18
4
  // simple handling for common placements; expand if needed
19
5
  if (anchorPlacement === 'top-bottom') {
@@ -42,7 +28,7 @@ const defaultOptions = {
42
28
  // useClassNames: false,
43
29
  // disableMutationObserver: false
44
30
  };
45
- function setipObserver(params, node) {
31
+ function initializeIntersectionObserver(params, node) {
46
32
  if (params?.duration) {
47
33
  node.style.setProperty('--aos-duration', `${params.duration}ms`);
48
34
  }
@@ -133,10 +119,10 @@ function setipObserver(params, node) {
133
119
  return { io, mo };
134
120
  }
135
121
  /**
136
- * Create a Svelte attacheemnt that observes elements with `data-aos` and toggles
122
+ * Create a Svelte attachment that observes elements with `data-aos` and toggles
137
123
  * animation classes when they intersect the viewport.
138
124
  *
139
- * The attachement will:
125
+ * The attachment will:
140
126
  * - Apply per-element CSS variables (duration/delay) from `data-aos-*` attributes
141
127
  * or from the `params` defaults.
142
128
  * - Add the `.aos-animate` class when the element meets the `threshold`/`rootMargin` criteria.
@@ -149,7 +135,7 @@ function setipObserver(params, node) {
149
135
  export function aosObserver(params) {
150
136
  params = { ...defaultOptions, ...params };
151
137
  return function (node) {
152
- const { io, mo } = setipObserver(params, node);
138
+ const { io, mo } = initializeIntersectionObserver(params, node);
153
139
  return () => {
154
140
  io.disconnect();
155
141
  mo.disconnect();
@@ -165,7 +151,7 @@ export function aosObserver(params) {
165
151
  */
166
152
  export function aosAction(node, params) {
167
153
  params = { ...defaultOptions, ...params };
168
- const { io, mo } = setipObserver(params, node);
154
+ const { io, mo } = initializeIntersectionObserver(params, node);
169
155
  return {
170
156
  update: () => {
171
157
  // NOTHING
@@ -0,0 +1,11 @@
1
+ <script lang="ts">
2
+ import { onMount } from 'svelte';
3
+ import { initAOS } from './aos.js';
4
+ import type { AOSOptions } from '../types.js';
5
+
6
+ export let options: AOSOptions = {};
7
+
8
+ onMount(() => {
9
+ initAOS(options);
10
+ });
11
+ </script>
@@ -0,0 +1,21 @@
1
+ import type { AOSOptions } from '../types.ts';
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const AOS: $$__sveltets_2_IsomorphicComponent<{
16
+ options?: AOSOptions;
17
+ }, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type AOS = InstanceType<typeof AOS>;
21
+ export default AOS;
@@ -0,0 +1,15 @@
1
+ import type { AnimationType, AOSOptions, EasingType } from '../types.ts';
2
+ export declare function initAOS(options?: AOSOptions): void;
3
+ export type AOSElementOptions = {
4
+ animation?: AnimationType;
5
+ duration?: number;
6
+ delay?: number;
7
+ easing?: EasingType;
8
+ once?: boolean;
9
+ distance?: string;
10
+ };
11
+ export declare function aos(options?: AOSElementOptions): (node: HTMLElement) => () => void | undefined;
12
+ export declare function aosAction(node: HTMLElement, options?: AOSElementOptions): {
13
+ update: () => void;
14
+ destroy(): void;
15
+ };
@@ -0,0 +1,143 @@
1
+ import { detectDeviceType } from "../utils.js";
2
+ const defaultOptions = {
3
+ delay: 0,
4
+ easing: 'ease',
5
+ duration: 600,
6
+ disable: 'mobile',
7
+ once: false,
8
+ anchorPlacement: 'top-bottom',
9
+ offset: 120,
10
+ threshold: 0.1
11
+ // TODO: implement these later
12
+ // animatedClassName: 'aos-animate',
13
+ // initClassName?: 'aos-init',
14
+ // useClassNames: false,
15
+ // disableMutationObserver: false
16
+ };
17
+ function isValidDistance(value) {
18
+ const el = document.createElement('div');
19
+ el.style.width = '';
20
+ el.style.width = value;
21
+ return el.style.width !== '';
22
+ }
23
+ class IntersectionObserverManager {
24
+ observer;
25
+ options;
26
+ elements = new Map();
27
+ constructor(options) {
28
+ this.options = options;
29
+ this.observer = new IntersectionObserver(this.handleIntersect.bind(this), {
30
+ threshold: options.threshold,
31
+ rootMargin: `0px 0px -${options.offset}px 0px`
32
+ });
33
+ console.log('disabled options:', options);
34
+ // handle disable option
35
+ if (typeof options?.disable === 'boolean' && options.disable) {
36
+ document.body.classList.add('aos-disabled');
37
+ }
38
+ else if (typeof options?.disable === 'string') {
39
+ const deviceType = detectDeviceType();
40
+ if (options.disable === deviceType) {
41
+ document.body.classList.add('aos-disabled');
42
+ }
43
+ }
44
+ else if (typeof options?.disable === 'function') {
45
+ if (options.disable()) {
46
+ document.body.classList.add('aos-disabled');
47
+ }
48
+ }
49
+ }
50
+ handleIntersect(entries) {
51
+ console.log('Handling intersections with options:', this.options);
52
+ entries.forEach((entry) => {
53
+ if (entry.isIntersecting && entry.intersectionRatio > 0.05) {
54
+ if (this.elements.has(entry.target)) {
55
+ entry.target.classList.add('aos-animate');
56
+ const elementOptions = this.elements.get(entry.target);
57
+ if (elementOptions?.once) {
58
+ // if only once why keep observing
59
+ this.observer.unobserve(entry.target);
60
+ }
61
+ }
62
+ else {
63
+ // this should never happen if it does don't observe the element
64
+ console.warn('No options found for element:', entry.target);
65
+ this.observer.unobserve(entry.target);
66
+ }
67
+ }
68
+ else {
69
+ const once = entry.target.hasAttribute('data-aos-once') || this.options.once;
70
+ if (!once) {
71
+ entry.target.classList.remove('aos-animate');
72
+ }
73
+ }
74
+ });
75
+ }
76
+ observe(element, options) {
77
+ console.log('Before Observing element with options:', element, options);
78
+ this.elements.set(element, this.options);
79
+ if (options.animation) {
80
+ element.setAttribute('data-aos', options.animation);
81
+ }
82
+ if (options.duration) {
83
+ element.style.setProperty('--aos-duration', `${options.duration}ms`);
84
+ }
85
+ if (options.delay) {
86
+ element.style.setProperty('--aos-delay', `${options.delay}ms`);
87
+ }
88
+ if (options.easing) {
89
+ element.style.setProperty('--aos-easing', options.easing);
90
+ }
91
+ if (options.distance && isValidDistance(options.distance)) {
92
+ element.style.setProperty('--aos-distance', options.distance);
93
+ }
94
+ this.observer.observe(element);
95
+ }
96
+ unobserve(element) {
97
+ this.observer.unobserve(element);
98
+ this.elements.delete(element);
99
+ }
100
+ }
101
+ let observerManager = null;
102
+ export function initAOS(options = {}) {
103
+ console.log('Initializing AOS with options:', options);
104
+ if (typeof window === 'undefined') {
105
+ console.warn('AOS can only be initialized in a browser environment.');
106
+ return;
107
+ }
108
+ const requiredOptions = { ...defaultOptions, ...options };
109
+ if (!observerManager) {
110
+ observerManager = new IntersectionObserverManager(requiredOptions);
111
+ }
112
+ else {
113
+ console.warn('AOS already initialzed, ');
114
+ }
115
+ }
116
+ function observe(node, options) {
117
+ if (observerManager) {
118
+ observerManager.observe(node, options);
119
+ }
120
+ else {
121
+ console.warn('AOS not initialized. Please call initialize it first.');
122
+ }
123
+ return () => observerManager?.unobserve(node);
124
+ }
125
+ export function aos(options = {
126
+ animation: 'fade'
127
+ }) {
128
+ return (node) => {
129
+ const unobserve = observe(node, options);
130
+ return unobserve;
131
+ };
132
+ }
133
+ export function aosAction(node, options = {
134
+ animation: 'fade'
135
+ }) {
136
+ const unobserve = observe(node, options);
137
+ return {
138
+ update: () => { },
139
+ destroy() {
140
+ unobserve();
141
+ }
142
+ };
143
+ }
@@ -0,0 +1,2 @@
1
+ export { default as AOS } from './AOS.svelte';
2
+ export { aos, aosAction } from './aos.ts';
@@ -0,0 +1,2 @@
1
+ export { default as AOS } from './AOS.svelte';
2
+ export { aos, aosAction } from "./aos.js";
@@ -6,36 +6,35 @@
6
6
 
7
7
  @media screen {
8
8
  html:not(.no-js) {
9
- :not(.aos-disabled) {
10
- /* CSS Custom Properties (defaults) */
11
- --aos-duration: 600ms;
12
- --aos-delay: 50ms;
13
- --aos-distance: 100px;
9
+ /* CSS Custom Properties (defaults) */
10
+ --aos-duration: 600ms;
11
+ --aos-delay: 50ms;
12
+ --aos-distance: 100px;
14
13
 
15
- /* Base transition for all [data-aos] elements */
16
- [data-aos] {
17
- transition-duration: var(--aos-duration);
18
- transition-delay: var(--aos-delay);
19
- transition-timing-function: ease;
20
- }
14
+ /* Base transition for all [data-aos] elements */
15
+ [data-aos] {
16
+ transition-duration: var(--aos-duration);
17
+ transition-delay: var(--aos-delay);
18
+ transition-timing-function: ease;
19
+ }
21
20
 
22
- /* Default animated state */
23
- [data-aos].aos-animate {
24
- transform: translate3d(0, 0, 0) scale(1) rotate(0);
25
- }
21
+ /* Default animated state */
22
+ [data-aos].aos-animate {
23
+ transform: translate3d(0, 0, 0) scale(1) rotate(0);
24
+ }
26
25
 
27
- /* Reduced motion support */
28
- @media (prefers-reduced-motion: reduce) {
29
- [data-aos] {
30
- opacity: 1 !important;
31
- transform: none !important;
32
- transition: none !important;
33
- }
26
+ /* Reduced motion support */
27
+ @media (prefers-reduced-motion: reduce) {
28
+ [data-aos] {
29
+ opacity: 1 !important;
30
+ transform: none !important;
31
+ transition: none !important;
34
32
  }
33
+ }
35
34
 
36
- /* Disabled state */
37
- [data-aos-disabled] [data-aos],
38
- [data-aos][data-aos-disabled] {
35
+ /* this is used for the global disable option */
36
+ .aos-disabled {
37
+ * {
39
38
  opacity: 1 !important;
40
39
  transform: none !important;
41
40
  transition: none !important;
@@ -6,92 +6,90 @@
6
6
 
7
7
  @media screen {
8
8
  html:not(.no-js) {
9
- :not(.aos-disabled) {
10
- /* Standard easings */
11
- [data-aos][data-aos-easing='linear'] {
12
- transition-timing-function: linear;
13
- }
14
-
15
- [data-aos][data-aos-easing='ease'] {
16
- transition-timing-function: ease;
17
- }
18
-
19
- [data-aos][data-aos-easing='ease-in'] {
20
- transition-timing-function: ease-in;
21
- }
22
-
23
- [data-aos][data-aos-easing='ease-out'] {
24
- transition-timing-function: ease-out;
25
- }
26
-
27
- [data-aos][data-aos-easing='ease-in-out'] {
28
- transition-timing-function: ease-in-out;
29
- }
30
-
31
- /* Back easings (overshoot) */
32
- [data-aos][data-aos-easing='ease-in-back'] {
33
- transition-timing-function: cubic-bezier(0.6, -0.28, 0.735, 0.045);
34
- }
35
-
36
- [data-aos][data-aos-easing='ease-out-back'] {
37
- transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
38
- }
39
-
40
- [data-aos][data-aos-easing='ease-in-out-back'] {
41
- transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
42
- }
43
-
44
- /* Sine easings (smooth) */
45
- [data-aos][data-aos-easing='ease-in-sine'] {
46
- transition-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715);
47
- }
48
-
49
- [data-aos][data-aos-easing='ease-out-sine'] {
50
- transition-timing-function: cubic-bezier(0.39, 0.575, 0.565, 1);
51
- }
52
-
53
- [data-aos][data-aos-easing='ease-in-out-sine'] {
54
- transition-timing-function: cubic-bezier(0.445, 0.05, 0.55, 0.95);
55
- }
56
-
57
- /* Quad easings (moderate acceleration) */
58
- [data-aos][data-aos-easing='ease-in-quad'] {
59
- transition-timing-function: cubic-bezier(0.55, 0.085, 0.68, 0.53);
60
- }
61
-
62
- [data-aos][data-aos-easing='ease-out-quad'] {
63
- transition-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
64
- }
65
-
66
- [data-aos][data-aos-easing='ease-in-out-quad'] {
67
- transition-timing-function: cubic-bezier(0.455, 0.03, 0.515, 0.955);
68
- }
69
-
70
- /* Cubic easings (stronger acceleration) */
71
- [data-aos][data-aos-easing='ease-in-cubic'] {
72
- transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
73
- }
74
-
75
- [data-aos][data-aos-easing='ease-out-cubic'] {
76
- transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
77
- }
78
-
79
- [data-aos][data-aos-easing='ease-in-out-cubic'] {
80
- transition-timing-function: cubic-bezier(0.645, 0.045, 0.355, 1);
81
- }
82
-
83
- /* Quart easings (aggressive acceleration) */
84
- [data-aos][data-aos-easing='ease-in-quart'] {
85
- transition-timing-function: cubic-bezier(0.895, 0.03, 0.685, 0.22);
86
- }
87
-
88
- [data-aos][data-aos-easing='ease-out-quart'] {
89
- transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
90
- }
91
-
92
- [data-aos][data-aos-easing='ease-in-out-quart'] {
93
- transition-timing-function: cubic-bezier(0.77, 0, 0.175, 1);
94
- }
9
+ /* Standard easings */
10
+ [data-aos][data-aos-easing='linear'] {
11
+ transition-timing-function: linear;
12
+ }
13
+
14
+ [data-aos][data-aos-easing='ease'] {
15
+ transition-timing-function: ease;
16
+ }
17
+
18
+ [data-aos][data-aos-easing='ease-in'] {
19
+ transition-timing-function: ease-in;
20
+ }
21
+
22
+ [data-aos][data-aos-easing='ease-out'] {
23
+ transition-timing-function: ease-out;
24
+ }
25
+
26
+ [data-aos][data-aos-easing='ease-in-out'] {
27
+ transition-timing-function: ease-in-out;
28
+ }
29
+
30
+ /* Back easings (overshoot) */
31
+ [data-aos][data-aos-easing='ease-in-back'] {
32
+ transition-timing-function: cubic-bezier(0.6, -0.28, 0.735, 0.045);
33
+ }
34
+
35
+ [data-aos][data-aos-easing='ease-out-back'] {
36
+ transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
37
+ }
38
+
39
+ [data-aos][data-aos-easing='ease-in-out-back'] {
40
+ transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
41
+ }
42
+
43
+ /* Sine easings (smooth) */
44
+ [data-aos][data-aos-easing='ease-in-sine'] {
45
+ transition-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715);
46
+ }
47
+
48
+ [data-aos][data-aos-easing='ease-out-sine'] {
49
+ transition-timing-function: cubic-bezier(0.39, 0.575, 0.565, 1);
50
+ }
51
+
52
+ [data-aos][data-aos-easing='ease-in-out-sine'] {
53
+ transition-timing-function: cubic-bezier(0.445, 0.05, 0.55, 0.95);
54
+ }
55
+
56
+ /* Quad easings (moderate acceleration) */
57
+ [data-aos][data-aos-easing='ease-in-quad'] {
58
+ transition-timing-function: cubic-bezier(0.55, 0.085, 0.68, 0.53);
59
+ }
60
+
61
+ [data-aos][data-aos-easing='ease-out-quad'] {
62
+ transition-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
63
+ }
64
+
65
+ [data-aos][data-aos-easing='ease-in-out-quad'] {
66
+ transition-timing-function: cubic-bezier(0.455, 0.03, 0.515, 0.955);
67
+ }
68
+
69
+ /* Cubic easings (stronger acceleration) */
70
+ [data-aos][data-aos-easing='ease-in-cubic'] {
71
+ transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
72
+ }
73
+
74
+ [data-aos][data-aos-easing='ease-out-cubic'] {
75
+ transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
76
+ }
77
+
78
+ [data-aos][data-aos-easing='ease-in-out-cubic'] {
79
+ transition-timing-function: cubic-bezier(0.645, 0.045, 0.355, 1);
80
+ }
81
+
82
+ /* Quart easings (aggressive acceleration) */
83
+ [data-aos][data-aos-easing='ease-in-quart'] {
84
+ transition-timing-function: cubic-bezier(0.895, 0.03, 0.685, 0.22);
85
+ }
86
+
87
+ [data-aos][data-aos-easing='ease-out-quart'] {
88
+ transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
89
+ }
90
+
91
+ [data-aos][data-aos-easing='ease-in-out-quart'] {
92
+ transition-timing-function: cubic-bezier(0.77, 0, 0.175, 1);
95
93
  }
96
94
  }
97
95
  }
@@ -6,56 +6,54 @@
6
6
 
7
7
  @media screen {
8
8
  html:not(.no-js) {
9
- :not(.aos-disabled) {
10
- /* Base for all fade animations */
11
- [data-aos^='fade'][data-aos^='fade'] {
12
- opacity: 0;
13
- transition-property: opacity, transform;
14
-
15
- &.aos-animate {
16
- opacity: 1;
17
- transform: none;
18
- }
19
- }
9
+ /* Base for all fade animations */
10
+ [data-aos^='fade'][data-aos^='fade'] {
11
+ opacity: 0;
12
+ transition-property: opacity, transform;
20
13
 
21
- /* Simple fade (no movement) */
22
- [data-aos='fade'] {
23
- transform: translate3d(0, 0, 0);
14
+ &.aos-animate {
15
+ opacity: 1;
16
+ transform: none;
24
17
  }
18
+ }
25
19
 
26
- /* Directional fades */
27
- [data-aos='fade-up'] {
28
- transform: translate3d(0, var(--aos-distance), 0);
29
- }
20
+ /* Simple fade (no movement) */
21
+ [data-aos='fade'] {
22
+ transform: translate3d(0, 0, 0);
23
+ }
30
24
 
31
- [data-aos='fade-down'] {
32
- transform: translate3d(0, calc(-1 * var(--aos-distance)), 0);
33
- }
25
+ /* Directional fades */
26
+ [data-aos='fade-up'] {
27
+ transform: translate3d(0, var(--aos-distance), 0);
28
+ }
34
29
 
35
- [data-aos='fade-left'] {
36
- transform: translate3d(var(--aos-distance), 0, 0);
37
- }
30
+ [data-aos='fade-down'] {
31
+ transform: translate3d(0, calc(-1 * var(--aos-distance)), 0);
32
+ }
38
33
 
39
- [data-aos='fade-right'] {
40
- transform: translate3d(calc(-1 * var(--aos-distance)), 0, 0);
41
- }
34
+ [data-aos='fade-left'] {
35
+ transform: translate3d(var(--aos-distance), 0, 0);
36
+ }
42
37
 
43
- /* Diagonal fades */
44
- [data-aos='fade-up-left'] {
45
- transform: translate3d(var(--aos-distance), var(--aos-distance), 0);
46
- }
38
+ [data-aos='fade-right'] {
39
+ transform: translate3d(calc(-1 * var(--aos-distance)), 0, 0);
40
+ }
47
41
 
48
- [data-aos='fade-up-right'] {
49
- transform: translate3d(calc(-1 * var(--aos-distance)), var(--aos-distance), 0);
50
- }
42
+ /* Diagonal fades */
43
+ [data-aos='fade-up-left'] {
44
+ transform: translate3d(var(--aos-distance), var(--aos-distance), 0);
45
+ }
51
46
 
52
- [data-aos='fade-down-left'] {
53
- transform: translate3d(var(--aos-distance), calc(-1 * var(--aos-distance)), 0);
54
- }
47
+ [data-aos='fade-up-right'] {
48
+ transform: translate3d(calc(-1 * var(--aos-distance)), var(--aos-distance), 0);
49
+ }
55
50
 
56
- [data-aos='fade-down-right'] {
57
- transform: translate3d(calc(-1 * var(--aos-distance)), calc(-1 * var(--aos-distance)), 0);
58
- }
51
+ [data-aos='fade-down-left'] {
52
+ transform: translate3d(var(--aos-distance), calc(-1 * var(--aos-distance)), 0);
53
+ }
54
+
55
+ [data-aos='fade-down-right'] {
56
+ transform: translate3d(calc(-1 * var(--aos-distance)), calc(-1 * var(--aos-distance)), 0);
59
57
  }
60
58
  }
61
59
  }
@@ -6,33 +6,31 @@
6
6
 
7
7
  @media screen {
8
8
  html:not(.no-js) {
9
- :not(.aos-disabled) {
10
- /* Base for all flip animations */
11
- [data-aos^='flip'][data-aos^='flip'] {
12
- backface-visibility: hidden;
13
- transition-property: transform;
9
+ /* Base for all flip animations */
10
+ [data-aos^='flip'][data-aos^='flip'] {
11
+ backface-visibility: hidden;
12
+ transition-property: transform;
14
13
 
15
- &.aos-animate {
16
- transform: perspective(2500px) rotateX(0) rotateY(0);
17
- }
14
+ &.aos-animate {
15
+ transform: perspective(2500px) rotateX(0) rotateY(0);
18
16
  }
17
+ }
19
18
 
20
- /* Flip directions */
21
- [data-aos='flip-up'] {
22
- transform: perspective(2500px) rotateX(-100deg);
23
- }
19
+ /* Flip directions */
20
+ [data-aos='flip-up'] {
21
+ transform: perspective(2500px) rotateX(-100deg);
22
+ }
24
23
 
25
- [data-aos='flip-down'] {
26
- transform: perspective(2500px) rotateX(100deg);
27
- }
24
+ [data-aos='flip-down'] {
25
+ transform: perspective(2500px) rotateX(100deg);
26
+ }
28
27
 
29
- [data-aos='flip-left'] {
30
- transform: perspective(2500px) rotateY(-100deg);
31
- }
28
+ [data-aos='flip-left'] {
29
+ transform: perspective(2500px) rotateY(-100deg);
30
+ }
32
31
 
33
- [data-aos='flip-right'] {
34
- transform: perspective(2500px) rotateY(100deg);
35
- }
32
+ [data-aos='flip-right'] {
33
+ transform: perspective(2500px) rotateY(100deg);
36
34
  }
37
35
  }
38
36
  }
@@ -6,34 +6,32 @@
6
6
 
7
7
  @media screen {
8
8
  html:not(.no-js) {
9
- :not(.aos-disabled) {
10
- /* Base for all slide animations */
11
- [data-aos^='slide'][data-aos^='slide'] {
12
- transition-property: transform;
13
- visibility: hidden;
9
+ /* Base for all slide animations */
10
+ [data-aos^='slide'][data-aos^='slide'] {
11
+ transition-property: transform;
12
+ visibility: hidden;
14
13
 
15
- &.aos-animate {
16
- visibility: visible;
17
- transform: translate3d(0, 0, 0);
18
- }
14
+ &.aos-animate {
15
+ visibility: visible;
16
+ transform: translate3d(0, 0, 0);
19
17
  }
18
+ }
20
19
 
21
- /* Slide directions */
22
- [data-aos='slide-up'] {
23
- transform: translate3d(0, 100%, 0);
24
- }
20
+ /* Slide directions */
21
+ [data-aos='slide-up'] {
22
+ transform: translate3d(0, 100%, 0);
23
+ }
25
24
 
26
- [data-aos='slide-down'] {
27
- transform: translate3d(0, -100%, 0);
28
- }
25
+ [data-aos='slide-down'] {
26
+ transform: translate3d(0, -100%, 0);
27
+ }
29
28
 
30
- [data-aos='slide-left'] {
31
- transform: translate3d(100%, 0, 0);
32
- }
29
+ [data-aos='slide-left'] {
30
+ transform: translate3d(100%, 0, 0);
31
+ }
33
32
 
34
- [data-aos='slide-right'] {
35
- transform: translate3d(-100%, 0, 0);
36
- }
33
+ [data-aos='slide-right'] {
34
+ transform: translate3d(-100%, 0, 0);
37
35
  }
38
36
  }
39
37
  }
@@ -6,59 +6,57 @@
6
6
 
7
7
  @media screen {
8
8
  html:not(.no-js) {
9
- :not(.aos-disabled) {
10
- /* Base for all zoom animations */
11
- [data-aos^='zoom'][data-aos^='zoom'] {
12
- opacity: 0;
13
- transition-property: opacity, transform;
9
+ /* Base for all zoom animations */
10
+ [data-aos^='zoom'][data-aos^='zoom'] {
11
+ opacity: 0;
12
+ transition-property: opacity, transform;
14
13
 
15
- &.aos-animate {
16
- opacity: 1;
17
- transform: translate3d(0, 0, 0) scale(1);
18
- }
14
+ &.aos-animate {
15
+ opacity: 1;
16
+ transform: translate3d(0, 0, 0) scale(1);
19
17
  }
18
+ }
20
19
 
21
- /* Zoom In */
22
- [data-aos='zoom-in'] {
23
- transform: scale(0.6);
24
- }
20
+ /* Zoom In */
21
+ [data-aos='zoom-in'] {
22
+ transform: scale(0.6);
23
+ }
25
24
 
26
- [data-aos='zoom-in-up'] {
27
- transform: translate3d(0, var(--aos-distance), 0) scale(0.6);
28
- }
25
+ [data-aos='zoom-in-up'] {
26
+ transform: translate3d(0, var(--aos-distance), 0) scale(0.6);
27
+ }
29
28
 
30
- [data-aos='zoom-in-down'] {
31
- transform: translate3d(0, calc(-1 * var(--aos-distance)), 0) scale(0.6);
32
- }
29
+ [data-aos='zoom-in-down'] {
30
+ transform: translate3d(0, calc(-1 * var(--aos-distance)), 0) scale(0.6);
31
+ }
33
32
 
34
- [data-aos='zoom-in-left'] {
35
- transform: translate3d(var(--aos-distance), 0, 0) scale(0.6);
36
- }
33
+ [data-aos='zoom-in-left'] {
34
+ transform: translate3d(var(--aos-distance), 0, 0) scale(0.6);
35
+ }
37
36
 
38
- [data-aos='zoom-in-right'] {
39
- transform: translate3d(calc(-1 * var(--aos-distance)), 0, 0) scale(0.6);
40
- }
37
+ [data-aos='zoom-in-right'] {
38
+ transform: translate3d(calc(-1 * var(--aos-distance)), 0, 0) scale(0.6);
39
+ }
41
40
 
42
- /* Zoom Out */
43
- [data-aos='zoom-out'] {
44
- transform: scale(1.2);
45
- }
41
+ /* Zoom Out */
42
+ [data-aos='zoom-out'] {
43
+ transform: scale(1.2);
44
+ }
46
45
 
47
- [data-aos='zoom-out-up'] {
48
- transform: translate3d(0, var(--aos-distance), 0) scale(1.2);
49
- }
46
+ [data-aos='zoom-out-up'] {
47
+ transform: translate3d(0, var(--aos-distance), 0) scale(1.2);
48
+ }
50
49
 
51
- [data-aos='zoom-out-down'] {
52
- transform: translate3d(0, calc(-1 * var(--aos-distance)), 0) scale(1.2);
53
- }
50
+ [data-aos='zoom-out-down'] {
51
+ transform: translate3d(0, calc(-1 * var(--aos-distance)), 0) scale(1.2);
52
+ }
54
53
 
55
- [data-aos='zoom-out-left'] {
56
- transform: translate3d(var(--aos-distance), 0, 0) scale(1.2);
57
- }
54
+ [data-aos='zoom-out-left'] {
55
+ transform: translate3d(var(--aos-distance), 0, 0) scale(1.2);
56
+ }
58
57
 
59
- [data-aos='zoom-out-right'] {
60
- transform: translate3d(calc(-1 * var(--aos-distance)), 0, 0) scale(1.2);
61
- }
58
+ [data-aos='zoom-out-right'] {
59
+ transform: translate3d(calc(-1 * var(--aos-distance)), 0, 0) scale(1.2);
62
60
  }
63
61
  }
64
62
  }
@@ -0,0 +1 @@
1
+ export declare function detectDeviceType(): 'mobile' | 'tablet' | 'desktop';
package/dist/utils.js ADDED
@@ -0,0 +1,15 @@
1
+ // TODO: Improve this device detection logic
2
+ export function detectDeviceType() {
3
+ if (typeof navigator === 'undefined')
4
+ return 'desktop';
5
+ const ua = navigator.userAgent;
6
+ if (/Mobi|Android/i.test(ua)) {
7
+ return 'mobile';
8
+ }
9
+ else if (/Tablet|iPad/i.test(ua)) {
10
+ return 'tablet';
11
+ }
12
+ else {
13
+ return 'desktop';
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-aos",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "license": "MIT",
5
5
  "description": "Animate On Scroll (AOS) library for Svelte applications. Easily add scroll-based animations to your Svelte components with customizable options.",
6
6
  "author": {
@@ -31,6 +31,10 @@
31
31
  "types": "./dist/index.d.ts",
32
32
  "svelte": "./dist/index.js"
33
33
  },
34
+ "./no-mutation": {
35
+ "types": "./dist/no-mutation/index.d.ts",
36
+ "svelte": "./dist/no-mutation/index.js"
37
+ },
34
38
  "./styles/base.css": {
35
39
  "svelte": "./dist/styles/base.css"
36
40
  },