@qhealth-design-system/core 1.22.1 → 1.23.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/.storybook/assets/image-position-demo-portrait.svg +54 -0
- package/.storybook/assets/image-position-demo.svg +55 -0
- package/.storybook/globals.js +10 -1
- package/.storybook/preview.js +8 -1
- package/CHANGELOG.md +4 -0
- package/README.md +0 -6
- package/package.json +13 -33
- package/src/assets/img/svg-icons.svg +154 -154
- package/src/component-loader.js +11 -2
- package/src/components/_global/css/admin/component.scss +1 -0
- package/src/components/_global/css/btn/component.scss +9 -0
- package/src/components/_global/css/img/image-position-utility-classes.scss +30 -0
- package/src/components/_global/css/img/image-ratio-utility-classes.scss +41 -0
- package/src/components/_global/css/img/images.scss +74 -5
- package/src/components/_global/css/modal/component.scss +1 -0
- package/src/components/_global/js/animate/global.js +272 -294
- package/src/components/_global/js/collapsible.js +3 -3
- package/src/components/_global/js/global.js +304 -316
- package/src/components/_global/js/legacyGlobal.js +63 -0
- package/src/components/_global/js/modal/global.js +218 -223
- package/src/components/_global/js/popover/controller.js +4 -4
- package/src/components/_global/js/tabs/global.js +264 -276
- package/src/components/a-z_listing/js/global.js +106 -92
- package/src/components/accordion/css/component.scss +24 -41
- package/src/components/accordion/html/component.hbs +23 -5
- package/src/components/accordion/js/global.js +5 -10
- package/src/components/basic_search/js/global.js +0 -7
- package/src/components/code/js/global.js +6 -12
- package/src/components/file_upload/js/global.js +1 -5
- package/src/components/internal_navigation/css/component.scss +2 -2
- package/src/components/internal_navigation/html/component.hbs +16 -1
- package/src/components/main_navigation/js/global.js +341 -335
- package/src/components/overflow_menu/css/component.scss +1 -0
- package/src/components/search_box/css/component.scss +0 -1
- package/src/components/tab/js/global.js +5 -10
- package/src/components/toggle_tip/js/global.js +0 -6
- package/src/components/tool_tip/js/global.js +0 -6
- package/src/components/video_player/css/component.scss +27 -9
- package/src/components/video_player/html/component.hbs +32 -6
- package/src/components/video_player/js/global.js +8 -1
- package/src/index.js +4 -0
- package/src/stories/Accordion/accordion.stories.js +1 -0
- package/src/stories/Banner/bannerContained.stories.js +123 -0
- package/src/stories/Flexbox/Flexbox.stories.js +316 -0
- package/src/stories/Footer/Footer.stories.js +3 -3
- package/src/stories/Header/Header.js +1 -1
- package/src/stories/Image/Image.stories.js +182 -0
- package/src/stories/PromoPanel/PromoPanel.stories.js +1 -1
- package/src/stories/Templates/ContentPage.stories.js +101 -0
- package/src/stories/Templates/LandingPage.stories.js +193 -0
- package/src/stories/Templates/templateHelpers.js +102 -0
- package/src/stories/VideoPlayer/VideoPlayer.stories.js +16 -0
- package/src/styles/imports/utilities.scss +15 -25
- package/src/styles/imports/variables.scss +26 -0
- package/src/components/_global/html/head.html +0 -22
- package/src/components/_global/html/scripts.html +0 -28
- package/src/components/_global/js/_polyfills/global.js +0 -19
- package/src/components/_template/html/component-page.html +0 -75
- package/src/components/_template/js/global.js +0 -3
- package/src/components/accordion/html/accordion-group.html +0 -163
- package/src/components/accordion/html/default.html +0 -99
- package/src/components/banner_basic/js/global.js +0 -3
- package/src/components/loading_spinner/js/global.js +0 -3
- package/src/components/pagination/html/default.html +0 -39
- package/src/components/search_box/html/component.html +0 -26
- package/src/data/current.json +0 -400
- package/src/data/current_admin.json +0 -305
- package/src/data/model_component.js +0 -14
- package/src/data/site.json +0 -977
- package/src/externals/tinymce_classes.css +0 -62
- package/src/html/component-global-elements.html +0 -2857
- package/src/html/component-horizontal_rule.html +0 -647
- package/src/html/component-internal_navigation.html +0 -583
- package/src/html/component-left_hand_navigation.html +0 -57
- package/src/html/component-main_navigation.html +0 -583
- package/src/html/component-multi_column.html +0 -582
- package/src/html/components.html +0 -354
- package/src/html/home.html +0 -1898
- package/src/html/index.html +0 -129
- package/src/html/inner-with-nav.html +0 -605
- package/src/html/inner.html +0 -618
|
@@ -1,327 +1,305 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module animate
|
|
3
3
|
*/
|
|
4
|
-
(function (QLD) {
|
|
5
|
-
var animate = {};
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Calculate the requirements for the desired animation
|
|
9
|
-
*
|
|
10
|
-
* @memberof module:animate
|
|
11
|
-
* @instance
|
|
12
|
-
* @private
|
|
13
|
-
*
|
|
14
|
-
* @param {integer} initialSize - The initial size of the element to animate
|
|
15
|
-
* @param {integer} endSize - The size the element after the animation completes
|
|
16
|
-
* @param {string} speed - The speed of the animation in ms
|
|
17
|
-
*
|
|
18
|
-
* @return {object} - Required steps, stepSize and intervalTime for the animation
|
|
19
|
-
*/
|
|
20
|
-
function CalculateAnimationSpecs(initialSize, endSize, speed) {
|
|
21
|
-
if (initialSize === endSize) {
|
|
22
|
-
return {
|
|
23
|
-
stepSize: 0,
|
|
24
|
-
steps: 0,
|
|
25
|
-
intervalTime: 0,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var distance = endSize - initialSize; // the overall distance the animation needs to travel
|
|
30
|
-
var intervalTime = speed / distance; // the time each setInterval iteration will take
|
|
31
|
-
var stepSize = distance < 0 ? -1 : 1; // if distance is negative then we set stepSize to -1
|
|
32
|
-
var steps = Math.abs(distance / stepSize); // the amount of steps required to get to endSize
|
|
33
|
-
intervalTime = speed / steps;
|
|
34
|
-
|
|
35
|
-
// we need to adjust our animation specs if interval time exceeds 60FPS eg intervalTime < 16.67ms
|
|
36
|
-
if (Math.abs(intervalTime) < 1000 / 60) {
|
|
37
|
-
intervalTime = 1000 / 60; // let’s not get lower that 60FPS
|
|
38
|
-
steps = Math.ceil(Math.abs(speed / intervalTime)); // we now need the steps and make sure we ceil them so -1 won't make them negative
|
|
39
|
-
stepSize = distance / steps; // last thing is step sizes which are derived from all of the above
|
|
40
|
-
}
|
|
41
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Calculate the requirements for the desired animation
|
|
7
|
+
*
|
|
8
|
+
* @memberof module:animate
|
|
9
|
+
*
|
|
10
|
+
* @param {integer} initialSize - The initial size of the element to animate
|
|
11
|
+
* @param {integer} endSize - The size the element after the animation completes
|
|
12
|
+
* @param {string} speed - The speed of the animation in ms
|
|
13
|
+
*
|
|
14
|
+
* @return {object} - Required steps, stepSize and intervalTime for the animation
|
|
15
|
+
*/
|
|
16
|
+
export function CalculateAnimationSpecs(initialSize, endSize, speed) {
|
|
17
|
+
if (initialSize === endSize) {
|
|
42
18
|
return {
|
|
43
|
-
stepSize:
|
|
44
|
-
steps:
|
|
45
|
-
intervalTime:
|
|
19
|
+
stepSize: 0,
|
|
20
|
+
steps: 0,
|
|
21
|
+
intervalTime: 0,
|
|
46
22
|
};
|
|
47
23
|
}
|
|
48
24
|
|
|
49
|
-
//
|
|
50
|
-
if
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Getting computed CSS styles from normal browsers and IE
|
|
56
|
-
*
|
|
57
|
-
* @memberof module:animate
|
|
58
|
-
*
|
|
59
|
-
* @param {object} element - The DOM element we want to get the computed style from
|
|
60
|
-
* @param {string} property - The CSS property
|
|
61
|
-
*
|
|
62
|
-
* @return {string|integer} - The CSS value for the property
|
|
63
|
-
*/
|
|
64
|
-
animate.GetCSSPropertyBecauseIE = function (element, property) {
|
|
65
|
-
if (typeof getComputedStyle !== "undefined") {
|
|
66
|
-
return window.getComputedStyle(element)[property];
|
|
67
|
-
} else {
|
|
68
|
-
var space = element.currentStyle[property];
|
|
25
|
+
var distance = endSize - initialSize; // the overall distance the animation needs to travel
|
|
26
|
+
var stepSize = distance < 0 ? -1 : 1; // if distance is negative then we set stepSize to -1
|
|
27
|
+
var steps = Math.abs(distance / stepSize); // the amount of steps required to get to endSize
|
|
28
|
+
var intervalTime = speed / steps; // the time each setInterval iteration will take
|
|
69
29
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
30
|
+
// we need to adjust our animation specs if interval time exceeds 60FPS eg intervalTime < 16.67ms
|
|
31
|
+
if (Math.abs(intervalTime) < 1000 / 60) {
|
|
32
|
+
intervalTime = 1000 / 60; // let’s not get lower that 60FPS
|
|
33
|
+
steps = Math.ceil(Math.abs(speed / intervalTime)); // we now need the steps and make sure we ceil them so -1 won't make them negative
|
|
34
|
+
stepSize = distance / steps; // last thing is step sizes which are derived from all of the above
|
|
35
|
+
}
|
|
73
36
|
|
|
74
|
-
|
|
75
|
-
|
|
37
|
+
return {
|
|
38
|
+
stepSize: stepSize,
|
|
39
|
+
steps: steps - 1,
|
|
40
|
+
intervalTime: intervalTime,
|
|
76
41
|
};
|
|
42
|
+
}
|
|
77
43
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
element.style[dimension] = initialSize + "px"; // set back to initial height
|
|
97
|
-
} else {
|
|
98
|
-
initialSize = element.clientWidth;
|
|
99
|
-
element.style[dimension] = "auto";
|
|
100
|
-
endSize = element.clientWidth;
|
|
101
|
-
element.style[dimension] = initialSize + "px";
|
|
44
|
+
/**
|
|
45
|
+
* Getting computed CSS styles from normal browsers and IE
|
|
46
|
+
*
|
|
47
|
+
* @memberof module:animate
|
|
48
|
+
*
|
|
49
|
+
* @param {object} element - The DOM element we want to get the computed style from
|
|
50
|
+
* @param {string} property - The CSS property
|
|
51
|
+
*
|
|
52
|
+
* @return {string|integer} - The CSS value for the property
|
|
53
|
+
*/
|
|
54
|
+
export function GetCSSPropertyBecauseIE(element, property) {
|
|
55
|
+
if (typeof getComputedStyle !== "undefined") {
|
|
56
|
+
return window.getComputedStyle(element)[property];
|
|
57
|
+
} else {
|
|
58
|
+
var space = element.currentStyle[property];
|
|
59
|
+
|
|
60
|
+
if (space === "auto") {
|
|
61
|
+
space = CalculateAuto(element, property);
|
|
102
62
|
}
|
|
103
63
|
|
|
104
|
-
return
|
|
105
|
-
}
|
|
64
|
+
return space;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
106
67
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Calculate the size of the element when it’s dimension(height or width) is set to auto
|
|
70
|
+
*
|
|
71
|
+
* @memberof module:animate
|
|
72
|
+
*
|
|
73
|
+
* @param {object} element - The element to read auto height from
|
|
74
|
+
* @param {string} dimension - The dimension to measure
|
|
75
|
+
*
|
|
76
|
+
* @return {integer} - The size of the element when at dimension(height or width) is set to 'auto'
|
|
77
|
+
*/
|
|
78
|
+
export function CalculateAuto(element, dimension) {
|
|
79
|
+
var initialSize;
|
|
80
|
+
var endSize;
|
|
81
|
+
|
|
82
|
+
if (dimension === "height") {
|
|
83
|
+
initialSize = element.clientHeight; // get current height
|
|
84
|
+
element.style[dimension] = "auto"; // set height to auto
|
|
85
|
+
endSize = element.clientHeight; // get height again
|
|
86
|
+
element.style[dimension] = initialSize + "px"; // set back to initial height
|
|
87
|
+
} else {
|
|
88
|
+
initialSize = element.clientWidth;
|
|
89
|
+
element.style[dimension] = "auto";
|
|
90
|
+
endSize = element.clientWidth;
|
|
91
|
+
element.style[dimension] = initialSize + "px";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return parseInt(endSize);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Stop any au animation on a DOM element
|
|
99
|
+
*
|
|
100
|
+
* @memberof module:animate
|
|
101
|
+
*
|
|
102
|
+
* @param {object} element - The element to stop animating
|
|
103
|
+
*/
|
|
104
|
+
export function Stop(element) {
|
|
105
|
+
clearInterval(element.QLDanimation);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The magical animation function
|
|
110
|
+
*
|
|
111
|
+
* @memberof module:animate
|
|
112
|
+
*
|
|
113
|
+
* @param {object} options - The options for the animation
|
|
114
|
+
* @param {object} options.element - Element/s we are animating (DOM nodes)
|
|
115
|
+
* @param {string} options.property - The CSS property to animate
|
|
116
|
+
* @param {integer|string} options.endSize - The size the element should animate to. Can be 'auto' or pixel value
|
|
117
|
+
* @param {integer} options.speed - The speed of the animation in milliseconds [optional] [default: 250]
|
|
118
|
+
* @param {function} options.callback - A function to be executed after the animation ends [optional]
|
|
119
|
+
*
|
|
120
|
+
* @return {unknown} - The return value passed on from our options.callback function [optional]
|
|
121
|
+
*/
|
|
122
|
+
export function Run(options) {
|
|
123
|
+
// defaults
|
|
124
|
+
var elements = options.element;
|
|
125
|
+
var speed = options.speed || 250;
|
|
126
|
+
|
|
127
|
+
// making a single DOM element iteratable
|
|
128
|
+
if (elements.length === undefined) {
|
|
129
|
+
elements = [elements];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// making a callback if none was provided
|
|
133
|
+
if (typeof options.callback !== "function") {
|
|
134
|
+
options.callback = function () {};
|
|
135
|
+
}
|
|
117
136
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
var elements = options.element;
|
|
135
|
-
var speed = options.speed || 250;
|
|
136
|
-
|
|
137
|
-
// making a single DOM element iteratable
|
|
138
|
-
if (elements.length === undefined) {
|
|
139
|
-
elements = [elements];
|
|
137
|
+
// adding iteration counts
|
|
138
|
+
elements[0].QLDinteration = 0;
|
|
139
|
+
elements[0].QLDinterations = elements.length;
|
|
140
|
+
|
|
141
|
+
// iterate over all DOM nodes
|
|
142
|
+
for (var i = 0; i < elements.length; i++) {
|
|
143
|
+
var element = elements[i]; // this element
|
|
144
|
+
Stop(element); // stop any previous animations
|
|
145
|
+
var initialSize = parseInt(
|
|
146
|
+
GetCSSPropertyBecauseIE(element, options.property),
|
|
147
|
+
); // the elements current size
|
|
148
|
+
var endSize = options.endSize; // the element end size
|
|
149
|
+
|
|
150
|
+
if (options.endSize === "auto") {
|
|
151
|
+
// calculate what 'auto' means in pixel
|
|
152
|
+
endSize = CalculateAuto(element, options.property);
|
|
140
153
|
}
|
|
141
154
|
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
// calculate our animation specs
|
|
156
|
+
var animationSpecs = CalculateAnimationSpecs(initialSize, endSize, speed);
|
|
157
|
+
var iterateCounter = initialSize;
|
|
158
|
+
|
|
159
|
+
// set state
|
|
160
|
+
if (animationSpecs.stepSize < 0) {
|
|
161
|
+
element.QLDtoggleState = "closing";
|
|
162
|
+
} else if (animationSpecs.stepSize > 0) {
|
|
163
|
+
element.QLDtoggleState = "opening";
|
|
145
164
|
}
|
|
146
165
|
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
QLD.animate.Stop(element); // stop any previous animations
|
|
155
|
-
var initialSize = parseInt(
|
|
156
|
-
QLD.animate.GetCSSPropertyBecauseIE(element, options.property),
|
|
157
|
-
); // the elements current size
|
|
158
|
-
var endSize = options.endSize; // the element end size
|
|
159
|
-
|
|
160
|
-
if (options.endSize === "auto") {
|
|
161
|
-
// calculate what 'auto' means in pixel
|
|
162
|
-
endSize = QLD.animate.CalculateAuto(element, options.property);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// calculate our animation specs
|
|
166
|
-
var animationSpecs = CalculateAnimationSpecs(initialSize, endSize, speed);
|
|
167
|
-
var iterateCounter = initialSize;
|
|
168
|
-
|
|
169
|
-
// set state
|
|
170
|
-
if (animationSpecs.stepSize < 0) {
|
|
171
|
-
element.QLDtoggleState = "closing";
|
|
172
|
-
} else if (animationSpecs.stepSize > 0) {
|
|
173
|
-
element.QLDtoggleState = "opening";
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// scoping variable
|
|
177
|
-
(function (
|
|
178
|
-
element,
|
|
179
|
-
initialSize,
|
|
180
|
-
iterateCounter,
|
|
181
|
-
animationSpecs,
|
|
182
|
-
endSize,
|
|
183
|
-
) {
|
|
184
|
-
// keep track of animation by adding it to the DOM element
|
|
185
|
-
element.QLDanimation = setInterval(function () {
|
|
186
|
-
// when we are at the end
|
|
187
|
-
if (initialSize === endSize || animationSpecs.steps === 0) {
|
|
188
|
-
QLD.animate.Stop(element);
|
|
189
|
-
|
|
190
|
-
element.style[options.property] = endSize + "px"; // set to endSize
|
|
191
|
-
element.QLDtoggleState = "";
|
|
192
|
-
|
|
193
|
-
elements[0].QLDinteration++;
|
|
194
|
-
|
|
195
|
-
// removing auto so CSS can take over
|
|
196
|
-
if (options.endSize === "auto") {
|
|
197
|
-
element.style[options.property] = "";
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// when all iterations have finished, run the callback
|
|
201
|
-
if (elements[0].QLDinteration >= elements[0].QLDinterations) {
|
|
202
|
-
return options.callback();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
166
|
+
// scoping variable
|
|
167
|
+
(function (element, initialSize, iterateCounter, animationSpecs, endSize) {
|
|
168
|
+
// keep track of animation by adding it to the DOM element
|
|
169
|
+
element.QLDanimation = setInterval(function () {
|
|
170
|
+
// when we are at the end
|
|
171
|
+
if (initialSize === endSize || animationSpecs.steps === 0) {
|
|
172
|
+
Stop(element);
|
|
205
173
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
iterateCounter += animationSpecs.stepSize;
|
|
209
|
-
element.style[options.property] = iterateCounter + "px";
|
|
174
|
+
element.style[options.property] = endSize + "px"; // set to endSize
|
|
175
|
+
element.QLDtoggleState = "";
|
|
210
176
|
|
|
211
|
-
|
|
177
|
+
elements[0].QLDinteration++;
|
|
178
|
+
|
|
179
|
+
// removing auto so CSS can take over
|
|
180
|
+
if (options.endSize === "auto") {
|
|
181
|
+
element.style[options.property] = "";
|
|
212
182
|
}
|
|
213
|
-
}, Math.abs(animationSpecs.intervalTime));
|
|
214
|
-
})(element, initialSize, iterateCounter, animationSpecs, endSize);
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
183
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
* @param {object} options - The options for the animation
|
|
224
|
-
* @param {object} options.element - Element/s we are animating (DOM nodes)
|
|
225
|
-
* @param {string} options.property - The CSS property to animate [optional] [default: 'height']
|
|
226
|
-
* @param {integer|string} options.closeSize - The size the element should close to. Can be 'auto' or pixel value [optional] [default: 0]
|
|
227
|
-
* @param {integer|string} options.openSize - The size the element should open to. Can be 'auto' or pixel value [optional] [default: 'auto']
|
|
228
|
-
* @param {integer} options.speed - The speed of the animation in milliseconds [optional] [default: 250]
|
|
229
|
-
* @param {function} options.prefunction - A function to be executed before each animation starts, passes {object} element, {string} state [optional]
|
|
230
|
-
* @param {function} options.postfunction - A function to be executed after each animation ends, passes {object} element, {string} state [optional]
|
|
231
|
-
* @param {function} options.callback - A function to be executed after the animation ends, passes {object} element, {string} state [optional]
|
|
232
|
-
*
|
|
233
|
-
* @return {unknown} - The return value passed on from our options.callback function [optional]
|
|
234
|
-
*/
|
|
235
|
-
animate.Toggle = function (options) {
|
|
236
|
-
var elements = options.element;
|
|
237
|
-
var property = options.property || "height";
|
|
238
|
-
var speed = options.speed || 250;
|
|
239
|
-
var closeSize = options.closeSize === undefined ? 0 : options.closeSize;
|
|
240
|
-
var openSize = options.openSize === undefined ? "auto" : options.openSize;
|
|
241
|
-
|
|
242
|
-
// making a single DOM element iteratable
|
|
243
|
-
if (elements.length === undefined) {
|
|
244
|
-
elements = [elements];
|
|
245
|
-
}
|
|
184
|
+
// when all iterations have finished, run the callback
|
|
185
|
+
if (elements[0].QLDinteration >= elements[0].QLDinterations) {
|
|
186
|
+
return options.callback();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
246
189
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
190
|
+
// if we are still animating
|
|
191
|
+
else {
|
|
192
|
+
iterateCounter += animationSpecs.stepSize;
|
|
193
|
+
element.style[options.property] = iterateCounter + "px";
|
|
251
194
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
195
|
+
animationSpecs.steps--;
|
|
196
|
+
}
|
|
197
|
+
}, Math.abs(animationSpecs.intervalTime));
|
|
198
|
+
})(element, initialSize, iterateCounter, animationSpecs, endSize);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Toggle animation
|
|
204
|
+
*
|
|
205
|
+
* @memberof module:animate
|
|
206
|
+
*
|
|
207
|
+
* @param {object} options - The options for the animation
|
|
208
|
+
* @param {object} options.element - Element/s we are animating (DOM nodes)
|
|
209
|
+
* @param {string} options.property - The CSS property to animate [optional] [default: 'height']
|
|
210
|
+
* @param {integer|string} options.closeSize - The size the element should close to. Can be 'auto' or pixel value [optional] [default: 0]
|
|
211
|
+
* @param {integer|string} options.openSize - The size the element should open to. Can be 'auto' or pixel value [optional] [default: 'auto']
|
|
212
|
+
* @param {integer} options.speed - The speed of the animation in milliseconds [optional] [default: 250]
|
|
213
|
+
* @param {function} options.prefunction - A function to be executed before each animation starts, passes {object} element, {string} state [optional]
|
|
214
|
+
* @param {function} options.postfunction - A function to be executed after each animation ends, passes {object} element, {string} state [optional]
|
|
215
|
+
* @param {function} options.callback - A function to be executed after the animation ends, passes {object} element, {string} state [optional]
|
|
216
|
+
*
|
|
217
|
+
* @return {unknown} - The return value passed on from our options.callback function [optional]
|
|
218
|
+
*/
|
|
219
|
+
export function Toggle(options) {
|
|
220
|
+
var elements = options.element;
|
|
221
|
+
var property = options.property || "height";
|
|
222
|
+
var speed = options.speed || 250;
|
|
223
|
+
var closeSize = options.closeSize === undefined ? 0 : options.closeSize;
|
|
224
|
+
var openSize = options.openSize === undefined ? "auto" : options.openSize;
|
|
225
|
+
|
|
226
|
+
// making a single DOM element iteratable
|
|
227
|
+
if (elements.length === undefined) {
|
|
228
|
+
elements = [elements];
|
|
229
|
+
}
|
|
256
230
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
231
|
+
// making a prefunction if none was provided
|
|
232
|
+
if (typeof options.prefunction !== "function") {
|
|
233
|
+
options.prefunction = function () {};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// making a postfunction if none was provided
|
|
237
|
+
if (typeof options.postfunction !== "function") {
|
|
238
|
+
options.postfunction = function () {};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// making a callback if none was provided
|
|
242
|
+
if (typeof options.callback !== "function") {
|
|
243
|
+
options.callback = function () {};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// adding iteration counts
|
|
247
|
+
elements[0].QLDtoggleInteration = 0;
|
|
248
|
+
elements[0].QLDtoggleInterations = elements.length;
|
|
249
|
+
|
|
250
|
+
// iterate over all DOM nodes
|
|
251
|
+
for (var i = 0; i < elements.length; i++) {
|
|
252
|
+
var element = elements[i];
|
|
253
|
+
|
|
254
|
+
Stop(element);
|
|
255
|
+
|
|
256
|
+
var targetSize; // the size the element should open/close to after toggle is clicked
|
|
257
|
+
var preState; // the state we animate to for the prefunction and callback functions
|
|
258
|
+
var postState; // the state we animate to for the prefunction and callback functions
|
|
259
|
+
var currentSize = parseInt(
|
|
260
|
+
GetCSSPropertyBecauseIE(element, options.property),
|
|
261
|
+
); // the current size of the element
|
|
262
|
+
|
|
263
|
+
if (currentSize === closeSize || element.QLDtoggleState === "closing") {
|
|
264
|
+
targetSize = openSize;
|
|
265
|
+
preState = "opening";
|
|
266
|
+
postState = "open";
|
|
267
|
+
} else if (
|
|
268
|
+
currentSize !== closeSize ||
|
|
269
|
+
element.QLDtoggleState === "opening"
|
|
270
|
+
) {
|
|
271
|
+
targetSize = closeSize;
|
|
272
|
+
preState = "closing";
|
|
273
|
+
postState = "closed";
|
|
274
|
+
} else {
|
|
275
|
+
throw new Error("QLD.animate.Toggle cannot determine state of element");
|
|
260
276
|
}
|
|
261
277
|
|
|
262
|
-
//
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
); // the current size of the element
|
|
278
|
-
|
|
279
|
-
console.log(currentSize);
|
|
280
|
-
if (currentSize === closeSize || element.QLDtoggleState === "closing") {
|
|
281
|
-
targetSize = openSize;
|
|
282
|
-
preState = "opening";
|
|
283
|
-
postState = "open";
|
|
284
|
-
} else if (
|
|
285
|
-
currentSize !== closeSize ||
|
|
286
|
-
element.QLDtoggleState === "opening"
|
|
287
|
-
) {
|
|
288
|
-
targetSize = closeSize;
|
|
289
|
-
preState = "closing";
|
|
290
|
-
postState = "closed";
|
|
291
|
-
} else {
|
|
292
|
-
throw new Error("QLD.animate.Toggle cannot determine state of element");
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// run prefunction once per element
|
|
296
|
-
options.prefunction(element, preState);
|
|
297
|
-
|
|
298
|
-
// shoot off animation
|
|
299
|
-
QLD.animate.Run({
|
|
300
|
-
element: element,
|
|
301
|
-
endSize: targetSize,
|
|
302
|
-
property: property,
|
|
303
|
-
speed: speed,
|
|
304
|
-
callback: function () {
|
|
305
|
-
// making sure we fire the callback only once
|
|
306
|
-
elements[0].QLDtoggleInteration++;
|
|
307
|
-
|
|
308
|
-
if (elements[0].QLDtoggleInteration === elements[0].QLDinterations) {
|
|
309
|
-
var returnParam = options.callback(element, postState);
|
|
310
|
-
|
|
311
|
-
// run postfunction once per element
|
|
312
|
-
options.postfunction(element, postState);
|
|
313
|
-
|
|
314
|
-
return returnParam;
|
|
315
|
-
}
|
|
278
|
+
// run prefunction once per element
|
|
279
|
+
options.prefunction(element, preState);
|
|
280
|
+
|
|
281
|
+
// shoot off animation
|
|
282
|
+
Run({
|
|
283
|
+
element: element,
|
|
284
|
+
endSize: targetSize,
|
|
285
|
+
property: property,
|
|
286
|
+
speed: speed,
|
|
287
|
+
callback: function () {
|
|
288
|
+
// making sure we fire the callback only once
|
|
289
|
+
elements[0].QLDtoggleInteration++;
|
|
290
|
+
|
|
291
|
+
if (elements[0].QLDtoggleInteration === elements[0].QLDinterations) {
|
|
292
|
+
var returnParam = options.callback(element, postState);
|
|
316
293
|
|
|
317
294
|
// run postfunction once per element
|
|
318
295
|
options.postfunction(element, postState);
|
|
319
|
-
},
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
296
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
297
|
+
return returnParam;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// run postfunction once per element
|
|
301
|
+
options.postfunction(element, postState);
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* arrow keys, etc.) belong to the consuming component, not here.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import "./animate/global";
|
|
15
|
+
import * as animate from "./animate/global.js";
|
|
16
16
|
import { isExpanded, setExpanded } from "../../../helpers/global-helpers.js";
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -120,7 +120,7 @@ export function open(elements, speed, root = document, callbacks = {}) {
|
|
|
120
120
|
element.getAttribute("aria-controls"),
|
|
121
121
|
);
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
animate.Run({
|
|
124
124
|
element: target,
|
|
125
125
|
property: "height",
|
|
126
126
|
endSize: "auto",
|
|
@@ -157,7 +157,7 @@ export function close(elements, speed, root = document, callbacks = {}) {
|
|
|
157
157
|
element.getAttribute("aria-controls"),
|
|
158
158
|
);
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
animate.Run({
|
|
161
161
|
element: target,
|
|
162
162
|
property: "height",
|
|
163
163
|
endSize: 0,
|