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