@dso-toolkit/core 53.0.0 → 53.1.0
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/cjs/dso-accordion-section.cjs.entry.js +39 -1404
- package/dist/cjs/dso-action-list-item.cjs.entry.js +27 -0
- package/dist/cjs/dso-action-list.cjs.entry.js +20 -0
- package/dist/cjs/dso-annotation-output.cjs.entry.js +1 -1
- package/dist/cjs/dso-date-picker.cjs.entry.js +1 -1
- package/dist/cjs/dso-dropdown-menu.cjs.entry.js +18 -3
- package/dist/cjs/dso-expandable-heading.cjs.entry.js +1 -1
- package/dist/cjs/dso-expandable.cjs.entry.js +1433 -2
- package/dist/cjs/dso-header.cjs.entry.js +16 -1
- package/dist/cjs/dso-helpcenter-panel.cjs.entry.js +2 -2
- package/dist/cjs/dso-image-overlay.cjs.entry.js +2 -2
- package/dist/cjs/dso-info_2.cjs.entry.js +3 -2
- package/dist/cjs/dso-list-button.cjs.entry.js +3 -3
- package/dist/cjs/dso-modal.cjs.entry.js +2 -2
- package/dist/cjs/dso-ozon-content.cjs.entry.js +1 -1
- package/dist/cjs/dso-table.cjs.entry.js +2 -2
- package/dist/cjs/dso-toolkit.cjs.js +1 -1
- package/dist/cjs/dso-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/dso-viewer-grid.cjs.entry.js +2 -2
- package/dist/cjs/expandable.interfaces-19b608b9.js +7 -0
- package/dist/cjs/{focus-trap.esm-c501d382.js → focus-trap.esm-a5b7273f.js} +134 -51
- package/dist/cjs/{has-overflow-b1b4f3f3.js → has-overflow-dd552ec8.js} +3 -4
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/{index.esm-03a9e0b4.js → index.esm-0e935715.js} +97 -17
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/accordion/accordion.js +1 -1
- package/dist/collection/components/accordion/components/accordion-section.css +60 -10
- package/dist/collection/components/accordion/components/accordion-section.js +41 -100
- package/dist/collection/components/action-list/action-list.css +25 -0
- package/dist/collection/components/action-list/action-list.js +42 -0
- package/dist/collection/components/action-list/components/action-list-item.css +81 -0
- package/dist/collection/components/action-list/components/action-list-item.js +120 -0
- package/dist/collection/components/annotation-output/annotation-output.js +1 -1
- package/dist/collection/components/date-picker/date-picker.css +1 -1
- package/dist/collection/components/date-picker/date-picker.js +1 -1
- package/dist/collection/components/dropdown-menu/dropdown-menu.js +36 -1
- package/dist/collection/components/expandable/expandable.css +12 -1
- package/dist/collection/components/expandable/expandable.interfaces.js +3 -0
- package/dist/collection/components/expandable/expandable.js +246 -2
- package/dist/collection/components/expandable-heading/expandable-heading.js +1 -1
- package/dist/collection/components/header/header.js +18 -2
- package/dist/collection/components/list-button/list-button.css +2 -2
- package/dist/collection/components/selectable/selectable.css +22 -9
- package/dist/collection/components/selectable/selectable.js +2 -1
- package/dist/collection/index.js +1 -0
- package/dist/components/dropdown-menu.js +17 -1
- package/dist/components/dso-accordion-section.js +52 -1407
- package/dist/components/dso-action-list-item.d.ts +11 -0
- package/dist/components/dso-action-list-item.js +53 -0
- package/dist/components/dso-action-list.d.ts +11 -0
- package/dist/components/dso-action-list.js +36 -0
- package/dist/components/dso-annotation-output.js +1 -1
- package/dist/components/dso-date-picker.js +2 -2
- package/dist/components/dso-expandable-heading.js +1 -1
- package/dist/components/dso-header.js +18 -2
- package/dist/components/dso-list-button.js +1 -1
- package/dist/components/expandable.js +1440 -4
- package/dist/components/focus-trap.esm.js +133 -50
- package/dist/components/has-overflow.js +3 -4
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.esm.js +97 -17
- package/dist/components/index.js +3 -1
- package/dist/components/selectable.js +3 -2
- package/dist/dso-toolkit/dso-toolkit.esm.js +1 -1
- package/dist/dso-toolkit/index.esm.js +1 -1
- package/dist/dso-toolkit/{p-e4f667b3.entry.js → p-0b6fa7d3.entry.js} +1 -1
- package/dist/dso-toolkit/p-36224d6f.entry.js +1 -0
- package/dist/dso-toolkit/{p-9b07b034.entry.js → p-398a8e0b.entry.js} +1 -1
- package/dist/dso-toolkit/{p-d2805c02.entry.js → p-3b91c3e9.entry.js} +1 -1
- package/dist/dso-toolkit/p-452b1234.js +1 -0
- package/dist/dso-toolkit/p-5950644a.js +5 -0
- package/dist/dso-toolkit/{p-b3f4645f.entry.js → p-5de8b79a.entry.js} +1 -1
- package/dist/dso-toolkit/p-5e50b616.entry.js +1 -0
- package/dist/dso-toolkit/p-6a99d7f8.entry.js +1 -0
- package/dist/dso-toolkit/p-91963e3d.js +5 -0
- package/dist/dso-toolkit/p-96f44d35.entry.js +1 -0
- package/dist/dso-toolkit/p-975c172a.entry.js +1 -0
- package/dist/dso-toolkit/{p-092dde2f.entry.js → p-a1616935.entry.js} +1 -1
- package/dist/dso-toolkit/{p-ba330644.entry.js → p-bb90ea4c.entry.js} +1 -1
- package/dist/dso-toolkit/p-bf750b97.js +1 -0
- package/dist/dso-toolkit/{p-aab458c4.entry.js → p-c86a5bcb.entry.js} +1 -1
- package/dist/dso-toolkit/{p-f2b76233.entry.js → p-cf9b79df.entry.js} +1 -1
- package/dist/dso-toolkit/{p-43f3d736.entry.js → p-d10ec2b3.entry.js} +1 -1
- package/dist/dso-toolkit/p-e8a6ccf5.entry.js +1 -0
- package/dist/dso-toolkit/p-eaae698e.entry.js +1 -0
- package/dist/dso-toolkit/p-fa2f1a1c.entry.js +1 -0
- package/dist/dso-toolkit/p-fe7ca25f.entry.js +1 -0
- package/dist/esm/dso-accordion-section.entry.js +39 -1404
- package/dist/esm/dso-action-list-item.entry.js +23 -0
- package/dist/esm/dso-action-list.entry.js +16 -0
- package/dist/esm/dso-annotation-output.entry.js +1 -1
- package/dist/esm/dso-date-picker.entry.js +1 -1
- package/dist/esm/dso-dropdown-menu.entry.js +18 -3
- package/dist/esm/dso-expandable-heading.entry.js +1 -1
- package/dist/esm/dso-expandable.entry.js +1434 -3
- package/dist/esm/dso-header.entry.js +16 -1
- package/dist/esm/dso-helpcenter-panel.entry.js +2 -2
- package/dist/esm/dso-image-overlay.entry.js +2 -2
- package/dist/esm/dso-info_2.entry.js +3 -2
- package/dist/esm/dso-list-button.entry.js +3 -3
- package/dist/esm/dso-modal.entry.js +2 -2
- package/dist/esm/dso-ozon-content.entry.js +1 -1
- package/dist/esm/dso-table.entry.js +2 -2
- package/dist/esm/dso-toolkit.js +1 -1
- package/dist/esm/dso-tooltip.entry.js +1 -1
- package/dist/esm/dso-viewer-grid.entry.js +2 -2
- package/dist/esm/expandable.interfaces-9b1afbe8.js +5 -0
- package/dist/esm/{focus-trap.esm-94794d92.js → focus-trap.esm-2a49a38f.js} +134 -51
- package/dist/esm/{has-overflow-c44a8a0a.js → has-overflow-fdc85d8f.js} +3 -4
- package/dist/esm/{index.esm-8fc07ad8.js → index.esm-3d6c8190.js} +97 -17
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/accordion/accordion.interfaces.d.ts +1 -1
- package/dist/types/components/accordion/components/accordion-section.d.ts +4 -8
- package/dist/types/components/action-list/action-list.d.ts +5 -0
- package/dist/types/components/action-list/components/action-list-item.d.ts +15 -0
- package/dist/types/components/dropdown-menu/dropdown-menu.d.ts +5 -0
- package/dist/types/components/expandable/expandable.d.ts +25 -1
- package/dist/types/components/expandable/expandable.interfaces.d.ts +10 -0
- package/dist/types/components/header/header.d.ts +3 -0
- package/dist/types/components/modal/modal.controller.d.ts +2 -3
- package/dist/types/components/modal/modal.interfaces.d.ts +11 -0
- package/dist/types/components.d.ts +77 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +11 -11
- package/dist/dso-toolkit/p-147ec7bd.entry.js +0 -1
- package/dist/dso-toolkit/p-3635427a.js +0 -5
- package/dist/dso-toolkit/p-452c7fbb.entry.js +0 -1
- package/dist/dso-toolkit/p-460e6134.entry.js +0 -1
- package/dist/dso-toolkit/p-4ae40ddc.entry.js +0 -1
- package/dist/dso-toolkit/p-4c8426b7.entry.js +0 -1
- package/dist/dso-toolkit/p-57ceabab.js +0 -5
- package/dist/dso-toolkit/p-d3ed00f6.js +0 -1
- package/dist/dso-toolkit/p-e3bd7689.entry.js +0 -1
- package/dist/dso-toolkit/p-f3f0d6c9.entry.js +0 -1
|
@@ -1,1315 +1,11 @@
|
|
|
1
|
-
import { h, proxyCustomElement, HTMLElement, forceUpdate, Host, Fragment } from '@stencil/core/internal/client';
|
|
2
|
-
import { d as
|
|
1
|
+
import { h, proxyCustomElement, HTMLElement as HTMLElement$1, forceUpdate, Host, Fragment } from '@stencil/core/internal/client';
|
|
2
|
+
import { d as defineCustomElement$3 } from './expandable.js';
|
|
3
3
|
import { d as defineCustomElement$2 } from './icon.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* (c) 2020 Julian Garnier
|
|
8
|
-
* Released under the MIT license
|
|
9
|
-
* animejs.com
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// Defaults
|
|
13
|
-
|
|
14
|
-
var defaultInstanceSettings = {
|
|
15
|
-
update: null,
|
|
16
|
-
begin: null,
|
|
17
|
-
loopBegin: null,
|
|
18
|
-
changeBegin: null,
|
|
19
|
-
change: null,
|
|
20
|
-
changeComplete: null,
|
|
21
|
-
loopComplete: null,
|
|
22
|
-
complete: null,
|
|
23
|
-
loop: 1,
|
|
24
|
-
direction: 'normal',
|
|
25
|
-
autoplay: true,
|
|
26
|
-
timelineOffset: 0
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
var defaultTweenSettings = {
|
|
30
|
-
duration: 1000,
|
|
31
|
-
delay: 0,
|
|
32
|
-
endDelay: 0,
|
|
33
|
-
easing: 'easeOutElastic(1, .5)',
|
|
34
|
-
round: 0
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
var validTransforms = ['translateX', 'translateY', 'translateZ', 'rotate', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scaleX', 'scaleY', 'scaleZ', 'skew', 'skewX', 'skewY', 'perspective', 'matrix', 'matrix3d'];
|
|
38
|
-
|
|
39
|
-
// Caching
|
|
40
|
-
|
|
41
|
-
var cache = {
|
|
42
|
-
CSS: {},
|
|
43
|
-
springs: {}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// Utils
|
|
47
|
-
|
|
48
|
-
function minMax(val, min, max) {
|
|
49
|
-
return Math.min(Math.max(val, min), max);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function stringContains(str, text) {
|
|
53
|
-
return str.indexOf(text) > -1;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function applyArguments(func, args) {
|
|
57
|
-
return func.apply(null, args);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var is = {
|
|
61
|
-
arr: function (a) { return Array.isArray(a); },
|
|
62
|
-
obj: function (a) { return stringContains(Object.prototype.toString.call(a), 'Object'); },
|
|
63
|
-
pth: function (a) { return is.obj(a) && a.hasOwnProperty('totalLength'); },
|
|
64
|
-
svg: function (a) { return a instanceof SVGElement; },
|
|
65
|
-
inp: function (a) { return a instanceof HTMLInputElement; },
|
|
66
|
-
dom: function (a) { return a.nodeType || is.svg(a); },
|
|
67
|
-
str: function (a) { return typeof a === 'string'; },
|
|
68
|
-
fnc: function (a) { return typeof a === 'function'; },
|
|
69
|
-
und: function (a) { return typeof a === 'undefined'; },
|
|
70
|
-
nil: function (a) { return is.und(a) || a === null; },
|
|
71
|
-
hex: function (a) { return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a); },
|
|
72
|
-
rgb: function (a) { return /^rgb/.test(a); },
|
|
73
|
-
hsl: function (a) { return /^hsl/.test(a); },
|
|
74
|
-
col: function (a) { return (is.hex(a) || is.rgb(a) || is.hsl(a)); },
|
|
75
|
-
key: function (a) { return !defaultInstanceSettings.hasOwnProperty(a) && !defaultTweenSettings.hasOwnProperty(a) && a !== 'targets' && a !== 'keyframes'; },
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// Easings
|
|
79
|
-
|
|
80
|
-
function parseEasingParameters(string) {
|
|
81
|
-
var match = /\(([^)]+)\)/.exec(string);
|
|
82
|
-
return match ? match[1].split(',').map(function (p) { return parseFloat(p); }) : [];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Spring solver inspired by Webkit Copyright © 2016 Apple Inc. All rights reserved. https://webkit.org/demos/spring/spring.js
|
|
86
|
-
|
|
87
|
-
function spring(string, duration) {
|
|
88
|
-
|
|
89
|
-
var params = parseEasingParameters(string);
|
|
90
|
-
var mass = minMax(is.und(params[0]) ? 1 : params[0], .1, 100);
|
|
91
|
-
var stiffness = minMax(is.und(params[1]) ? 100 : params[1], .1, 100);
|
|
92
|
-
var damping = minMax(is.und(params[2]) ? 10 : params[2], .1, 100);
|
|
93
|
-
var velocity = minMax(is.und(params[3]) ? 0 : params[3], .1, 100);
|
|
94
|
-
var w0 = Math.sqrt(stiffness / mass);
|
|
95
|
-
var zeta = damping / (2 * Math.sqrt(stiffness * mass));
|
|
96
|
-
var wd = zeta < 1 ? w0 * Math.sqrt(1 - zeta * zeta) : 0;
|
|
97
|
-
var a = 1;
|
|
98
|
-
var b = zeta < 1 ? (zeta * w0 + -velocity) / wd : -velocity + w0;
|
|
99
|
-
|
|
100
|
-
function solver(t) {
|
|
101
|
-
var progress = duration ? (duration * t) / 1000 : t;
|
|
102
|
-
if (zeta < 1) {
|
|
103
|
-
progress = Math.exp(-progress * zeta * w0) * (a * Math.cos(wd * progress) + b * Math.sin(wd * progress));
|
|
104
|
-
} else {
|
|
105
|
-
progress = (a + b * progress) * Math.exp(-progress * w0);
|
|
106
|
-
}
|
|
107
|
-
if (t === 0 || t === 1) { return t; }
|
|
108
|
-
return 1 - progress;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function getDuration() {
|
|
112
|
-
var cached = cache.springs[string];
|
|
113
|
-
if (cached) { return cached; }
|
|
114
|
-
var frame = 1/6;
|
|
115
|
-
var elapsed = 0;
|
|
116
|
-
var rest = 0;
|
|
117
|
-
while(true) {
|
|
118
|
-
elapsed += frame;
|
|
119
|
-
if (solver(elapsed) === 1) {
|
|
120
|
-
rest++;
|
|
121
|
-
if (rest >= 16) { break; }
|
|
122
|
-
} else {
|
|
123
|
-
rest = 0;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
var duration = elapsed * frame * 1000;
|
|
127
|
-
cache.springs[string] = duration;
|
|
128
|
-
return duration;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return duration ? solver : getDuration;
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Basic steps easing implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
|
|
136
|
-
|
|
137
|
-
function steps(steps) {
|
|
138
|
-
if ( steps === void 0 ) steps = 10;
|
|
139
|
-
|
|
140
|
-
return function (t) { return Math.ceil((minMax(t, 0.000001, 1)) * steps) * (1 / steps); };
|
|
5
|
+
function isExpandable(element) {
|
|
6
|
+
return element instanceof HTMLElement && "getAnimeInstance" in element;
|
|
141
7
|
}
|
|
142
8
|
|
|
143
|
-
// BezierEasing https://github.com/gre/bezier-easing
|
|
144
|
-
|
|
145
|
-
var bezier = (function () {
|
|
146
|
-
|
|
147
|
-
var kSplineTableSize = 11;
|
|
148
|
-
var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
|
|
149
|
-
|
|
150
|
-
function A(aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1 }
|
|
151
|
-
function B(aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1 }
|
|
152
|
-
function C(aA1) { return 3.0 * aA1 }
|
|
153
|
-
|
|
154
|
-
function calcBezier(aT, aA1, aA2) { return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT }
|
|
155
|
-
function getSlope(aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1) }
|
|
156
|
-
|
|
157
|
-
function binarySubdivide(aX, aA, aB, mX1, mX2) {
|
|
158
|
-
var currentX, currentT, i = 0;
|
|
159
|
-
do {
|
|
160
|
-
currentT = aA + (aB - aA) / 2.0;
|
|
161
|
-
currentX = calcBezier(currentT, mX1, mX2) - aX;
|
|
162
|
-
if (currentX > 0.0) { aB = currentT; } else { aA = currentT; }
|
|
163
|
-
} while (Math.abs(currentX) > 0.0000001 && ++i < 10);
|
|
164
|
-
return currentT;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
|
|
168
|
-
for (var i = 0; i < 4; ++i) {
|
|
169
|
-
var currentSlope = getSlope(aGuessT, mX1, mX2);
|
|
170
|
-
if (currentSlope === 0.0) { return aGuessT; }
|
|
171
|
-
var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
|
|
172
|
-
aGuessT -= currentX / currentSlope;
|
|
173
|
-
}
|
|
174
|
-
return aGuessT;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function bezier(mX1, mY1, mX2, mY2) {
|
|
178
|
-
|
|
179
|
-
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) { return; }
|
|
180
|
-
var sampleValues = new Float32Array(kSplineTableSize);
|
|
181
|
-
|
|
182
|
-
if (mX1 !== mY1 || mX2 !== mY2) {
|
|
183
|
-
for (var i = 0; i < kSplineTableSize; ++i) {
|
|
184
|
-
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function getTForX(aX) {
|
|
189
|
-
|
|
190
|
-
var intervalStart = 0;
|
|
191
|
-
var currentSample = 1;
|
|
192
|
-
var lastSample = kSplineTableSize - 1;
|
|
193
|
-
|
|
194
|
-
for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
|
|
195
|
-
intervalStart += kSampleStepSize;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
--currentSample;
|
|
199
|
-
|
|
200
|
-
var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
|
|
201
|
-
var guessForT = intervalStart + dist * kSampleStepSize;
|
|
202
|
-
var initialSlope = getSlope(guessForT, mX1, mX2);
|
|
203
|
-
|
|
204
|
-
if (initialSlope >= 0.001) {
|
|
205
|
-
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
|
|
206
|
-
} else if (initialSlope === 0.0) {
|
|
207
|
-
return guessForT;
|
|
208
|
-
} else {
|
|
209
|
-
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return function (x) {
|
|
215
|
-
if (mX1 === mY1 && mX2 === mY2) { return x; }
|
|
216
|
-
if (x === 0 || x === 1) { return x; }
|
|
217
|
-
return calcBezier(getTForX(x), mY1, mY2);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return bezier;
|
|
223
|
-
|
|
224
|
-
})();
|
|
225
|
-
|
|
226
|
-
var penner = (function () {
|
|
227
|
-
|
|
228
|
-
// Based on jQuery UI's implemenation of easing equations from Robert Penner (http://www.robertpenner.com/easing)
|
|
229
|
-
|
|
230
|
-
var eases = { linear: function () { return function (t) { return t; }; } };
|
|
231
|
-
|
|
232
|
-
var functionEasings = {
|
|
233
|
-
Sine: function () { return function (t) { return 1 - Math.cos(t * Math.PI / 2); }; },
|
|
234
|
-
Circ: function () { return function (t) { return 1 - Math.sqrt(1 - t * t); }; },
|
|
235
|
-
Back: function () { return function (t) { return t * t * (3 * t - 2); }; },
|
|
236
|
-
Bounce: function () { return function (t) {
|
|
237
|
-
var pow2, b = 4;
|
|
238
|
-
while (t < (( pow2 = Math.pow(2, --b)) - 1) / 11) {}
|
|
239
|
-
return 1 / Math.pow(4, 3 - b) - 7.5625 * Math.pow(( pow2 * 3 - 2 ) / 22 - t, 2)
|
|
240
|
-
}; },
|
|
241
|
-
Elastic: function (amplitude, period) {
|
|
242
|
-
if ( amplitude === void 0 ) amplitude = 1;
|
|
243
|
-
if ( period === void 0 ) period = .5;
|
|
244
|
-
|
|
245
|
-
var a = minMax(amplitude, 1, 10);
|
|
246
|
-
var p = minMax(period, .1, 2);
|
|
247
|
-
return function (t) {
|
|
248
|
-
return (t === 0 || t === 1) ? t :
|
|
249
|
-
-a * Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2) * Math.asin(1 / a))) * (Math.PI * 2)) / p);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
var baseEasings = ['Quad', 'Cubic', 'Quart', 'Quint', 'Expo'];
|
|
255
|
-
|
|
256
|
-
baseEasings.forEach(function (name, i) {
|
|
257
|
-
functionEasings[name] = function () { return function (t) { return Math.pow(t, i + 2); }; };
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
Object.keys(functionEasings).forEach(function (name) {
|
|
261
|
-
var easeIn = functionEasings[name];
|
|
262
|
-
eases['easeIn' + name] = easeIn;
|
|
263
|
-
eases['easeOut' + name] = function (a, b) { return function (t) { return 1 - easeIn(a, b)(1 - t); }; };
|
|
264
|
-
eases['easeInOut' + name] = function (a, b) { return function (t) { return t < 0.5 ? easeIn(a, b)(t * 2) / 2 :
|
|
265
|
-
1 - easeIn(a, b)(t * -2 + 2) / 2; }; };
|
|
266
|
-
eases['easeOutIn' + name] = function (a, b) { return function (t) { return t < 0.5 ? (1 - easeIn(a, b)(1 - t * 2)) / 2 :
|
|
267
|
-
(easeIn(a, b)(t * 2 - 1) + 1) / 2; }; };
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
return eases;
|
|
271
|
-
|
|
272
|
-
})();
|
|
273
|
-
|
|
274
|
-
function parseEasings(easing, duration) {
|
|
275
|
-
if (is.fnc(easing)) { return easing; }
|
|
276
|
-
var name = easing.split('(')[0];
|
|
277
|
-
var ease = penner[name];
|
|
278
|
-
var args = parseEasingParameters(easing);
|
|
279
|
-
switch (name) {
|
|
280
|
-
case 'spring' : return spring(easing, duration);
|
|
281
|
-
case 'cubicBezier' : return applyArguments(bezier, args);
|
|
282
|
-
case 'steps' : return applyArguments(steps, args);
|
|
283
|
-
default : return applyArguments(ease, args);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// Strings
|
|
288
|
-
|
|
289
|
-
function selectString(str) {
|
|
290
|
-
try {
|
|
291
|
-
var nodes = document.querySelectorAll(str);
|
|
292
|
-
return nodes;
|
|
293
|
-
} catch(e) {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
// Arrays
|
|
299
|
-
|
|
300
|
-
function filterArray(arr, callback) {
|
|
301
|
-
var len = arr.length;
|
|
302
|
-
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
|
|
303
|
-
var result = [];
|
|
304
|
-
for (var i = 0; i < len; i++) {
|
|
305
|
-
if (i in arr) {
|
|
306
|
-
var val = arr[i];
|
|
307
|
-
if (callback.call(thisArg, val, i, arr)) {
|
|
308
|
-
result.push(val);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return result;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function flattenArray(arr) {
|
|
316
|
-
return arr.reduce(function (a, b) { return a.concat(is.arr(b) ? flattenArray(b) : b); }, []);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function toArray(o) {
|
|
320
|
-
if (is.arr(o)) { return o; }
|
|
321
|
-
if (is.str(o)) { o = selectString(o) || o; }
|
|
322
|
-
if (o instanceof NodeList || o instanceof HTMLCollection) { return [].slice.call(o); }
|
|
323
|
-
return [o];
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function arrayContains(arr, val) {
|
|
327
|
-
return arr.some(function (a) { return a === val; });
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// Objects
|
|
331
|
-
|
|
332
|
-
function cloneObject(o) {
|
|
333
|
-
var clone = {};
|
|
334
|
-
for (var p in o) { clone[p] = o[p]; }
|
|
335
|
-
return clone;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
function replaceObjectProps(o1, o2) {
|
|
339
|
-
var o = cloneObject(o1);
|
|
340
|
-
for (var p in o1) { o[p] = o2.hasOwnProperty(p) ? o2[p] : o1[p]; }
|
|
341
|
-
return o;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
function mergeObjects(o1, o2) {
|
|
345
|
-
var o = cloneObject(o1);
|
|
346
|
-
for (var p in o2) { o[p] = is.und(o1[p]) ? o2[p] : o1[p]; }
|
|
347
|
-
return o;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// Colors
|
|
351
|
-
|
|
352
|
-
function rgbToRgba(rgbValue) {
|
|
353
|
-
var rgb = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(rgbValue);
|
|
354
|
-
return rgb ? ("rgba(" + (rgb[1]) + ",1)") : rgbValue;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
function hexToRgba(hexValue) {
|
|
358
|
-
var rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
359
|
-
var hex = hexValue.replace(rgx, function (m, r, g, b) { return r + r + g + g + b + b; } );
|
|
360
|
-
var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
361
|
-
var r = parseInt(rgb[1], 16);
|
|
362
|
-
var g = parseInt(rgb[2], 16);
|
|
363
|
-
var b = parseInt(rgb[3], 16);
|
|
364
|
-
return ("rgba(" + r + "," + g + "," + b + ",1)");
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
function hslToRgba(hslValue) {
|
|
368
|
-
var hsl = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(hslValue) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(hslValue);
|
|
369
|
-
var h = parseInt(hsl[1], 10) / 360;
|
|
370
|
-
var s = parseInt(hsl[2], 10) / 100;
|
|
371
|
-
var l = parseInt(hsl[3], 10) / 100;
|
|
372
|
-
var a = hsl[4] || 1;
|
|
373
|
-
function hue2rgb(p, q, t) {
|
|
374
|
-
if (t < 0) { t += 1; }
|
|
375
|
-
if (t > 1) { t -= 1; }
|
|
376
|
-
if (t < 1/6) { return p + (q - p) * 6 * t; }
|
|
377
|
-
if (t < 1/2) { return q; }
|
|
378
|
-
if (t < 2/3) { return p + (q - p) * (2/3 - t) * 6; }
|
|
379
|
-
return p;
|
|
380
|
-
}
|
|
381
|
-
var r, g, b;
|
|
382
|
-
if (s == 0) {
|
|
383
|
-
r = g = b = l;
|
|
384
|
-
} else {
|
|
385
|
-
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
386
|
-
var p = 2 * l - q;
|
|
387
|
-
r = hue2rgb(p, q, h + 1/3);
|
|
388
|
-
g = hue2rgb(p, q, h);
|
|
389
|
-
b = hue2rgb(p, q, h - 1/3);
|
|
390
|
-
}
|
|
391
|
-
return ("rgba(" + (r * 255) + "," + (g * 255) + "," + (b * 255) + "," + a + ")");
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
function colorToRgb(val) {
|
|
395
|
-
if (is.rgb(val)) { return rgbToRgba(val); }
|
|
396
|
-
if (is.hex(val)) { return hexToRgba(val); }
|
|
397
|
-
if (is.hsl(val)) { return hslToRgba(val); }
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
// Units
|
|
401
|
-
|
|
402
|
-
function getUnit(val) {
|
|
403
|
-
var split = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(val);
|
|
404
|
-
if (split) { return split[1]; }
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
function getTransformUnit(propName) {
|
|
408
|
-
if (stringContains(propName, 'translate') || propName === 'perspective') { return 'px'; }
|
|
409
|
-
if (stringContains(propName, 'rotate') || stringContains(propName, 'skew')) { return 'deg'; }
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// Values
|
|
413
|
-
|
|
414
|
-
function getFunctionValue(val, animatable) {
|
|
415
|
-
if (!is.fnc(val)) { return val; }
|
|
416
|
-
return val(animatable.target, animatable.id, animatable.total);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
function getAttribute(el, prop) {
|
|
420
|
-
return el.getAttribute(prop);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
function convertPxToUnit(el, value, unit) {
|
|
424
|
-
var valueUnit = getUnit(value);
|
|
425
|
-
if (arrayContains([unit, 'deg', 'rad', 'turn'], valueUnit)) { return value; }
|
|
426
|
-
var cached = cache.CSS[value + unit];
|
|
427
|
-
if (!is.und(cached)) { return cached; }
|
|
428
|
-
var baseline = 100;
|
|
429
|
-
var tempEl = document.createElement(el.tagName);
|
|
430
|
-
var parentEl = (el.parentNode && (el.parentNode !== document)) ? el.parentNode : document.body;
|
|
431
|
-
parentEl.appendChild(tempEl);
|
|
432
|
-
tempEl.style.position = 'absolute';
|
|
433
|
-
tempEl.style.width = baseline + unit;
|
|
434
|
-
var factor = baseline / tempEl.offsetWidth;
|
|
435
|
-
parentEl.removeChild(tempEl);
|
|
436
|
-
var convertedUnit = factor * parseFloat(value);
|
|
437
|
-
cache.CSS[value + unit] = convertedUnit;
|
|
438
|
-
return convertedUnit;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
function getCSSValue(el, prop, unit) {
|
|
442
|
-
if (prop in el.style) {
|
|
443
|
-
var uppercasePropName = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
444
|
-
var value = el.style[prop] || getComputedStyle(el).getPropertyValue(uppercasePropName) || '0';
|
|
445
|
-
return unit ? convertPxToUnit(el, value, unit) : value;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
function getAnimationType(el, prop) {
|
|
450
|
-
if (is.dom(el) && !is.inp(el) && (!is.nil(getAttribute(el, prop)) || (is.svg(el) && el[prop]))) { return 'attribute'; }
|
|
451
|
-
if (is.dom(el) && arrayContains(validTransforms, prop)) { return 'transform'; }
|
|
452
|
-
if (is.dom(el) && (prop !== 'transform' && getCSSValue(el, prop))) { return 'css'; }
|
|
453
|
-
if (el[prop] != null) { return 'object'; }
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
function getElementTransforms(el) {
|
|
457
|
-
if (!is.dom(el)) { return; }
|
|
458
|
-
var str = el.style.transform || '';
|
|
459
|
-
var reg = /(\w+)\(([^)]*)\)/g;
|
|
460
|
-
var transforms = new Map();
|
|
461
|
-
var m; while (m = reg.exec(str)) { transforms.set(m[1], m[2]); }
|
|
462
|
-
return transforms;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
function getTransformValue(el, propName, animatable, unit) {
|
|
466
|
-
var defaultVal = stringContains(propName, 'scale') ? 1 : 0 + getTransformUnit(propName);
|
|
467
|
-
var value = getElementTransforms(el).get(propName) || defaultVal;
|
|
468
|
-
if (animatable) {
|
|
469
|
-
animatable.transforms.list.set(propName, value);
|
|
470
|
-
animatable.transforms['last'] = propName;
|
|
471
|
-
}
|
|
472
|
-
return unit ? convertPxToUnit(el, value, unit) : value;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
function getOriginalTargetValue(target, propName, unit, animatable) {
|
|
476
|
-
switch (getAnimationType(target, propName)) {
|
|
477
|
-
case 'transform': return getTransformValue(target, propName, animatable, unit);
|
|
478
|
-
case 'css': return getCSSValue(target, propName, unit);
|
|
479
|
-
case 'attribute': return getAttribute(target, propName);
|
|
480
|
-
default: return target[propName] || 0;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
function getRelativeValue(to, from) {
|
|
485
|
-
var operator = /^(\*=|\+=|-=)/.exec(to);
|
|
486
|
-
if (!operator) { return to; }
|
|
487
|
-
var u = getUnit(to) || 0;
|
|
488
|
-
var x = parseFloat(from);
|
|
489
|
-
var y = parseFloat(to.replace(operator[0], ''));
|
|
490
|
-
switch (operator[0][0]) {
|
|
491
|
-
case '+': return x + y + u;
|
|
492
|
-
case '-': return x - y + u;
|
|
493
|
-
case '*': return x * y + u;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
function validateValue(val, unit) {
|
|
498
|
-
if (is.col(val)) { return colorToRgb(val); }
|
|
499
|
-
if (/\s/g.test(val)) { return val; }
|
|
500
|
-
var originalUnit = getUnit(val);
|
|
501
|
-
var unitLess = originalUnit ? val.substr(0, val.length - originalUnit.length) : val;
|
|
502
|
-
if (unit) { return unitLess + unit; }
|
|
503
|
-
return unitLess;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
// getTotalLength() equivalent for circle, rect, polyline, polygon and line shapes
|
|
507
|
-
// adapted from https://gist.github.com/SebLambla/3e0550c496c236709744
|
|
508
|
-
|
|
509
|
-
function getDistance(p1, p2) {
|
|
510
|
-
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
function getCircleLength(el) {
|
|
514
|
-
return Math.PI * 2 * getAttribute(el, 'r');
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
function getRectLength(el) {
|
|
518
|
-
return (getAttribute(el, 'width') * 2) + (getAttribute(el, 'height') * 2);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
function getLineLength(el) {
|
|
522
|
-
return getDistance(
|
|
523
|
-
{x: getAttribute(el, 'x1'), y: getAttribute(el, 'y1')},
|
|
524
|
-
{x: getAttribute(el, 'x2'), y: getAttribute(el, 'y2')}
|
|
525
|
-
);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
function getPolylineLength(el) {
|
|
529
|
-
var points = el.points;
|
|
530
|
-
var totalLength = 0;
|
|
531
|
-
var previousPos;
|
|
532
|
-
for (var i = 0 ; i < points.numberOfItems; i++) {
|
|
533
|
-
var currentPos = points.getItem(i);
|
|
534
|
-
if (i > 0) { totalLength += getDistance(previousPos, currentPos); }
|
|
535
|
-
previousPos = currentPos;
|
|
536
|
-
}
|
|
537
|
-
return totalLength;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
function getPolygonLength(el) {
|
|
541
|
-
var points = el.points;
|
|
542
|
-
return getPolylineLength(el) + getDistance(points.getItem(points.numberOfItems - 1), points.getItem(0));
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
// Path animation
|
|
546
|
-
|
|
547
|
-
function getTotalLength(el) {
|
|
548
|
-
if (el.getTotalLength) { return el.getTotalLength(); }
|
|
549
|
-
switch(el.tagName.toLowerCase()) {
|
|
550
|
-
case 'circle': return getCircleLength(el);
|
|
551
|
-
case 'rect': return getRectLength(el);
|
|
552
|
-
case 'line': return getLineLength(el);
|
|
553
|
-
case 'polyline': return getPolylineLength(el);
|
|
554
|
-
case 'polygon': return getPolygonLength(el);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
function setDashoffset(el) {
|
|
559
|
-
var pathLength = getTotalLength(el);
|
|
560
|
-
el.setAttribute('stroke-dasharray', pathLength);
|
|
561
|
-
return pathLength;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
// Motion path
|
|
565
|
-
|
|
566
|
-
function getParentSvgEl(el) {
|
|
567
|
-
var parentEl = el.parentNode;
|
|
568
|
-
while (is.svg(parentEl)) {
|
|
569
|
-
if (!is.svg(parentEl.parentNode)) { break; }
|
|
570
|
-
parentEl = parentEl.parentNode;
|
|
571
|
-
}
|
|
572
|
-
return parentEl;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
function getParentSvg(pathEl, svgData) {
|
|
576
|
-
var svg = svgData || {};
|
|
577
|
-
var parentSvgEl = svg.el || getParentSvgEl(pathEl);
|
|
578
|
-
var rect = parentSvgEl.getBoundingClientRect();
|
|
579
|
-
var viewBoxAttr = getAttribute(parentSvgEl, 'viewBox');
|
|
580
|
-
var width = rect.width;
|
|
581
|
-
var height = rect.height;
|
|
582
|
-
var viewBox = svg.viewBox || (viewBoxAttr ? viewBoxAttr.split(' ') : [0, 0, width, height]);
|
|
583
|
-
return {
|
|
584
|
-
el: parentSvgEl,
|
|
585
|
-
viewBox: viewBox,
|
|
586
|
-
x: viewBox[0] / 1,
|
|
587
|
-
y: viewBox[1] / 1,
|
|
588
|
-
w: width,
|
|
589
|
-
h: height,
|
|
590
|
-
vW: viewBox[2],
|
|
591
|
-
vH: viewBox[3]
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
function getPath(path, percent) {
|
|
596
|
-
var pathEl = is.str(path) ? selectString(path)[0] : path;
|
|
597
|
-
var p = percent || 100;
|
|
598
|
-
return function(property) {
|
|
599
|
-
return {
|
|
600
|
-
property: property,
|
|
601
|
-
el: pathEl,
|
|
602
|
-
svg: getParentSvg(pathEl),
|
|
603
|
-
totalLength: getTotalLength(pathEl) * (p / 100)
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
function getPathProgress(path, progress, isPathTargetInsideSVG) {
|
|
609
|
-
function point(offset) {
|
|
610
|
-
if ( offset === void 0 ) offset = 0;
|
|
611
|
-
|
|
612
|
-
var l = progress + offset >= 1 ? progress + offset : 0;
|
|
613
|
-
return path.el.getPointAtLength(l);
|
|
614
|
-
}
|
|
615
|
-
var svg = getParentSvg(path.el, path.svg);
|
|
616
|
-
var p = point();
|
|
617
|
-
var p0 = point(-1);
|
|
618
|
-
var p1 = point(+1);
|
|
619
|
-
var scaleX = isPathTargetInsideSVG ? 1 : svg.w / svg.vW;
|
|
620
|
-
var scaleY = isPathTargetInsideSVG ? 1 : svg.h / svg.vH;
|
|
621
|
-
switch (path.property) {
|
|
622
|
-
case 'x': return (p.x - svg.x) * scaleX;
|
|
623
|
-
case 'y': return (p.y - svg.y) * scaleY;
|
|
624
|
-
case 'angle': return Math.atan2(p1.y - p0.y, p1.x - p0.x) * 180 / Math.PI;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
// Decompose value
|
|
629
|
-
|
|
630
|
-
function decomposeValue(val, unit) {
|
|
631
|
-
// const rgx = /-?\d*\.?\d+/g; // handles basic numbers
|
|
632
|
-
// const rgx = /[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g; // handles exponents notation
|
|
633
|
-
var rgx = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g; // handles exponents notation
|
|
634
|
-
var value = validateValue((is.pth(val) ? val.totalLength : val), unit) + '';
|
|
635
|
-
return {
|
|
636
|
-
original: value,
|
|
637
|
-
numbers: value.match(rgx) ? value.match(rgx).map(Number) : [0],
|
|
638
|
-
strings: (is.str(val) || unit) ? value.split(rgx) : []
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
// Animatables
|
|
643
|
-
|
|
644
|
-
function parseTargets(targets) {
|
|
645
|
-
var targetsArray = targets ? (flattenArray(is.arr(targets) ? targets.map(toArray) : toArray(targets))) : [];
|
|
646
|
-
return filterArray(targetsArray, function (item, pos, self) { return self.indexOf(item) === pos; });
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
function getAnimatables(targets) {
|
|
650
|
-
var parsed = parseTargets(targets);
|
|
651
|
-
return parsed.map(function (t, i) {
|
|
652
|
-
return {target: t, id: i, total: parsed.length, transforms: { list: getElementTransforms(t) } };
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
// Properties
|
|
657
|
-
|
|
658
|
-
function normalizePropertyTweens(prop, tweenSettings) {
|
|
659
|
-
var settings = cloneObject(tweenSettings);
|
|
660
|
-
// Override duration if easing is a spring
|
|
661
|
-
if (/^spring/.test(settings.easing)) { settings.duration = spring(settings.easing); }
|
|
662
|
-
if (is.arr(prop)) {
|
|
663
|
-
var l = prop.length;
|
|
664
|
-
var isFromTo = (l === 2 && !is.obj(prop[0]));
|
|
665
|
-
if (!isFromTo) {
|
|
666
|
-
// Duration divided by the number of tweens
|
|
667
|
-
if (!is.fnc(tweenSettings.duration)) { settings.duration = tweenSettings.duration / l; }
|
|
668
|
-
} else {
|
|
669
|
-
// Transform [from, to] values shorthand to a valid tween value
|
|
670
|
-
prop = {value: prop};
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
var propArray = is.arr(prop) ? prop : [prop];
|
|
674
|
-
return propArray.map(function (v, i) {
|
|
675
|
-
var obj = (is.obj(v) && !is.pth(v)) ? v : {value: v};
|
|
676
|
-
// Default delay value should only be applied to the first tween
|
|
677
|
-
if (is.und(obj.delay)) { obj.delay = !i ? tweenSettings.delay : 0; }
|
|
678
|
-
// Default endDelay value should only be applied to the last tween
|
|
679
|
-
if (is.und(obj.endDelay)) { obj.endDelay = i === propArray.length - 1 ? tweenSettings.endDelay : 0; }
|
|
680
|
-
return obj;
|
|
681
|
-
}).map(function (k) { return mergeObjects(k, settings); });
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
function flattenKeyframes(keyframes) {
|
|
686
|
-
var propertyNames = filterArray(flattenArray(keyframes.map(function (key) { return Object.keys(key); })), function (p) { return is.key(p); })
|
|
687
|
-
.reduce(function (a,b) { if (a.indexOf(b) < 0) { a.push(b); } return a; }, []);
|
|
688
|
-
var properties = {};
|
|
689
|
-
var loop = function ( i ) {
|
|
690
|
-
var propName = propertyNames[i];
|
|
691
|
-
properties[propName] = keyframes.map(function (key) {
|
|
692
|
-
var newKey = {};
|
|
693
|
-
for (var p in key) {
|
|
694
|
-
if (is.key(p)) {
|
|
695
|
-
if (p == propName) { newKey.value = key[p]; }
|
|
696
|
-
} else {
|
|
697
|
-
newKey[p] = key[p];
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
return newKey;
|
|
701
|
-
});
|
|
702
|
-
};
|
|
703
|
-
|
|
704
|
-
for (var i = 0; i < propertyNames.length; i++) loop( i );
|
|
705
|
-
return properties;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
function getProperties(tweenSettings, params) {
|
|
709
|
-
var properties = [];
|
|
710
|
-
var keyframes = params.keyframes;
|
|
711
|
-
if (keyframes) { params = mergeObjects(flattenKeyframes(keyframes), params); }
|
|
712
|
-
for (var p in params) {
|
|
713
|
-
if (is.key(p)) {
|
|
714
|
-
properties.push({
|
|
715
|
-
name: p,
|
|
716
|
-
tweens: normalizePropertyTweens(params[p], tweenSettings)
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
return properties;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
// Tweens
|
|
724
|
-
|
|
725
|
-
function normalizeTweenValues(tween, animatable) {
|
|
726
|
-
var t = {};
|
|
727
|
-
for (var p in tween) {
|
|
728
|
-
var value = getFunctionValue(tween[p], animatable);
|
|
729
|
-
if (is.arr(value)) {
|
|
730
|
-
value = value.map(function (v) { return getFunctionValue(v, animatable); });
|
|
731
|
-
if (value.length === 1) { value = value[0]; }
|
|
732
|
-
}
|
|
733
|
-
t[p] = value;
|
|
734
|
-
}
|
|
735
|
-
t.duration = parseFloat(t.duration);
|
|
736
|
-
t.delay = parseFloat(t.delay);
|
|
737
|
-
return t;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
function normalizeTweens(prop, animatable) {
|
|
741
|
-
var previousTween;
|
|
742
|
-
return prop.tweens.map(function (t) {
|
|
743
|
-
var tween = normalizeTweenValues(t, animatable);
|
|
744
|
-
var tweenValue = tween.value;
|
|
745
|
-
var to = is.arr(tweenValue) ? tweenValue[1] : tweenValue;
|
|
746
|
-
var toUnit = getUnit(to);
|
|
747
|
-
var originalValue = getOriginalTargetValue(animatable.target, prop.name, toUnit, animatable);
|
|
748
|
-
var previousValue = previousTween ? previousTween.to.original : originalValue;
|
|
749
|
-
var from = is.arr(tweenValue) ? tweenValue[0] : previousValue;
|
|
750
|
-
var fromUnit = getUnit(from) || getUnit(originalValue);
|
|
751
|
-
var unit = toUnit || fromUnit;
|
|
752
|
-
if (is.und(to)) { to = previousValue; }
|
|
753
|
-
tween.from = decomposeValue(from, unit);
|
|
754
|
-
tween.to = decomposeValue(getRelativeValue(to, from), unit);
|
|
755
|
-
tween.start = previousTween ? previousTween.end : 0;
|
|
756
|
-
tween.end = tween.start + tween.delay + tween.duration + tween.endDelay;
|
|
757
|
-
tween.easing = parseEasings(tween.easing, tween.duration);
|
|
758
|
-
tween.isPath = is.pth(tweenValue);
|
|
759
|
-
tween.isPathTargetInsideSVG = tween.isPath && is.svg(animatable.target);
|
|
760
|
-
tween.isColor = is.col(tween.from.original);
|
|
761
|
-
if (tween.isColor) { tween.round = 1; }
|
|
762
|
-
previousTween = tween;
|
|
763
|
-
return tween;
|
|
764
|
-
});
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
// Tween progress
|
|
768
|
-
|
|
769
|
-
var setProgressValue = {
|
|
770
|
-
css: function (t, p, v) { return t.style[p] = v; },
|
|
771
|
-
attribute: function (t, p, v) { return t.setAttribute(p, v); },
|
|
772
|
-
object: function (t, p, v) { return t[p] = v; },
|
|
773
|
-
transform: function (t, p, v, transforms, manual) {
|
|
774
|
-
transforms.list.set(p, v);
|
|
775
|
-
if (p === transforms.last || manual) {
|
|
776
|
-
var str = '';
|
|
777
|
-
transforms.list.forEach(function (value, prop) { str += prop + "(" + value + ") "; });
|
|
778
|
-
t.style.transform = str;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
// Set Value helper
|
|
784
|
-
|
|
785
|
-
function setTargetsValue(targets, properties) {
|
|
786
|
-
var animatables = getAnimatables(targets);
|
|
787
|
-
animatables.forEach(function (animatable) {
|
|
788
|
-
for (var property in properties) {
|
|
789
|
-
var value = getFunctionValue(properties[property], animatable);
|
|
790
|
-
var target = animatable.target;
|
|
791
|
-
var valueUnit = getUnit(value);
|
|
792
|
-
var originalValue = getOriginalTargetValue(target, property, valueUnit, animatable);
|
|
793
|
-
var unit = valueUnit || getUnit(originalValue);
|
|
794
|
-
var to = getRelativeValue(validateValue(value, unit), originalValue);
|
|
795
|
-
var animType = getAnimationType(target, property);
|
|
796
|
-
setProgressValue[animType](target, property, to, animatable.transforms, true);
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
// Animations
|
|
802
|
-
|
|
803
|
-
function createAnimation(animatable, prop) {
|
|
804
|
-
var animType = getAnimationType(animatable.target, prop.name);
|
|
805
|
-
if (animType) {
|
|
806
|
-
var tweens = normalizeTweens(prop, animatable);
|
|
807
|
-
var lastTween = tweens[tweens.length - 1];
|
|
808
|
-
return {
|
|
809
|
-
type: animType,
|
|
810
|
-
property: prop.name,
|
|
811
|
-
animatable: animatable,
|
|
812
|
-
tweens: tweens,
|
|
813
|
-
duration: lastTween.end,
|
|
814
|
-
delay: tweens[0].delay,
|
|
815
|
-
endDelay: lastTween.endDelay
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
function getAnimations(animatables, properties) {
|
|
821
|
-
return filterArray(flattenArray(animatables.map(function (animatable) {
|
|
822
|
-
return properties.map(function (prop) {
|
|
823
|
-
return createAnimation(animatable, prop);
|
|
824
|
-
});
|
|
825
|
-
})), function (a) { return !is.und(a); });
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
// Create Instance
|
|
829
|
-
|
|
830
|
-
function getInstanceTimings(animations, tweenSettings) {
|
|
831
|
-
var animLength = animations.length;
|
|
832
|
-
var getTlOffset = function (anim) { return anim.timelineOffset ? anim.timelineOffset : 0; };
|
|
833
|
-
var timings = {};
|
|
834
|
-
timings.duration = animLength ? Math.max.apply(Math, animations.map(function (anim) { return getTlOffset(anim) + anim.duration; })) : tweenSettings.duration;
|
|
835
|
-
timings.delay = animLength ? Math.min.apply(Math, animations.map(function (anim) { return getTlOffset(anim) + anim.delay; })) : tweenSettings.delay;
|
|
836
|
-
timings.endDelay = animLength ? timings.duration - Math.max.apply(Math, animations.map(function (anim) { return getTlOffset(anim) + anim.duration - anim.endDelay; })) : tweenSettings.endDelay;
|
|
837
|
-
return timings;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
var instanceID = 0;
|
|
841
|
-
|
|
842
|
-
function createNewInstance(params) {
|
|
843
|
-
var instanceSettings = replaceObjectProps(defaultInstanceSettings, params);
|
|
844
|
-
var tweenSettings = replaceObjectProps(defaultTweenSettings, params);
|
|
845
|
-
var properties = getProperties(tweenSettings, params);
|
|
846
|
-
var animatables = getAnimatables(params.targets);
|
|
847
|
-
var animations = getAnimations(animatables, properties);
|
|
848
|
-
var timings = getInstanceTimings(animations, tweenSettings);
|
|
849
|
-
var id = instanceID;
|
|
850
|
-
instanceID++;
|
|
851
|
-
return mergeObjects(instanceSettings, {
|
|
852
|
-
id: id,
|
|
853
|
-
children: [],
|
|
854
|
-
animatables: animatables,
|
|
855
|
-
animations: animations,
|
|
856
|
-
duration: timings.duration,
|
|
857
|
-
delay: timings.delay,
|
|
858
|
-
endDelay: timings.endDelay
|
|
859
|
-
});
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
// Core
|
|
863
|
-
|
|
864
|
-
var activeInstances = [];
|
|
865
|
-
|
|
866
|
-
var engine = (function () {
|
|
867
|
-
var raf;
|
|
868
|
-
|
|
869
|
-
function play() {
|
|
870
|
-
if (!raf && (!isDocumentHidden() || !anime.suspendWhenDocumentHidden) && activeInstances.length > 0) {
|
|
871
|
-
raf = requestAnimationFrame(step);
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
function step(t) {
|
|
875
|
-
// memo on algorithm issue:
|
|
876
|
-
// dangerous iteration over mutable `activeInstances`
|
|
877
|
-
// (that collection may be updated from within callbacks of `tick`-ed animation instances)
|
|
878
|
-
var activeInstancesLength = activeInstances.length;
|
|
879
|
-
var i = 0;
|
|
880
|
-
while (i < activeInstancesLength) {
|
|
881
|
-
var activeInstance = activeInstances[i];
|
|
882
|
-
if (!activeInstance.paused) {
|
|
883
|
-
activeInstance.tick(t);
|
|
884
|
-
i++;
|
|
885
|
-
} else {
|
|
886
|
-
activeInstances.splice(i, 1);
|
|
887
|
-
activeInstancesLength--;
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
raf = i > 0 ? requestAnimationFrame(step) : undefined;
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
function handleVisibilityChange() {
|
|
894
|
-
if (!anime.suspendWhenDocumentHidden) { return; }
|
|
895
|
-
|
|
896
|
-
if (isDocumentHidden()) {
|
|
897
|
-
// suspend ticks
|
|
898
|
-
raf = cancelAnimationFrame(raf);
|
|
899
|
-
} else { // is back to active tab
|
|
900
|
-
// first adjust animations to consider the time that ticks were suspended
|
|
901
|
-
activeInstances.forEach(
|
|
902
|
-
function (instance) { return instance ._onDocumentVisibility(); }
|
|
903
|
-
);
|
|
904
|
-
engine();
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
if (typeof document !== 'undefined') {
|
|
908
|
-
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
return play;
|
|
912
|
-
})();
|
|
913
|
-
|
|
914
|
-
function isDocumentHidden() {
|
|
915
|
-
return !!document && document.hidden;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
// Public Instance
|
|
919
|
-
|
|
920
|
-
function anime(params) {
|
|
921
|
-
if ( params === void 0 ) params = {};
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
var startTime = 0, lastTime = 0, now = 0;
|
|
925
|
-
var children, childrenLength = 0;
|
|
926
|
-
var resolve = null;
|
|
927
|
-
|
|
928
|
-
function makePromise(instance) {
|
|
929
|
-
var promise = window.Promise && new Promise(function (_resolve) { return resolve = _resolve; });
|
|
930
|
-
instance.finished = promise;
|
|
931
|
-
return promise;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
var instance = createNewInstance(params);
|
|
935
|
-
makePromise(instance);
|
|
936
|
-
|
|
937
|
-
function toggleInstanceDirection() {
|
|
938
|
-
var direction = instance.direction;
|
|
939
|
-
if (direction !== 'alternate') {
|
|
940
|
-
instance.direction = direction !== 'normal' ? 'normal' : 'reverse';
|
|
941
|
-
}
|
|
942
|
-
instance.reversed = !instance.reversed;
|
|
943
|
-
children.forEach(function (child) { return child.reversed = instance.reversed; });
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
function adjustTime(time) {
|
|
947
|
-
return instance.reversed ? instance.duration - time : time;
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
function resetTime() {
|
|
951
|
-
startTime = 0;
|
|
952
|
-
lastTime = adjustTime(instance.currentTime) * (1 / anime.speed);
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
function seekChild(time, child) {
|
|
956
|
-
if (child) { child.seek(time - child.timelineOffset); }
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
function syncInstanceChildren(time) {
|
|
960
|
-
if (!instance.reversePlayback) {
|
|
961
|
-
for (var i = 0; i < childrenLength; i++) { seekChild(time, children[i]); }
|
|
962
|
-
} else {
|
|
963
|
-
for (var i$1 = childrenLength; i$1--;) { seekChild(time, children[i$1]); }
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
function setAnimationsProgress(insTime) {
|
|
968
|
-
var i = 0;
|
|
969
|
-
var animations = instance.animations;
|
|
970
|
-
var animationsLength = animations.length;
|
|
971
|
-
while (i < animationsLength) {
|
|
972
|
-
var anim = animations[i];
|
|
973
|
-
var animatable = anim.animatable;
|
|
974
|
-
var tweens = anim.tweens;
|
|
975
|
-
var tweenLength = tweens.length - 1;
|
|
976
|
-
var tween = tweens[tweenLength];
|
|
977
|
-
// Only check for keyframes if there is more than one tween
|
|
978
|
-
if (tweenLength) { tween = filterArray(tweens, function (t) { return (insTime < t.end); })[0] || tween; }
|
|
979
|
-
var elapsed = minMax(insTime - tween.start - tween.delay, 0, tween.duration) / tween.duration;
|
|
980
|
-
var eased = isNaN(elapsed) ? 1 : tween.easing(elapsed);
|
|
981
|
-
var strings = tween.to.strings;
|
|
982
|
-
var round = tween.round;
|
|
983
|
-
var numbers = [];
|
|
984
|
-
var toNumbersLength = tween.to.numbers.length;
|
|
985
|
-
var progress = (void 0);
|
|
986
|
-
for (var n = 0; n < toNumbersLength; n++) {
|
|
987
|
-
var value = (void 0);
|
|
988
|
-
var toNumber = tween.to.numbers[n];
|
|
989
|
-
var fromNumber = tween.from.numbers[n] || 0;
|
|
990
|
-
if (!tween.isPath) {
|
|
991
|
-
value = fromNumber + (eased * (toNumber - fromNumber));
|
|
992
|
-
} else {
|
|
993
|
-
value = getPathProgress(tween.value, eased * toNumber, tween.isPathTargetInsideSVG);
|
|
994
|
-
}
|
|
995
|
-
if (round) {
|
|
996
|
-
if (!(tween.isColor && n > 2)) {
|
|
997
|
-
value = Math.round(value * round) / round;
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
numbers.push(value);
|
|
1001
|
-
}
|
|
1002
|
-
// Manual Array.reduce for better performances
|
|
1003
|
-
var stringsLength = strings.length;
|
|
1004
|
-
if (!stringsLength) {
|
|
1005
|
-
progress = numbers[0];
|
|
1006
|
-
} else {
|
|
1007
|
-
progress = strings[0];
|
|
1008
|
-
for (var s = 0; s < stringsLength; s++) {
|
|
1009
|
-
var b = strings[s + 1];
|
|
1010
|
-
var n$1 = numbers[s];
|
|
1011
|
-
if (!isNaN(n$1)) {
|
|
1012
|
-
if (!b) {
|
|
1013
|
-
progress += n$1 + ' ';
|
|
1014
|
-
} else {
|
|
1015
|
-
progress += n$1 + b;
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
setProgressValue[anim.type](animatable.target, anim.property, progress, animatable.transforms);
|
|
1021
|
-
anim.currentValue = progress;
|
|
1022
|
-
i++;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
function setCallback(cb) {
|
|
1027
|
-
if (instance[cb] && !instance.passThrough) { instance[cb](instance); }
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
function countIteration() {
|
|
1031
|
-
if (instance.remaining && instance.remaining !== true) {
|
|
1032
|
-
instance.remaining--;
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
function setInstanceProgress(engineTime) {
|
|
1037
|
-
var insDuration = instance.duration;
|
|
1038
|
-
var insDelay = instance.delay;
|
|
1039
|
-
var insEndDelay = insDuration - instance.endDelay;
|
|
1040
|
-
var insTime = adjustTime(engineTime);
|
|
1041
|
-
instance.progress = minMax((insTime / insDuration) * 100, 0, 100);
|
|
1042
|
-
instance.reversePlayback = insTime < instance.currentTime;
|
|
1043
|
-
if (children) { syncInstanceChildren(insTime); }
|
|
1044
|
-
if (!instance.began && instance.currentTime > 0) {
|
|
1045
|
-
instance.began = true;
|
|
1046
|
-
setCallback('begin');
|
|
1047
|
-
}
|
|
1048
|
-
if (!instance.loopBegan && instance.currentTime > 0) {
|
|
1049
|
-
instance.loopBegan = true;
|
|
1050
|
-
setCallback('loopBegin');
|
|
1051
|
-
}
|
|
1052
|
-
if (insTime <= insDelay && instance.currentTime !== 0) {
|
|
1053
|
-
setAnimationsProgress(0);
|
|
1054
|
-
}
|
|
1055
|
-
if ((insTime >= insEndDelay && instance.currentTime !== insDuration) || !insDuration) {
|
|
1056
|
-
setAnimationsProgress(insDuration);
|
|
1057
|
-
}
|
|
1058
|
-
if (insTime > insDelay && insTime < insEndDelay) {
|
|
1059
|
-
if (!instance.changeBegan) {
|
|
1060
|
-
instance.changeBegan = true;
|
|
1061
|
-
instance.changeCompleted = false;
|
|
1062
|
-
setCallback('changeBegin');
|
|
1063
|
-
}
|
|
1064
|
-
setCallback('change');
|
|
1065
|
-
setAnimationsProgress(insTime);
|
|
1066
|
-
} else {
|
|
1067
|
-
if (instance.changeBegan) {
|
|
1068
|
-
instance.changeCompleted = true;
|
|
1069
|
-
instance.changeBegan = false;
|
|
1070
|
-
setCallback('changeComplete');
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
instance.currentTime = minMax(insTime, 0, insDuration);
|
|
1074
|
-
if (instance.began) { setCallback('update'); }
|
|
1075
|
-
if (engineTime >= insDuration) {
|
|
1076
|
-
lastTime = 0;
|
|
1077
|
-
countIteration();
|
|
1078
|
-
if (!instance.remaining) {
|
|
1079
|
-
instance.paused = true;
|
|
1080
|
-
if (!instance.completed) {
|
|
1081
|
-
instance.completed = true;
|
|
1082
|
-
setCallback('loopComplete');
|
|
1083
|
-
setCallback('complete');
|
|
1084
|
-
if (!instance.passThrough && 'Promise' in window) {
|
|
1085
|
-
resolve();
|
|
1086
|
-
makePromise(instance);
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
} else {
|
|
1090
|
-
startTime = now;
|
|
1091
|
-
setCallback('loopComplete');
|
|
1092
|
-
instance.loopBegan = false;
|
|
1093
|
-
if (instance.direction === 'alternate') {
|
|
1094
|
-
toggleInstanceDirection();
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
instance.reset = function() {
|
|
1101
|
-
var direction = instance.direction;
|
|
1102
|
-
instance.passThrough = false;
|
|
1103
|
-
instance.currentTime = 0;
|
|
1104
|
-
instance.progress = 0;
|
|
1105
|
-
instance.paused = true;
|
|
1106
|
-
instance.began = false;
|
|
1107
|
-
instance.loopBegan = false;
|
|
1108
|
-
instance.changeBegan = false;
|
|
1109
|
-
instance.completed = false;
|
|
1110
|
-
instance.changeCompleted = false;
|
|
1111
|
-
instance.reversePlayback = false;
|
|
1112
|
-
instance.reversed = direction === 'reverse';
|
|
1113
|
-
instance.remaining = instance.loop;
|
|
1114
|
-
children = instance.children;
|
|
1115
|
-
childrenLength = children.length;
|
|
1116
|
-
for (var i = childrenLength; i--;) { instance.children[i].reset(); }
|
|
1117
|
-
if (instance.reversed && instance.loop !== true || (direction === 'alternate' && instance.loop === 1)) { instance.remaining++; }
|
|
1118
|
-
setAnimationsProgress(instance.reversed ? instance.duration : 0);
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
|
-
// internal method (for engine) to adjust animation timings before restoring engine ticks (rAF)
|
|
1122
|
-
instance._onDocumentVisibility = resetTime;
|
|
1123
|
-
|
|
1124
|
-
// Set Value helper
|
|
1125
|
-
|
|
1126
|
-
instance.set = function(targets, properties) {
|
|
1127
|
-
setTargetsValue(targets, properties);
|
|
1128
|
-
return instance;
|
|
1129
|
-
};
|
|
1130
|
-
|
|
1131
|
-
instance.tick = function(t) {
|
|
1132
|
-
now = t;
|
|
1133
|
-
if (!startTime) { startTime = now; }
|
|
1134
|
-
setInstanceProgress((now + (lastTime - startTime)) * anime.speed);
|
|
1135
|
-
};
|
|
1136
|
-
|
|
1137
|
-
instance.seek = function(time) {
|
|
1138
|
-
setInstanceProgress(adjustTime(time));
|
|
1139
|
-
};
|
|
1140
|
-
|
|
1141
|
-
instance.pause = function() {
|
|
1142
|
-
instance.paused = true;
|
|
1143
|
-
resetTime();
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
instance.play = function() {
|
|
1147
|
-
if (!instance.paused) { return; }
|
|
1148
|
-
if (instance.completed) { instance.reset(); }
|
|
1149
|
-
instance.paused = false;
|
|
1150
|
-
activeInstances.push(instance);
|
|
1151
|
-
resetTime();
|
|
1152
|
-
engine();
|
|
1153
|
-
};
|
|
1154
|
-
|
|
1155
|
-
instance.reverse = function() {
|
|
1156
|
-
toggleInstanceDirection();
|
|
1157
|
-
instance.completed = instance.reversed ? false : true;
|
|
1158
|
-
resetTime();
|
|
1159
|
-
};
|
|
1160
|
-
|
|
1161
|
-
instance.restart = function() {
|
|
1162
|
-
instance.reset();
|
|
1163
|
-
instance.play();
|
|
1164
|
-
};
|
|
1165
|
-
|
|
1166
|
-
instance.remove = function(targets) {
|
|
1167
|
-
var targetsArray = parseTargets(targets);
|
|
1168
|
-
removeTargetsFromInstance(targetsArray, instance);
|
|
1169
|
-
};
|
|
1170
|
-
|
|
1171
|
-
instance.reset();
|
|
1172
|
-
|
|
1173
|
-
if (instance.autoplay) { instance.play(); }
|
|
1174
|
-
|
|
1175
|
-
return instance;
|
|
1176
|
-
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
// Remove targets from animation
|
|
1180
|
-
|
|
1181
|
-
function removeTargetsFromAnimations(targetsArray, animations) {
|
|
1182
|
-
for (var a = animations.length; a--;) {
|
|
1183
|
-
if (arrayContains(targetsArray, animations[a].animatable.target)) {
|
|
1184
|
-
animations.splice(a, 1);
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
function removeTargetsFromInstance(targetsArray, instance) {
|
|
1190
|
-
var animations = instance.animations;
|
|
1191
|
-
var children = instance.children;
|
|
1192
|
-
removeTargetsFromAnimations(targetsArray, animations);
|
|
1193
|
-
for (var c = children.length; c--;) {
|
|
1194
|
-
var child = children[c];
|
|
1195
|
-
var childAnimations = child.animations;
|
|
1196
|
-
removeTargetsFromAnimations(targetsArray, childAnimations);
|
|
1197
|
-
if (!childAnimations.length && !child.children.length) { children.splice(c, 1); }
|
|
1198
|
-
}
|
|
1199
|
-
if (!animations.length && !children.length) { instance.pause(); }
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
function removeTargetsFromActiveInstances(targets) {
|
|
1203
|
-
var targetsArray = parseTargets(targets);
|
|
1204
|
-
for (var i = activeInstances.length; i--;) {
|
|
1205
|
-
var instance = activeInstances[i];
|
|
1206
|
-
removeTargetsFromInstance(targetsArray, instance);
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
// Stagger helpers
|
|
1211
|
-
|
|
1212
|
-
function stagger(val, params) {
|
|
1213
|
-
if ( params === void 0 ) params = {};
|
|
1214
|
-
|
|
1215
|
-
var direction = params.direction || 'normal';
|
|
1216
|
-
var easing = params.easing ? parseEasings(params.easing) : null;
|
|
1217
|
-
var grid = params.grid;
|
|
1218
|
-
var axis = params.axis;
|
|
1219
|
-
var fromIndex = params.from || 0;
|
|
1220
|
-
var fromFirst = fromIndex === 'first';
|
|
1221
|
-
var fromCenter = fromIndex === 'center';
|
|
1222
|
-
var fromLast = fromIndex === 'last';
|
|
1223
|
-
var isRange = is.arr(val);
|
|
1224
|
-
var val1 = isRange ? parseFloat(val[0]) : parseFloat(val);
|
|
1225
|
-
var val2 = isRange ? parseFloat(val[1]) : 0;
|
|
1226
|
-
var unit = getUnit(isRange ? val[1] : val) || 0;
|
|
1227
|
-
var start = params.start || 0 + (isRange ? val1 : 0);
|
|
1228
|
-
var values = [];
|
|
1229
|
-
var maxValue = 0;
|
|
1230
|
-
return function (el, i, t) {
|
|
1231
|
-
if (fromFirst) { fromIndex = 0; }
|
|
1232
|
-
if (fromCenter) { fromIndex = (t - 1) / 2; }
|
|
1233
|
-
if (fromLast) { fromIndex = t - 1; }
|
|
1234
|
-
if (!values.length) {
|
|
1235
|
-
for (var index = 0; index < t; index++) {
|
|
1236
|
-
if (!grid) {
|
|
1237
|
-
values.push(Math.abs(fromIndex - index));
|
|
1238
|
-
} else {
|
|
1239
|
-
var fromX = !fromCenter ? fromIndex%grid[0] : (grid[0]-1)/2;
|
|
1240
|
-
var fromY = !fromCenter ? Math.floor(fromIndex/grid[0]) : (grid[1]-1)/2;
|
|
1241
|
-
var toX = index%grid[0];
|
|
1242
|
-
var toY = Math.floor(index/grid[0]);
|
|
1243
|
-
var distanceX = fromX - toX;
|
|
1244
|
-
var distanceY = fromY - toY;
|
|
1245
|
-
var value = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
|
|
1246
|
-
if (axis === 'x') { value = -distanceX; }
|
|
1247
|
-
if (axis === 'y') { value = -distanceY; }
|
|
1248
|
-
values.push(value);
|
|
1249
|
-
}
|
|
1250
|
-
maxValue = Math.max.apply(Math, values);
|
|
1251
|
-
}
|
|
1252
|
-
if (easing) { values = values.map(function (val) { return easing(val / maxValue) * maxValue; }); }
|
|
1253
|
-
if (direction === 'reverse') { values = values.map(function (val) { return axis ? (val < 0) ? val * -1 : -val : Math.abs(maxValue - val); }); }
|
|
1254
|
-
}
|
|
1255
|
-
var spacing = isRange ? (val2 - val1) / maxValue : val1;
|
|
1256
|
-
return start + (spacing * (Math.round(values[i] * 100) / 100)) + unit;
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
// Timeline
|
|
1261
|
-
|
|
1262
|
-
function timeline(params) {
|
|
1263
|
-
if ( params === void 0 ) params = {};
|
|
1264
|
-
|
|
1265
|
-
var tl = anime(params);
|
|
1266
|
-
tl.duration = 0;
|
|
1267
|
-
tl.add = function(instanceParams, timelineOffset) {
|
|
1268
|
-
var tlIndex = activeInstances.indexOf(tl);
|
|
1269
|
-
var children = tl.children;
|
|
1270
|
-
if (tlIndex > -1) { activeInstances.splice(tlIndex, 1); }
|
|
1271
|
-
function passThrough(ins) { ins.passThrough = true; }
|
|
1272
|
-
for (var i = 0; i < children.length; i++) { passThrough(children[i]); }
|
|
1273
|
-
var insParams = mergeObjects(instanceParams, replaceObjectProps(defaultTweenSettings, params));
|
|
1274
|
-
insParams.targets = insParams.targets || params.targets;
|
|
1275
|
-
var tlDuration = tl.duration;
|
|
1276
|
-
insParams.autoplay = false;
|
|
1277
|
-
insParams.direction = tl.direction;
|
|
1278
|
-
insParams.timelineOffset = is.und(timelineOffset) ? tlDuration : getRelativeValue(timelineOffset, tlDuration);
|
|
1279
|
-
passThrough(tl);
|
|
1280
|
-
tl.seek(insParams.timelineOffset);
|
|
1281
|
-
var ins = anime(insParams);
|
|
1282
|
-
passThrough(ins);
|
|
1283
|
-
children.push(ins);
|
|
1284
|
-
var timings = getInstanceTimings(children, params);
|
|
1285
|
-
tl.delay = timings.delay;
|
|
1286
|
-
tl.endDelay = timings.endDelay;
|
|
1287
|
-
tl.duration = timings.duration;
|
|
1288
|
-
tl.seek(0);
|
|
1289
|
-
tl.reset();
|
|
1290
|
-
if (tl.autoplay) { tl.play(); }
|
|
1291
|
-
return tl;
|
|
1292
|
-
};
|
|
1293
|
-
return tl;
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
anime.version = '3.2.1';
|
|
1297
|
-
anime.speed = 1;
|
|
1298
|
-
// TODO:#review: naming, documentation
|
|
1299
|
-
anime.suspendWhenDocumentHidden = true;
|
|
1300
|
-
anime.running = activeInstances;
|
|
1301
|
-
anime.remove = removeTargetsFromActiveInstances;
|
|
1302
|
-
anime.get = getOriginalTargetValue;
|
|
1303
|
-
anime.set = setTargetsValue;
|
|
1304
|
-
anime.convertPx = convertPxToUnit;
|
|
1305
|
-
anime.path = getPath;
|
|
1306
|
-
anime.setDashoffset = setDashoffset;
|
|
1307
|
-
anime.stagger = stagger;
|
|
1308
|
-
anime.timeline = timeline;
|
|
1309
|
-
anime.easing = parseEasings;
|
|
1310
|
-
anime.penner = penner;
|
|
1311
|
-
anime.random = function (min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; };
|
|
1312
|
-
|
|
1313
9
|
const stateMap = {
|
|
1314
10
|
success: "succes:",
|
|
1315
11
|
info: "info:",
|
|
@@ -1369,9 +65,9 @@ const HandleIcon = ({ state, icon, attachmentCount }) => {
|
|
|
1369
65
|
}
|
|
1370
66
|
};
|
|
1371
67
|
|
|
1372
|
-
const accordionSectionCss = "*,*::after,*::before{box-sizing:border-box}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}:host{display:block}:host .dso-section-handle{font-size:1em;font-weight:600;line-height:1.375em;margin:0;position:relative}:host .dso-section-handle>a:active{text-decoration:none}:host .dso-section-handle a{text-decoration:none}:host .dso-section-handle a:hover,:host .dso-section-handle a:focus{text-decoration:none}:host .dso-section-handle a:active{text-decoration:underline}:host .dso-section-handle .dso-status{font-weight:400;text-decoration:underline}:host .dso-section-handle>button,:host .dso-section-handle>a{align-items:
|
|
68
|
+
const accordionSectionCss = "*,*::after,*::before{box-sizing:border-box}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}:host{display:block}:host .dso-section-handle{font-size:1em;font-weight:600;line-height:1.375em;margin:0;position:relative}:host .dso-section-handle>a:active{text-decoration:none}:host .dso-section-handle a{text-decoration:none}:host .dso-section-handle a:hover,:host .dso-section-handle a:focus{text-decoration:none}:host .dso-section-handle a:active{text-decoration:underline}:host .dso-section-handle .dso-status{font-weight:400;text-decoration:underline}:host .dso-section-handle>button,:host .dso-section-handle>a{align-items:flex-start;background-color:transparent;border:0;cursor:pointer;display:flex;font-family:Asap, sans-serif;font-size:1em;font-weight:600;line-height:1.375em;margin:0;padding:12px 16px 12px;text-align:start;width:100%;word-break:break-word}:host .dso-section-handle>button dso-icon,:host .dso-section-handle>a dso-icon{flex-shrink:0}:host .dso-section-handle>button dso-icon.dso-section-handle-chevron,:host .dso-section-handle>a dso-icon.dso-section-handle-chevron{transition:transform 260ms cubic-bezier(0.4, 0, 0.2, 1);transform:rotate(0)}:host .dso-section-handle>button>.dso-section-handle-addons:first-child,:host .dso-section-handle>button>dso-icon:first-child,:host .dso-section-handle>a>.dso-section-handle-addons:first-child,:host .dso-section-handle>a>dso-icon:first-child{margin-right:8px}:host .dso-section-handle>button>dso-icon:last-child,:host .dso-section-handle>a>dso-icon:last-child{margin-left:auto}:host .dso-section-handle>button>.dso-section-handle-addons:last-child,:host .dso-section-handle>a>.dso-section-handle-addons:last-child{margin-left:auto}:host .dso-section-handle>button>.dso-section-handle-addons:last-child dso-attachments-counter,:host .dso-section-handle>button>.dso-section-handle-addons:last-child dso-icon,:host .dso-section-handle>a>.dso-section-handle-addons:last-child dso-attachments-counter,:host .dso-section-handle>a>.dso-section-handle-addons:last-child dso-icon{margin-left:16px}:host([open]) .dso-section-handle>button .dso-section-handle-chevron:first-child,:host([open]) .dso-section-handle>a .dso-section-handle-chevron:first-child{transform:rotate(90deg)}:host([open]) .dso-section-handle>button .dso-section-handle-chevron:last-child,:host([open]) .dso-section-handle>a .dso-section-handle-chevron:last-child{transform:rotate(-180deg)}.dso-section-body{background-color:#fff;border-top:0;margin-top:-4px}.dso-section-body .dso-section-body-content{padding:20px 16px 16px}:host(.dso-accordion-default) .dso-section-handle{background-color:#fff;border:1px solid #8b4a6a;border-radius:4px}:host(.dso-accordion-default) .dso-section-handle a,:host(.dso-accordion-default) .dso-section-handle button{color:#8b4a6a}:host(.dso-accordion-default) .dso-section-handle a:hover,:host(.dso-accordion-default) .dso-section-handle a:active,:host(.dso-accordion-default) .dso-section-handle a.active,:host(.dso-accordion-default) .dso-section-handle button:hover,:host(.dso-accordion-default) .dso-section-handle button:active,:host(.dso-accordion-default) .dso-section-handle button.active{color:#8b4a6a}:host(.dso-accordion-default) .dso-section-body{border:1px solid #8b4a6a;border-radius:0 0 4px 4px}:host(.dso-accordion-default[open])>.dso-section-handle{background-color:#8b4a6a;border-radius:0;border-top-left-radius:4px;border-top-right-radius:4px}:host(.dso-accordion-default[open])>.dso-section-handle a,:host(.dso-accordion-default[open])>.dso-section-handle button{color:#fff}:host(.dso-accordion-default[open])>.dso-section-handle a dso-attachments-counter,:host(.dso-accordion-default[open])>.dso-section-handle button dso-attachments-counter{--dso-attachments-counter-color:#fff;--dso-icon:var(--di-paperclip-wit)}:host(.dso-accordion-default.dso-nested-accordion[open]) .dso-section-body{background-color:#e5e5e5}:host(.dso-accordion-compact) .dso-section-handle{border-bottom:1px solid transparent;border-top:1px solid #ccc}:host(.dso-accordion-compact) .dso-section-handle a,:host(.dso-accordion-compact) .dso-section-handle button{color:#39870c;padding-bottom:11px;padding-left:0;padding-top:11px}:host(.dso-accordion-compact) .dso-section-handle a:hover,:host(.dso-accordion-compact) .dso-section-handle a:active,:host(.dso-accordion-compact) .dso-section-handle a.active,:host(.dso-accordion-compact) .dso-section-handle button:hover,:host(.dso-accordion-compact) .dso-section-handle button:active,:host(.dso-accordion-compact) .dso-section-handle button.active{color:#39870c}:host(.dso-accordion-compact) .dso-section-body .dso-section-body-content{padding-left:32px;padding-top:0;padding-right:0}:host(.dso-accordion-compact.dso-accordion-reverse-align) .dso-section-handle a,:host(.dso-accordion-compact.dso-accordion-reverse-align) .dso-section-handle button{padding-left:16px}:host(.dso-accordion-compact.dso-accordion-reverse-align) .dso-section-body .dso-section-body-content{padding-left:16px;padding-right:0}:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-handle{background-color:transparent}:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-handle a,:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-handle button{color:#39870c}:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-handle a:hover,:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-handle a:active,:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-handle a.active,:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-handle button:hover,:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-handle button:active,:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-handle button.active{color:#39870c}:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-handle a dso-attachments-counter,:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-handle button dso-attachments-counter{--dso-attachments-counter-color:#666;--dso-icon:var(--di-paperclip-grijs)}:host(.dso-accordion-compact[open]:not(.dso-nested-accordion))>.dso-section-body{border-top:0}:host(.dso-accordion-compact.dso-nested-accordion[open])>.dso-section-body{padding-bottom:0}:host(.dso-accordion-compact.dso-nested-accordion[open])>.dso-section-body dso-accordion-section:last-child{border-bottom:0}:host(.dso-accordion-conclusion) .dso-section-handle{background-color:#f2f2f2;border:1px solid #f2f2f2}:host(.dso-accordion-conclusion) .dso-section-handle a,:host(.dso-accordion-conclusion) .dso-section-handle button{color:#000}:host(.dso-accordion-conclusion) .dso-section-handle a:hover,:host(.dso-accordion-conclusion) .dso-section-handle a:active,:host(.dso-accordion-conclusion) .dso-section-handle a.active,:host(.dso-accordion-conclusion) .dso-section-handle button:hover,:host(.dso-accordion-conclusion) .dso-section-handle button:active,:host(.dso-accordion-conclusion) .dso-section-handle button.active{background-color:#e5e5e5}:host(.dso-accordion-conclusion) .dso-section-handle a dso-attachments-counter,:host(.dso-accordion-conclusion) .dso-section-handle button dso-attachments-counter{--dso-attachments-counter-color:#000;--dso-icon:var(--di-paperclip-zwart)}:host(.dso-accordion-conclusion) .dso-section-body{border:2px solid #f2f2f2}:host(.dso-accordion-conclusion[open]:not(.dso-nested-accordion))>.dso-section-handle{background-color:#f2f2f2}:host(.dso-accordion-conclusion.dso-nested-accordion[open]){background-color:#fff}:host(.dso-accordion-neutral) .dso-section-handle{background-color:transparent;border:none;border-radius:4px;margin-block-end:2px}:host(.dso-accordion-neutral) .dso-section-handle a,:host(.dso-accordion-neutral) .dso-section-handle button{color:#000;padding:5px 16px 5px 0}:host(.dso-accordion-neutral) .dso-section-handle a:hover,:host(.dso-accordion-neutral) .dso-section-handle a:active,:host(.dso-accordion-neutral) .dso-section-handle a.active,:host(.dso-accordion-neutral) .dso-section-handle button:hover,:host(.dso-accordion-neutral) .dso-section-handle button:active,:host(.dso-accordion-neutral) .dso-section-handle button.active{color:#000}:host(.dso-accordion-neutral) .dso-section-handle a .info-icon,:host(.dso-accordion-neutral) .dso-section-handle button .info-icon{color:#39870c;margin-inline-start:8px}:host(.dso-accordion-neutral) .dso-section-body{background-color:transparent;border:1px solid #275937;box-shadow:1px 3px 4px rgba(0, 0, 0, 0.5);margin-block:0}:host(.dso-accordion-neutral) .dso-section-body.dso-animate-ready{transition:margin-block 260ms cubic-bezier(0.4, 0, 0.2, 1)}:host(.dso-accordion-neutral) .dso-section-body .dso-section-body-content{padding:16px 32px 24px 32px}:host(.dso-accordion-neutral[open])>.dso-section-handle{background-color:transparant;border-radius:0;border-top-left-radius:4px;border-top-right-radius:4px}:host(.dso-accordion-neutral[open])>.dso-section-handle a,:host(.dso-accordion-neutral[open])>.dso-section-handle button{color:#000}:host(.dso-accordion-neutral[open])>.dso-section-handle a dso-attachments-counter,:host(.dso-accordion-neutral[open])>.dso-section-handle button dso-attachments-counter{--dso-attachments-counter-color:#fff;--dso-icon:var(--di-paperclip-wit)}:host(.dso-accordion-neutral[open]) .dso-section-body{margin-block-end:16px;margin-block-start:2px}:host(.dso-accordion-neutral.dso-nested-accordion[open]) .dso-section-body{background-color:#e5e5e5}";
|
|
1373
69
|
|
|
1374
|
-
const AccordionSection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
70
|
+
const AccordionSection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
|
|
1375
71
|
constructor() {
|
|
1376
72
|
super();
|
|
1377
73
|
this.__registerHost();
|
|
@@ -1385,9 +81,7 @@ const AccordionSection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
1385
81
|
this.status = undefined;
|
|
1386
82
|
this.open = false;
|
|
1387
83
|
this.hasNestedSection = false;
|
|
1388
|
-
|
|
1389
|
-
toggleOpen() {
|
|
1390
|
-
this.activateAnimation();
|
|
84
|
+
this.hover = false;
|
|
1391
85
|
}
|
|
1392
86
|
componentWillLoad() {
|
|
1393
87
|
const accordion = this.host.parentElement;
|
|
@@ -1399,18 +93,6 @@ const AccordionSection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
1399
93
|
forceUpdate(this.host);
|
|
1400
94
|
});
|
|
1401
95
|
}
|
|
1402
|
-
this.prepareAnimationResizeObserver();
|
|
1403
|
-
}
|
|
1404
|
-
componentDidLoad() {
|
|
1405
|
-
var _a, _b;
|
|
1406
|
-
const bodyContentElement = (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(".dso-section-body-content");
|
|
1407
|
-
if (bodyContentElement) {
|
|
1408
|
-
(_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.observe(bodyContentElement);
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
disconnectedCallback() {
|
|
1412
|
-
var _a;
|
|
1413
|
-
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
1414
96
|
}
|
|
1415
97
|
/** Toggle this section.
|
|
1416
98
|
* @param scrollIntoView boolean - defaults to true
|
|
@@ -1427,6 +109,10 @@ const AccordionSection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
1427
109
|
async scrollSectionIntoView() {
|
|
1428
110
|
await this.scrollIntoViewWhenNeeded(false);
|
|
1429
111
|
}
|
|
112
|
+
get isNeutral() {
|
|
113
|
+
var _a;
|
|
114
|
+
return ((_a = this.accordionState) === null || _a === void 0 ? void 0 : _a.variant) === "neutral";
|
|
115
|
+
}
|
|
1430
116
|
async scrollIntoViewWhenNeeded(sectionToggled) {
|
|
1431
117
|
var _a, _b, _c;
|
|
1432
118
|
AccordionSection.scrollCandidate = undefined;
|
|
@@ -1435,12 +121,13 @@ const AccordionSection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
1435
121
|
if (!bodyClientRect || !headingClientRect || !this.accordionState) {
|
|
1436
122
|
return;
|
|
1437
123
|
}
|
|
1438
|
-
const waitForAnimationBeforeScrolling = (state) => {
|
|
1439
|
-
var _a;
|
|
1440
|
-
|
|
124
|
+
const waitForAnimationBeforeScrolling = async (state) => {
|
|
125
|
+
var _a, _b;
|
|
126
|
+
this.bodyHeight = await ((_a = this.expandable) === null || _a === void 0 ? void 0 : _a.getBodyHeight());
|
|
127
|
+
const sectionBottomOffsetTop = this.host.offsetTop + headingClientRect.height + (this.open ? (_b = this.bodyHeight) !== null && _b !== void 0 ? _b : 0 : 0);
|
|
1441
128
|
return (sectionToggled && (sectionBottomOffsetTop > document.documentElement.scrollHeight || state.allowMultipleOpen));
|
|
1442
129
|
};
|
|
1443
|
-
if (waitForAnimationBeforeScrolling(this.accordionState)) {
|
|
130
|
+
if (await waitForAnimationBeforeScrolling(this.accordionState)) {
|
|
1444
131
|
AccordionSection.scrollCandidate = this.host;
|
|
1445
132
|
return;
|
|
1446
133
|
}
|
|
@@ -1463,6 +150,32 @@ const AccordionSection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
1463
150
|
});
|
|
1464
151
|
}
|
|
1465
152
|
}
|
|
153
|
+
setAnimationBehaviour(event, section) {
|
|
154
|
+
const expandableElement = event.target;
|
|
155
|
+
if (!(expandableElement instanceof HTMLElement$1)) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (isExpandable(expandableElement)) {
|
|
159
|
+
this.expandable = expandableElement;
|
|
160
|
+
this.expandable.getAnimeInstance().then((animeInstance) => {
|
|
161
|
+
if (animeInstance) {
|
|
162
|
+
animeInstance.changeComplete = async () => {
|
|
163
|
+
if (!section) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const accordion = section.parentElement;
|
|
167
|
+
if (isAccordion(accordion)) {
|
|
168
|
+
accordion === null || accordion === void 0 ? void 0 : accordion.animationEnd(section);
|
|
169
|
+
}
|
|
170
|
+
if (AccordionSection.scrollCandidate === this.host) {
|
|
171
|
+
AccordionSection.scrollCandidate = undefined;
|
|
172
|
+
await this.scrollSectionIntoView();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
1466
179
|
async toggle(e) {
|
|
1467
180
|
var _a;
|
|
1468
181
|
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
@@ -1481,83 +194,9 @@ const AccordionSection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
1481
194
|
["dso-accordion-" + variant]: true,
|
|
1482
195
|
"dso-nested-accordion": this.hasNestedSection,
|
|
1483
196
|
"dso-accordion-reverse-align": reverseAlign !== null && reverseAlign !== void 0 ? reverseAlign : false,
|
|
1484
|
-
}, hidden: !variant }, h(Handle, { heading: this.heading, ref: (element) => (this.sectionHeading = element) }, h(HandleElement, { handleUrl: this.handleUrl, onClick: async (event) => await this.toggle(event), open: this.open }, reverseAlign ? (h(Fragment, null, hasAddons && (h("div", { class: "dso-section-handle-addons" }, h(HandleIcon, { icon: this.icon }))), h("span", null, this.handleTitle), h("dso-icon", { class: "dso-section-handle-chevron", icon: "chevron-down" }))) : (h(Fragment, null, h("dso-icon", { class: "dso-section-handle-chevron", icon: "chevron-right" }), this.state && h("span", { class: "sr-only" }, stateMap[this.state]), h("span", null, this.handleTitle), hasAddons && (h("div", { class: "dso-section-handle-addons" }, this.status && h("span", { class: "dso-status" }, this.status), h(HandleIcon, { state: this.state, icon: this.icon, attachmentCount: this.attachmentCount }))))))), h("
|
|
1485
|
-
}
|
|
1486
|
-
prepareAnimationResizeObserver() {
|
|
1487
|
-
this.resizeObserver = new ResizeObserver(debounce_1(([entry]) => {
|
|
1488
|
-
// entry.contentRect does not include padding, so we use getBoundingClientRect.
|
|
1489
|
-
const height = entry.target.getBoundingClientRect().height;
|
|
1490
|
-
if (this.bodyHeight !== height) {
|
|
1491
|
-
this.bodyHeight = height;
|
|
1492
|
-
this.instantiateAnimation();
|
|
1493
|
-
}
|
|
1494
|
-
}, 150));
|
|
1495
|
-
}
|
|
1496
|
-
instantiateAnimation() {
|
|
1497
|
-
this.animeInstance = anime({
|
|
1498
|
-
targets: this.sectionBody,
|
|
1499
|
-
height: 4,
|
|
1500
|
-
easing: "cubicBezier(0.4, 0, 0.2, 1)",
|
|
1501
|
-
duration: 260,
|
|
1502
|
-
autoplay: false,
|
|
1503
|
-
direction: "normal",
|
|
1504
|
-
changeComplete: async () => {
|
|
1505
|
-
var _a;
|
|
1506
|
-
(_a = this.accordion) === null || _a === void 0 ? void 0 : _a.animationEnd(this.host);
|
|
1507
|
-
if (AccordionSection.scrollCandidate === this.host) {
|
|
1508
|
-
AccordionSection.scrollCandidate = undefined;
|
|
1509
|
-
await this.scrollSectionIntoView();
|
|
1510
|
-
}
|
|
1511
|
-
},
|
|
1512
|
-
begin: () => {
|
|
1513
|
-
if (this.sectionBody) {
|
|
1514
|
-
if (this.open) {
|
|
1515
|
-
this.sectionBody.style.visibility = "";
|
|
1516
|
-
this.sectionBody.style.position = "";
|
|
1517
|
-
this.sectionBody.style.bottom = "";
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
},
|
|
1521
|
-
complete: () => {
|
|
1522
|
-
if (this.sectionBody) {
|
|
1523
|
-
this.sectionBody.style.height = "";
|
|
1524
|
-
if (!this.open) {
|
|
1525
|
-
this.sectionBody.style.visibility = "hidden";
|
|
1526
|
-
this.sectionBody.style.position = "absolute";
|
|
1527
|
-
this.sectionBody.style.bottom = "100%";
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
},
|
|
1531
|
-
});
|
|
1532
|
-
if (!this.open) {
|
|
1533
|
-
this.animeInstance.reverse();
|
|
1534
|
-
this.animeInstance.play();
|
|
1535
|
-
}
|
|
1536
|
-
if (this.sectionBody) {
|
|
1537
|
-
this.sectionBody.style.height = "";
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
activateAnimation() {
|
|
1541
|
-
if (this.animeInstance) {
|
|
1542
|
-
if (this.animeInstance.progress > 0 && this.animeInstance.progress < 100) {
|
|
1543
|
-
this.animeInstance.reverse();
|
|
1544
|
-
}
|
|
1545
|
-
else {
|
|
1546
|
-
if (this.open) {
|
|
1547
|
-
this.animeInstance.direction = "reverse";
|
|
1548
|
-
this.animeInstance.play();
|
|
1549
|
-
}
|
|
1550
|
-
else {
|
|
1551
|
-
this.animeInstance.direction = "normal";
|
|
1552
|
-
this.animeInstance.play();
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
197
|
+
}, hidden: !variant, onMouseenter: () => (this.hover = true), onMouseleave: () => (this.hover = false) }, h(Handle, { heading: this.heading, ref: (element) => (this.sectionHeading = element) }, h(HandleElement, { handleUrl: this.handleUrl, onClick: async (event) => await this.toggle(event), open: this.open }, reverseAlign ? (h(Fragment, null, hasAddons && (h("div", { class: "dso-section-handle-addons" }, h(HandleIcon, { icon: this.icon }))), h("span", null, this.handleTitle), h("dso-icon", { class: "dso-section-handle-chevron", icon: "chevron-down" }))) : (h(Fragment, null, h("dso-icon", { class: "dso-section-handle-chevron", icon: "chevron-right" }), this.state && h("span", { class: "sr-only" }, stateMap[this.state]), h("span", null, this.handleTitle, this.isNeutral && (h("dso-icon", { class: "info-icon", icon: this.open || this.hover ? "info-active" : "info" }))), hasAddons && (h("div", { class: "dso-section-handle-addons" }, this.status && h("span", { class: "dso-status" }, this.status), h(HandleIcon, { state: this.state, icon: this.icon, attachmentCount: this.attachmentCount }))))))), h("dso-expandable", { class: "dso-section-body", open: this.open, enableAnimation: true, minimumHeight: this.isNeutral ? 0 : 4, onAnimationInstantiated: (e) => this.setAnimationBehaviour(e, this.host) }, h("div", { slot: "expandable-content", class: "dso-section-body-content", ref: (element) => (this.sectionBody = element) }, h("slot", null)))));
|
|
1556
198
|
}
|
|
1557
199
|
get host() { return this; }
|
|
1558
|
-
static get watchers() { return {
|
|
1559
|
-
"open": ["toggleOpen"]
|
|
1560
|
-
}; }
|
|
1561
200
|
static get style() { return accordionSectionCss; }
|
|
1562
201
|
}, [1, "dso-accordion-section", {
|
|
1563
202
|
"handleTitle": [1, "handle-title"],
|
|
@@ -1569,23 +208,29 @@ const AccordionSection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
1569
208
|
"status": [1],
|
|
1570
209
|
"open": [1540],
|
|
1571
210
|
"hasNestedSection": [32],
|
|
211
|
+
"hover": [32],
|
|
1572
212
|
"toggleSection": [64],
|
|
1573
213
|
"scrollSectionIntoView": [64]
|
|
1574
214
|
}]);
|
|
1575
215
|
function isAccordion(element) {
|
|
1576
|
-
return element instanceof HTMLElement && "getState" in element;
|
|
216
|
+
return element instanceof HTMLElement$1 && "getState" in element;
|
|
1577
217
|
}
|
|
1578
218
|
function defineCustomElement$1() {
|
|
1579
219
|
if (typeof customElements === "undefined") {
|
|
1580
220
|
return;
|
|
1581
221
|
}
|
|
1582
|
-
const components = ["dso-accordion-section", "dso-icon"];
|
|
222
|
+
const components = ["dso-accordion-section", "dso-expandable", "dso-icon"];
|
|
1583
223
|
components.forEach(tagName => { switch (tagName) {
|
|
1584
224
|
case "dso-accordion-section":
|
|
1585
225
|
if (!customElements.get(tagName)) {
|
|
1586
226
|
customElements.define(tagName, AccordionSection);
|
|
1587
227
|
}
|
|
1588
228
|
break;
|
|
229
|
+
case "dso-expandable":
|
|
230
|
+
if (!customElements.get(tagName)) {
|
|
231
|
+
defineCustomElement$3();
|
|
232
|
+
}
|
|
233
|
+
break;
|
|
1589
234
|
case "dso-icon":
|
|
1590
235
|
if (!customElements.get(tagName)) {
|
|
1591
236
|
defineCustomElement$2();
|
|
@@ -1597,4 +242,4 @@ function defineCustomElement$1() {
|
|
|
1597
242
|
const DsoAccordionSection = AccordionSection;
|
|
1598
243
|
const defineCustomElement = defineCustomElement$1;
|
|
1599
244
|
|
|
1600
|
-
export { DsoAccordionSection, defineCustomElement };
|
|
245
|
+
export { DsoAccordionSection, defineCustomElement, isExpandable as i };
|