uikit 3.11.2-dev.19d26d0f9 → 3.11.2-dev.21a5b7139

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.
Files changed (167) hide show
  1. package/.eslintrc.json +4 -49
  2. package/.prettierignore +14 -0
  3. package/.prettierrc.json +13 -0
  4. package/.webstorm.js +3 -3
  5. package/CHANGELOG.md +16 -1
  6. package/build/.eslintrc.json +1 -3
  7. package/build/build.js +26 -28
  8. package/build/icons.js +7 -11
  9. package/build/less.js +48 -36
  10. package/build/package.json +2 -2
  11. package/build/prefix.js +21 -18
  12. package/build/publishDev.js +6 -8
  13. package/build/release.js +20 -17
  14. package/build/scope.js +21 -11
  15. package/build/scss.js +72 -39
  16. package/build/util.js +71 -62
  17. package/build/wrapper/icons.js +0 -2
  18. package/dist/css/uikit-core-rtl.css +42 -17
  19. package/dist/css/uikit-core-rtl.min.css +1 -1
  20. package/dist/css/uikit-core.css +42 -17
  21. package/dist/css/uikit-core.min.css +1 -1
  22. package/dist/css/uikit-rtl.css +42 -17
  23. package/dist/css/uikit-rtl.min.css +1 -1
  24. package/dist/css/uikit.css +42 -17
  25. package/dist/css/uikit.min.css +1 -1
  26. package/dist/js/components/countdown.js +88 -133
  27. package/dist/js/components/countdown.min.js +1 -1
  28. package/dist/js/components/filter.js +410 -437
  29. package/dist/js/components/filter.min.js +1 -1
  30. package/dist/js/components/lightbox-panel.js +1116 -1305
  31. package/dist/js/components/lightbox-panel.min.js +1 -1
  32. package/dist/js/components/lightbox.js +1164 -1383
  33. package/dist/js/components/lightbox.min.js +1 -1
  34. package/dist/js/components/notification.js +94 -114
  35. package/dist/js/components/notification.min.js +1 -1
  36. package/dist/js/components/parallax.js +294 -345
  37. package/dist/js/components/parallax.min.js +1 -1
  38. package/dist/js/components/slider-parallax.js +292 -344
  39. package/dist/js/components/slider-parallax.min.js +1 -1
  40. package/dist/js/components/slider.js +724 -846
  41. package/dist/js/components/slider.min.js +1 -1
  42. package/dist/js/components/slideshow-parallax.js +292 -344
  43. package/dist/js/components/slideshow-parallax.min.js +1 -1
  44. package/dist/js/components/slideshow.js +615 -799
  45. package/dist/js/components/slideshow.min.js +1 -1
  46. package/dist/js/components/sortable.js +587 -616
  47. package/dist/js/components/sortable.min.js +1 -1
  48. package/dist/js/components/tooltip.js +324 -356
  49. package/dist/js/components/tooltip.min.js +1 -1
  50. package/dist/js/components/upload.js +153 -161
  51. package/dist/js/components/upload.min.js +1 -1
  52. package/dist/js/uikit-core.js +5293 -6602
  53. package/dist/js/uikit-core.min.js +1 -1
  54. package/dist/js/uikit-icons.js +7 -9
  55. package/dist/js/uikit-icons.min.js +1 -1
  56. package/dist/js/uikit.js +8114 -9862
  57. package/dist/js/uikit.min.js +1 -1
  58. package/jsconfig.json +1 -1
  59. package/package.json +64 -60
  60. package/src/js/api/boot.js +25 -32
  61. package/src/js/api/component.js +23 -27
  62. package/src/js/api/global.js +6 -12
  63. package/src/js/api/hooks.js +13 -32
  64. package/src/js/api/instance.js +7 -15
  65. package/src/js/api/state.js +80 -101
  66. package/src/js/components/countdown.js +23 -49
  67. package/src/js/components/filter.js +71 -66
  68. package/src/js/components/index.js +13 -13
  69. package/src/js/components/internal/lightbox-animations.js +11 -23
  70. package/src/js/components/internal/slider-transitioner.js +65 -44
  71. package/src/js/components/internal/slideshow-animations.js +42 -61
  72. package/src/js/components/lightbox-panel.js +135 -109
  73. package/src/js/components/lightbox.js +17 -38
  74. package/src/js/components/notification.js +49 -43
  75. package/src/js/components/parallax.js +16 -30
  76. package/src/js/components/slider-parallax.js +13 -23
  77. package/src/js/components/slider.js +73 -61
  78. package/src/js/components/slideshow-parallax.js +1 -1
  79. package/src/js/components/slideshow.js +8 -13
  80. package/src/js/components/sortable.js +121 -102
  81. package/src/js/components/tooltip.js +41 -31
  82. package/src/js/components/upload.js +46 -53
  83. package/src/js/core/accordion.js +54 -49
  84. package/src/js/core/alert.js +10 -17
  85. package/src/js/core/core.js +74 -53
  86. package/src/js/core/cover.js +11 -15
  87. package/src/js/core/drop.js +107 -93
  88. package/src/js/core/form-custom.js +20 -25
  89. package/src/js/core/gif.js +3 -7
  90. package/src/js/core/grid.js +57 -58
  91. package/src/js/core/height-match.js +15 -28
  92. package/src/js/core/height-viewport.js +28 -35
  93. package/src/js/core/icon.js +38 -50
  94. package/src/js/core/img.js +57 -58
  95. package/src/js/core/index.js +39 -39
  96. package/src/js/core/leader.js +9 -18
  97. package/src/js/core/margin.js +10 -24
  98. package/src/js/core/modal.js +50 -36
  99. package/src/js/core/nav.js +2 -4
  100. package/src/js/core/navbar.js +112 -84
  101. package/src/js/core/offcanvas.js +49 -53
  102. package/src/js/core/overflow-auto.js +13 -17
  103. package/src/js/core/responsive.js +14 -12
  104. package/src/js/core/scroll.js +10 -20
  105. package/src/js/core/scrollspy-nav.js +34 -31
  106. package/src/js/core/scrollspy.js +34 -51
  107. package/src/js/core/sticky.js +151 -93
  108. package/src/js/core/svg.js +60 -79
  109. package/src/js/core/switcher.js +47 -46
  110. package/src/js/core/tab.js +7 -10
  111. package/src/js/core/toggle.js +63 -65
  112. package/src/js/core/video.js +11 -22
  113. package/src/js/mixin/animate.js +19 -20
  114. package/src/js/mixin/class.js +2 -4
  115. package/src/js/mixin/container.js +7 -11
  116. package/src/js/mixin/internal/animate-fade.js +73 -30
  117. package/src/js/mixin/internal/animate-slide.js +61 -41
  118. package/src/js/mixin/internal/slideshow-animations.js +7 -14
  119. package/src/js/mixin/internal/slideshow-transitioner.js +10 -17
  120. package/src/js/mixin/media.js +5 -10
  121. package/src/js/mixin/modal.js +89 -66
  122. package/src/js/mixin/parallax.js +53 -48
  123. package/src/js/mixin/position.js +26 -20
  124. package/src/js/mixin/slider-autoplay.js +12 -21
  125. package/src/js/mixin/slider-drag.js +62 -63
  126. package/src/js/mixin/slider-nav.js +25 -34
  127. package/src/js/mixin/slider-reactive.js +2 -8
  128. package/src/js/mixin/slider.js +51 -50
  129. package/src/js/mixin/slideshow.js +13 -19
  130. package/src/js/mixin/togglable.js +90 -63
  131. package/src/js/uikit-core.js +2 -4
  132. package/src/js/uikit.js +2 -4
  133. package/src/js/util/ajax.js +27 -43
  134. package/src/js/util/animation.js +82 -75
  135. package/src/js/util/attr.js +6 -12
  136. package/src/js/util/class.js +14 -52
  137. package/src/js/util/dimensions.js +56 -43
  138. package/src/js/util/dom.js +36 -54
  139. package/src/js/util/env.js +7 -12
  140. package/src/js/util/event.js +60 -59
  141. package/src/js/util/fastdom.js +1 -6
  142. package/src/js/util/filter.js +17 -34
  143. package/src/js/util/index.js +0 -1
  144. package/src/js/util/lang.js +79 -119
  145. package/src/js/util/mouse.js +19 -17
  146. package/src/js/util/options.js +44 -49
  147. package/src/js/util/player.js +40 -36
  148. package/src/js/util/position.js +53 -45
  149. package/src/js/util/promise.js +0 -191
  150. package/src/js/util/selector.js +39 -48
  151. package/src/js/util/style.js +36 -46
  152. package/src/js/util/viewport.js +75 -64
  153. package/src/less/components/flex.less +0 -9
  154. package/src/less/components/navbar.less +0 -7
  155. package/src/less/components/utility.less +22 -0
  156. package/src/scss/components/flex.scss +0 -9
  157. package/src/scss/components/form.scss +3 -3
  158. package/src/scss/components/icon.scss +2 -2
  159. package/src/scss/components/navbar.scss +0 -7
  160. package/src/scss/components/search.scss +1 -1
  161. package/src/scss/components/utility.scss +22 -0
  162. package/src/scss/variables-theme.scss +6 -6
  163. package/src/scss/variables.scss +6 -6
  164. package/tests/js/index.js +114 -85
  165. package/tests/sticky-parallax.html +44 -41
  166. package/tests/sticky.html +20 -3
  167. package/src/js/mixin/flex-bug.js +0 -56
@@ -1,5 +1,4 @@
1
- const objPrototype = Object.prototype;
2
- const {hasOwnProperty} = objPrototype;
1
+ const { hasOwnProperty, toString } = Object.prototype;
3
2
 
4
3
  export function hasOwn(obj, key) {
5
4
  return hasOwnProperty.call(obj, key);
@@ -7,18 +6,13 @@ export function hasOwn(obj, key) {
7
6
 
8
7
  const hyphenateRe = /\B([A-Z])/g;
9
8
 
10
- export const hyphenate = memoize(str => str
11
- .replace(hyphenateRe, '-$1')
12
- .toLowerCase()
13
- );
9
+ export const hyphenate = memoize((str) => str.replace(hyphenateRe, '-$1').toLowerCase());
14
10
 
15
11
  const camelizeRe = /-(\w)/g;
16
12
 
17
- export const camelize = memoize(str =>
18
- str.replace(camelizeRe, toUpper)
19
- );
13
+ export const camelize = memoize((str) => str.replace(camelizeRe, toUpper));
20
14
 
21
- export const ucfirst = memoize(str =>
15
+ export const ucfirst = memoize((str) =>
22
16
  str.length ? toUpper(null, str.charAt(0)) + str.slice(1) : ''
23
17
  );
24
18
 
@@ -26,43 +20,24 @@ function toUpper(_, c) {
26
20
  return c ? c.toUpperCase() : '';
27
21
  }
28
22
 
29
- const strPrototype = String.prototype;
30
- const startsWithFn = strPrototype.startsWith || function (search) { return this.lastIndexOf(search, 0) === 0; };
31
-
32
23
  export function startsWith(str, search) {
33
- return startsWithFn.call(str, search);
24
+ return str.startsWith(search);
34
25
  }
35
26
 
36
- const endsWithFn = strPrototype.endsWith || function (search) { return this.substr(-search.length) === search; };
37
-
38
27
  export function endsWith(str, search) {
39
- return endsWithFn.call(str, search);
28
+ return str.endsWith(search);
40
29
  }
41
30
 
42
- const arrPrototype = Array.prototype;
43
-
44
- const includesFn = function (search, i) { return !!~this.indexOf(search, i); };
45
- const includesStr = strPrototype.includes || includesFn;
46
- const includesArray = arrPrototype.includes || includesFn;
47
-
48
31
  export function includes(obj, search) {
49
- return obj && (isString(obj) ? includesStr : includesArray).call(obj, search);
32
+ return obj && obj.includes(search);
50
33
  }
51
34
 
52
- const findIndexFn = arrPrototype.findIndex || function (predicate) {
53
- for (let i = 0; i < this.length; i++) {
54
- if (predicate.call(arguments[1], this[i], i, this)) {
55
- return i;
56
- }
57
- }
58
- return -1;
59
- };
60
-
61
35
  export function findIndex(array, predicate) {
62
- return findIndexFn.call(array, predicate);
36
+ return array.findIndex(predicate);
63
37
  }
64
38
 
65
- export const {isArray} = Array;
39
+ export const { isArray, from: toArray } = Array;
40
+ export const { assign } = Object;
66
41
 
67
42
  export function isFunction(obj) {
68
43
  return typeof obj === 'function';
@@ -72,7 +47,6 @@ export function isObject(obj) {
72
47
  return obj !== null && typeof obj === 'object';
73
48
  }
74
49
 
75
- const {toString} = objPrototype;
76
50
  export function isPlainObject(obj) {
77
51
  return toString.call(obj) === '[object Object]';
78
52
  }
@@ -110,16 +84,11 @@ export function isNumber(value) {
110
84
  }
111
85
 
112
86
  export function isNumeric(value) {
113
- return isNumber(value) || isString(value) && !isNaN(value - parseFloat(value));
87
+ return isNumber(value) || (isString(value) && !isNaN(value - parseFloat(value)));
114
88
  }
115
89
 
116
90
  export function isEmpty(obj) {
117
- return !(isArray(obj)
118
- ? obj.length
119
- : isObject(obj)
120
- ? Object.keys(obj).length
121
- : false
122
- );
91
+ return !(isArray(obj) ? obj.length : isObject(obj) ? Object.keys(obj).length : false);
123
92
  }
124
93
 
125
94
  export function isUndefined(value) {
@@ -130,10 +99,10 @@ export function toBoolean(value) {
130
99
  return isBoolean(value)
131
100
  ? value
132
101
  : value === 'true' || value === '1' || value === ''
133
- ? true
134
- : value === 'false' || value === '0'
135
- ? false
136
- : value;
102
+ ? true
103
+ : value === 'false' || value === '0'
104
+ ? false
105
+ : value;
137
106
  }
138
107
 
139
108
  export function toNumber(value) {
@@ -145,14 +114,12 @@ export function toFloat(value) {
145
114
  return parseFloat(value) || 0;
146
115
  }
147
116
 
148
- export const toArray = Array.from || (value => arrPrototype.slice.call(value));
149
-
150
117
  export function toNode(element) {
151
118
  return toNodes(element)[0];
152
119
  }
153
120
 
154
121
  export function toNodes(element) {
155
- return element && (isNode(element) ? [element] : toArray(element).filter(isNode)) || [];
122
+ return (element && (isNode(element) ? [element] : Array.from(element).filter(isNode))) || [];
156
123
  }
157
124
 
158
125
  export function toWindow(element) {
@@ -162,52 +129,27 @@ export function toWindow(element) {
162
129
 
163
130
  element = toNode(element);
164
131
 
165
- return element
166
- ? (isDocument(element)
167
- ? element
168
- : element.ownerDocument
169
- ).defaultView
170
- : window;
132
+ return element ? (isDocument(element) ? element : element.ownerDocument).defaultView : window;
171
133
  }
172
134
 
173
135
  export function toMs(time) {
174
- return !time
175
- ? 0
176
- : endsWith(time, 'ms')
177
- ? toFloat(time)
178
- : toFloat(time) * 1000;
136
+ return time ? (endsWith(time, 'ms') ? toFloat(time) : toFloat(time) * 1000) : 0;
179
137
  }
180
138
 
181
139
  export function isEqual(value, other) {
182
- return value === other
183
- || isObject(value)
184
- && isObject(other)
185
- && Object.keys(value).length === Object.keys(other).length
186
- && each(value, (val, key) => val === other[key]);
140
+ return (
141
+ value === other ||
142
+ (isObject(value) &&
143
+ isObject(other) &&
144
+ Object.keys(value).length === Object.keys(other).length &&
145
+ each(value, (val, key) => val === other[key]))
146
+ );
187
147
  }
188
148
 
189
149
  export function swap(value, a, b) {
190
- return value.replace(
191
- new RegExp(`${a}|${b}`, 'g'),
192
- match => match === a ? b : a
193
- );
150
+ return value.replace(new RegExp(`${a}|${b}`, 'g'), (match) => (match === a ? b : a));
194
151
  }
195
152
 
196
- export const assign = Object.assign || function (target, ...args) {
197
- target = Object(target);
198
- for (let i = 0; i < args.length; i++) {
199
- const source = args[i];
200
- if (source !== null) {
201
- for (const key in source) {
202
- if (hasOwn(source, key)) {
203
- target[key] = source[key];
204
- }
205
- }
206
- }
207
- }
208
- return target;
209
- };
210
-
211
153
  export function last(array) {
212
154
  return array[array.length - 1];
213
155
  }
@@ -222,21 +164,16 @@ export function each(obj, cb) {
222
164
  }
223
165
 
224
166
  export function sortBy(array, prop) {
225
- return array.slice().sort(({[prop]: propA = 0}, {[prop]: propB = 0}) =>
226
- propA > propB
227
- ? 1
228
- : propB > propA
229
- ? -1
230
- : 0
231
- );
167
+ return array
168
+ .slice()
169
+ .sort(({ [prop]: propA = 0 }, { [prop]: propB = 0 }) =>
170
+ propA > propB ? 1 : propB > propA ? -1 : 0
171
+ );
232
172
  }
233
173
 
234
174
  export function uniqueBy(array, prop) {
235
175
  const seen = new Set();
236
- return array.filter(({[prop]: check}) => seen.has(check)
237
- ? false
238
- : seen.add(check) || true // IE 11 does not return the Set object
239
- );
176
+ return array.filter(({ [prop]: check }) => (seen.has(check) ? false : seen.add(check)));
240
177
  }
241
178
 
242
179
  export function clamp(number, min = 0, max = 1) {
@@ -246,36 +183,48 @@ export function clamp(number, min = 0, max = 1) {
246
183
  export function noop() {}
247
184
 
248
185
  export function intersectRect(...rects) {
249
- return [['bottom', 'top'], ['right', 'left']].every(([minProp, maxProp]) =>
250
- Math.min(...rects.map(({[minProp]: min}) => min)) - Math.max(...rects.map(({[maxProp]: max}) => max)) > 0
186
+ return [
187
+ ['bottom', 'top'],
188
+ ['right', 'left'],
189
+ ].every(
190
+ ([minProp, maxProp]) =>
191
+ Math.min(...rects.map(({ [minProp]: min }) => min)) -
192
+ Math.max(...rects.map(({ [maxProp]: max }) => max)) >
193
+ 0
251
194
  );
252
195
  }
253
196
 
254
197
  export function pointInRect(point, rect) {
255
- return point.x <= rect.right &&
198
+ return (
199
+ point.x <= rect.right &&
256
200
  point.x >= rect.left &&
257
201
  point.y <= rect.bottom &&
258
- point.y >= rect.top;
202
+ point.y >= rect.top
203
+ );
259
204
  }
260
205
 
261
206
  export const Dimensions = {
262
-
263
207
  ratio(dimensions, prop, value) {
264
-
265
208
  const aProp = prop === 'width' ? 'height' : 'width';
266
209
 
267
210
  return {
268
- [aProp]: dimensions[prop] ? Math.round(value * dimensions[aProp] / dimensions[prop]) : dimensions[aProp],
269
- [prop]: value
211
+ [aProp]: dimensions[prop]
212
+ ? Math.round((value * dimensions[aProp]) / dimensions[prop])
213
+ : dimensions[aProp],
214
+ [prop]: value,
270
215
  };
271
216
  },
272
217
 
273
218
  contain(dimensions, maxDimensions) {
274
219
  dimensions = assign({}, dimensions);
275
220
 
276
- each(dimensions, (_, prop) => dimensions = dimensions[prop] > maxDimensions[prop]
277
- ? this.ratio(dimensions, prop, maxDimensions[prop])
278
- : dimensions
221
+ each(
222
+ dimensions,
223
+ (_, prop) =>
224
+ (dimensions =
225
+ dimensions[prop] > maxDimensions[prop]
226
+ ? this.ratio(dimensions, prop, maxDimensions[prop])
227
+ : dimensions)
279
228
  );
280
229
 
281
230
  return dimensions;
@@ -284,21 +233,23 @@ export const Dimensions = {
284
233
  cover(dimensions, maxDimensions) {
285
234
  dimensions = this.contain(dimensions, maxDimensions);
286
235
 
287
- each(dimensions, (_, prop) => dimensions = dimensions[prop] < maxDimensions[prop]
288
- ? this.ratio(dimensions, prop, maxDimensions[prop])
289
- : dimensions
236
+ each(
237
+ dimensions,
238
+ (_, prop) =>
239
+ (dimensions =
240
+ dimensions[prop] < maxDimensions[prop]
241
+ ? this.ratio(dimensions, prop, maxDimensions[prop])
242
+ : dimensions)
290
243
  );
291
244
 
292
245
  return dimensions;
293
- }
294
-
246
+ },
295
247
  };
296
248
 
297
249
  export function getIndex(i, elements, current = 0, finite = false) {
298
-
299
250
  elements = toNodes(elements);
300
251
 
301
- const {length} = elements;
252
+ const { length } = elements;
302
253
 
303
254
  if (!length) {
304
255
  return -1;
@@ -307,10 +258,10 @@ export function getIndex(i, elements, current = 0, finite = false) {
307
258
  i = isNumeric(i)
308
259
  ? toNumber(i)
309
260
  : i === 'next'
310
- ? current + 1
311
- : i === 'previous'
312
- ? current - 1
313
- : elements.indexOf(toNode(i));
261
+ ? current + 1
262
+ : i === 'previous'
263
+ ? current - 1
264
+ : elements.indexOf(toNode(i));
314
265
 
315
266
  if (finite) {
316
267
  return clamp(i, 0, length - 1);
@@ -323,5 +274,14 @@ export function getIndex(i, elements, current = 0, finite = false) {
323
274
 
324
275
  export function memoize(fn) {
325
276
  const cache = Object.create(null);
326
- return key => cache[key] || (cache[key] = fn(key));
277
+ return (key) => cache[key] || (cache[key] = fn(key));
278
+ }
279
+
280
+ export class Deferred {
281
+ constructor() {
282
+ this.promise = new Promise((resolve, reject) => {
283
+ this.reject = reject;
284
+ this.resolve = resolve;
285
+ });
286
+ }
327
287
  }
@@ -1,20 +1,17 @@
1
- import {getEventPos, on} from './event';
2
- import {last, pointInRect} from './lang';
1
+ import { getEventPos, on } from './event';
2
+ import { last, pointInRect } from './lang';
3
3
 
4
4
  export function MouseTracker() {}
5
5
 
6
6
  MouseTracker.prototype = {
7
-
8
7
  positions: [],
9
8
 
10
9
  init() {
11
-
12
10
  this.positions = [];
13
11
 
14
12
  let position;
15
- this.unbind = on(document, 'mousemove', e => position = getEventPos(e));
13
+ this.unbind = on(document, 'mousemove', (e) => (position = getEventPos(e)));
16
14
  this.interval = setInterval(() => {
17
-
18
15
  if (!position) {
19
16
  return;
20
17
  }
@@ -25,7 +22,6 @@ MouseTracker.prototype = {
25
22
  this.positions.shift();
26
23
  }
27
24
  }, 50);
28
-
29
25
  },
30
26
 
31
27
  cancel() {
@@ -34,13 +30,12 @@ MouseTracker.prototype = {
34
30
  },
35
31
 
36
32
  movesTo(target) {
37
-
38
33
  if (this.positions.length < 2) {
39
34
  return false;
40
35
  }
41
36
 
42
37
  const p = target.getBoundingClientRect();
43
- const {left, right, top, bottom} = p;
38
+ const { left, right, top, bottom } = p;
44
39
 
45
40
  const [prevPosition] = this.positions;
46
41
  const position = last(this.positions);
@@ -50,19 +45,26 @@ MouseTracker.prototype = {
50
45
  return false;
51
46
  }
52
47
 
53
- const diagonals = [[{x: left, y: top}, {x: right, y: bottom}], [{x: left, y: bottom}, {x: right, y: top}]];
54
-
55
- return diagonals.some(diagonal => {
48
+ const diagonals = [
49
+ [
50
+ { x: left, y: top },
51
+ { x: right, y: bottom },
52
+ ],
53
+ [
54
+ { x: left, y: bottom },
55
+ { x: right, y: top },
56
+ ],
57
+ ];
58
+
59
+ return diagonals.some((diagonal) => {
56
60
  const intersection = intersect(path, diagonal);
57
61
  return intersection && pointInRect(intersection, p);
58
62
  });
59
- }
60
-
63
+ },
61
64
  };
62
65
 
63
66
  // Inspired by http://paulbourke.net/geometry/pointlineplane/
64
- function intersect([{x: x1, y: y1}, {x: x2, y: y2}], [{x: x3, y: y3}, {x: x4, y: y4}]) {
65
-
67
+ function intersect([{ x: x1, y: y1 }, { x: x2, y: y2 }], [{ x: x3, y: y3 }, { x: x4, y: y4 }]) {
66
68
  const denominator = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
67
69
 
68
70
  // Lines are parallel
@@ -77,5 +79,5 @@ function intersect([{x: x1, y: y1}, {x: x2, y: y2}], [{x: x3, y: y3}, {x: x4, y:
77
79
  }
78
80
 
79
81
  // Return an object with the x and y coordinates of the intersection
80
- return {x: x1 + ua * (x2 - x1), y: y1 + ua * (y2 - y1)};
82
+ return { x: x1 + ua * (x2 - x1), y: y1 + ua * (y2 - y1) };
81
83
  }
@@ -1,14 +1,24 @@
1
- import {assign, hasOwn, includes, isArray, isFunction, isUndefined, sortBy, startsWith} from './lang';
1
+ import {
2
+ assign,
3
+ hasOwn,
4
+ includes,
5
+ isArray,
6
+ isFunction,
7
+ isUndefined,
8
+ sortBy,
9
+ startsWith,
10
+ } from './lang';
2
11
 
3
12
  const strats = {};
4
13
 
5
14
  strats.events =
6
- strats.created =
7
- strats.beforeConnect =
8
- strats.connected =
9
- strats.beforeDisconnect =
10
- strats.disconnected =
11
- strats.destroy = concatStrat;
15
+ strats.created =
16
+ strats.beforeConnect =
17
+ strats.connected =
18
+ strats.beforeDisconnect =
19
+ strats.disconnected =
20
+ strats.destroy =
21
+ concatStrat;
12
22
 
13
23
  // args strategy
14
24
  strats.args = function (parentVal, childVal) {
@@ -17,37 +27,33 @@ strats.args = function (parentVal, childVal) {
17
27
 
18
28
  // update strategy
19
29
  strats.update = function (parentVal, childVal) {
20
- return sortBy(concatStrat(parentVal, isFunction(childVal) ? {read: childVal} : childVal), 'order');
30
+ return sortBy(
31
+ concatStrat(parentVal, isFunction(childVal) ? { read: childVal } : childVal),
32
+ 'order'
33
+ );
21
34
  };
22
35
 
23
36
  // property strategy
24
37
  strats.props = function (parentVal, childVal) {
25
-
26
38
  if (isArray(childVal)) {
27
- childVal = childVal.reduce((value, key) => {
39
+ const value = {};
40
+ for (const key of childVal) {
28
41
  value[key] = String;
29
- return value;
30
- }, {});
42
+ }
43
+ childVal = value;
31
44
  }
32
45
 
33
46
  return strats.methods(parentVal, childVal);
34
47
  };
35
48
 
36
49
  // extend strategy
37
- strats.computed =
38
- strats.methods = function (parentVal, childVal) {
39
- return childVal
40
- ? parentVal
41
- ? assign({}, parentVal, childVal)
42
- : childVal
43
- : parentVal;
50
+ strats.computed = strats.methods = function (parentVal, childVal) {
51
+ return childVal ? (parentVal ? assign({}, parentVal, childVal) : childVal) : parentVal;
44
52
  };
45
53
 
46
54
  // data strategy
47
55
  strats.data = function (parentVal, childVal, vm) {
48
-
49
56
  if (!vm) {
50
-
51
57
  if (!childVal) {
52
58
  return parentVal;
53
59
  }
@@ -59,7 +65,6 @@ strats.data = function (parentVal, childVal, vm) {
59
65
  return function (vm) {
60
66
  return mergeFnData(parentVal, childVal, vm);
61
67
  };
62
-
63
68
  }
64
69
 
65
70
  return mergeFnData(parentVal, childVal, vm);
@@ -67,26 +72,21 @@ strats.data = function (parentVal, childVal, vm) {
67
72
 
68
73
  function mergeFnData(parentVal, childVal, vm) {
69
74
  return strats.computed(
70
- isFunction(parentVal)
71
- ? parentVal.call(vm, vm)
72
- : parentVal,
73
- isFunction(childVal)
74
- ? childVal.call(vm, vm)
75
- : childVal
75
+ isFunction(parentVal) ? parentVal.call(vm, vm) : parentVal,
76
+ isFunction(childVal) ? childVal.call(vm, vm) : childVal
76
77
  );
77
78
  }
78
79
 
79
80
  // concat strategy
80
81
  function concatStrat(parentVal, childVal) {
81
-
82
82
  parentVal = parentVal && !isArray(parentVal) ? [parentVal] : parentVal;
83
83
 
84
84
  return childVal
85
85
  ? parentVal
86
86
  ? parentVal.concat(childVal)
87
87
  : isArray(childVal)
88
- ? childVal
89
- : [childVal]
88
+ ? childVal
89
+ : [childVal]
90
90
  : parentVal;
91
91
  }
92
92
 
@@ -96,7 +96,6 @@ function defaultStrat(parentVal, childVal) {
96
96
  }
97
97
 
98
98
  export function mergeOptions(parent, child, vm) {
99
-
100
99
  const options = {};
101
100
 
102
101
  if (isFunction(child)) {
@@ -108,8 +107,8 @@ export function mergeOptions(parent, child, vm) {
108
107
  }
109
108
 
110
109
  if (child.mixins) {
111
- for (let i = 0, l = child.mixins.length; i < l; i++) {
112
- parent = mergeOptions(parent, child.mixins[i], vm);
110
+ for (const mixin of child.mixins) {
111
+ parent = mergeOptions(parent, mixin, vm);
113
112
  }
114
113
  }
115
114
 
@@ -131,25 +130,21 @@ export function mergeOptions(parent, child, vm) {
131
130
  }
132
131
 
133
132
  export function parseOptions(options, args = []) {
134
-
135
133
  try {
136
-
137
- return !options
138
- ? {}
139
- : startsWith(options, '{')
134
+ return options
135
+ ? startsWith(options, '{')
140
136
  ? JSON.parse(options)
141
137
  : args.length && !includes(options, ':')
142
- ? ({[args[0]]: options})
143
- : options.split(';').reduce((options, option) => {
144
- const [key, value] = option.split(/:(.*)/);
145
- if (key && !isUndefined(value)) {
146
- options[key.trim()] = value.trim();
147
- }
148
- return options;
149
- }, {});
150
-
138
+ ? { [args[0]]: options }
139
+ : options.split(';').reduce((options, option) => {
140
+ const [key, value] = option.split(/:(.*)/);
141
+ if (key && !isUndefined(value)) {
142
+ options[key.trim()] = value.trim();
143
+ }
144
+ return options;
145
+ }, {})
146
+ : {};
151
147
  } catch (e) {
152
148
  return {};
153
149
  }
154
-
155
150
  }