uikit 3.14.4-dev.07daf8fb8 → 3.14.4-dev.154737924

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 (49) hide show
  1. package/dist/css/uikit-core-rtl.css +1 -1
  2. package/dist/css/uikit-core-rtl.min.css +1 -1
  3. package/dist/css/uikit-core.css +1 -1
  4. package/dist/css/uikit-core.min.css +1 -1
  5. package/dist/css/uikit-rtl.css +1 -1
  6. package/dist/css/uikit-rtl.min.css +1 -1
  7. package/dist/css/uikit.css +1 -1
  8. package/dist/css/uikit.min.css +1 -1
  9. package/dist/js/components/countdown.js +1 -1
  10. package/dist/js/components/countdown.min.js +1 -1
  11. package/dist/js/components/filter.js +1 -1
  12. package/dist/js/components/filter.min.js +1 -1
  13. package/dist/js/components/lightbox-panel.js +19 -4
  14. package/dist/js/components/lightbox-panel.min.js +1 -1
  15. package/dist/js/components/lightbox.js +19 -4
  16. package/dist/js/components/lightbox.min.js +1 -1
  17. package/dist/js/components/notification.js +1 -1
  18. package/dist/js/components/notification.min.js +1 -1
  19. package/dist/js/components/parallax.js +1 -1
  20. package/dist/js/components/parallax.min.js +1 -1
  21. package/dist/js/components/slider-parallax.js +1 -1
  22. package/dist/js/components/slider-parallax.min.js +1 -1
  23. package/dist/js/components/slider.js +1 -1
  24. package/dist/js/components/slider.min.js +1 -1
  25. package/dist/js/components/slideshow-parallax.js +1 -1
  26. package/dist/js/components/slideshow-parallax.min.js +1 -1
  27. package/dist/js/components/slideshow.js +1 -1
  28. package/dist/js/components/slideshow.min.js +1 -1
  29. package/dist/js/components/sortable.js +1 -1
  30. package/dist/js/components/sortable.min.js +1 -1
  31. package/dist/js/components/tooltip.js +22 -6
  32. package/dist/js/components/tooltip.min.js +1 -1
  33. package/dist/js/components/upload.js +1 -1
  34. package/dist/js/components/upload.min.js +1 -1
  35. package/dist/js/uikit-core.js +112 -91
  36. package/dist/js/uikit-core.min.js +2 -2
  37. package/dist/js/uikit-icons.js +1 -1
  38. package/dist/js/uikit-icons.min.js +1 -1
  39. package/dist/js/uikit.js +112 -91
  40. package/dist/js/uikit.min.js +2 -2
  41. package/package.json +1 -1
  42. package/src/js/core/navbar.js +2 -0
  43. package/src/js/core/toggle.js +3 -5
  44. package/src/js/mixin/modal.js +2 -2
  45. package/src/js/mixin/position.js +5 -4
  46. package/src/js/mixin/togglable.js +16 -1
  47. package/src/js/util/position.js +81 -76
  48. package/tests/navbar.html +13 -1
  49. package/tests/position.html +17 -4
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "uikit",
3
3
  "title": "UIkit",
4
4
  "description": "UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.",
5
- "version": "3.14.4-dev.07daf8fb8",
5
+ "version": "3.14.4-dev.154737924",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -38,6 +38,8 @@ export default {
38
38
  offset: Number,
39
39
  boundary: Boolean,
40
40
  target: Boolean,
41
+ targetX: Boolean,
42
+ targetY: Boolean,
41
43
  clsDrop: String,
42
44
  delayShow: Number,
43
45
  delayHide: Number,
@@ -181,7 +181,7 @@ export default {
181
181
  },
182
182
 
183
183
  {
184
- name: 'toggled',
184
+ name: 'hide show',
185
185
 
186
186
  self: true,
187
187
 
@@ -189,10 +189,8 @@ export default {
189
189
  return this.target;
190
190
  },
191
191
 
192
- handler(e, toggled) {
193
- if (e.target === this.target[0]) {
194
- this.updateAria(toggled);
195
- }
192
+ handler({ type }) {
193
+ this.updateAria(type === 'show');
196
194
  },
197
195
  },
198
196
 
@@ -135,8 +135,8 @@ export default {
135
135
  );
136
136
 
137
137
  if (this.overlay) {
138
- once(this.$el, 'hidden', preventOverscroll(this.$el));
139
- once(this.$el, 'hidden', preventBackgroundScroll());
138
+ once(this.$el, 'hidden', preventOverscroll(this.$el), { self: true });
139
+ once(this.$el, 'hidden', preventBackgroundScroll(), { self: true });
140
140
  }
141
141
 
142
142
  if (this.stack) {
@@ -35,6 +35,7 @@ export default {
35
35
  methods: {
36
36
  positionAt(element, target, boundary) {
37
37
  let offset = [this.getPositionOffset(element), this.getShiftOffset(element)];
38
+ const placement = [this.flip && 'flip', this.shift && 'shift'];
38
39
 
39
40
  const attach = {
40
41
  element: [this.inset ? this.dir : flipPosition(this.dir), this.align],
@@ -43,9 +44,10 @@ export default {
43
44
 
44
45
  if (this.axis === 'y') {
45
46
  for (const prop in attach) {
46
- attach[prop] = attach[prop].reverse();
47
+ attach[prop].reverse();
47
48
  }
48
- offset = offset.reverse();
49
+ offset.reverse();
50
+ placement.reverse();
49
51
  }
50
52
 
51
53
  const [scrollElement] = scrollParents(element, /auto|scroll/);
@@ -59,8 +61,7 @@ export default {
59
61
  attach,
60
62
  offset,
61
63
  boundary,
62
- flip: this.flip,
63
- shift: this.shift,
64
+ placement,
64
65
  viewportOffset: this.getViewportOffset(element),
65
66
  });
66
67
 
@@ -177,6 +177,7 @@ export function toggleTransition(cmp) {
177
177
  const currentMargin = toFloat(css(el, marginProp));
178
178
  const marginStart = toFloat(css(el, marginStartProp));
179
179
  const endDim = dim[dimProp] + marginStart;
180
+ const overflow = getOverflow(el);
180
181
 
181
182
  if (!inProgress && !show) {
182
183
  currentDim += marginStart;
@@ -199,12 +200,12 @@ export function toggleTransition(cmp) {
199
200
  });
200
201
 
201
202
  css(el, {
203
+ overflow,
202
204
  padding: 0,
203
205
  border: 0,
204
206
  [marginStartProp]: 0,
205
207
  width: dim.width,
206
208
  height: dim.height,
207
- overflow: 'hidden',
208
209
  [dimProp]: currentDim,
209
210
  });
210
211
 
@@ -251,3 +252,17 @@ function toggleAnimation(cmp) {
251
252
  );
252
253
  };
253
254
  }
255
+
256
+ function getOverflow(el) {
257
+ return [
258
+ ['X', 'Width'],
259
+ ['Y', 'Height'],
260
+ ]
261
+ .map(([axis, prop]) =>
262
+ includes(['auto', 'scroll'], css(el, `overflow${axis}`)) &&
263
+ el[`scroll${prop}`] > el[`client${prop}`]
264
+ ? 'scroll'
265
+ : 'hidden'
266
+ )
267
+ .join(' ');
268
+ }
@@ -15,6 +15,7 @@ export function positionAt(element, target, options) {
15
15
  ...options.attach,
16
16
  },
17
17
  offset: [0, 0],
18
+ placement: [],
18
19
  ...options,
19
20
  };
20
21
 
@@ -25,55 +26,19 @@ export function positionAt(element, target, options) {
25
26
  offset(element, getPosition(element, target, options));
26
27
  }
27
28
 
28
- function attachTo(element, target, options) {
29
- let { attach, offset: offsetBy } = {
30
- attach: {
31
- element: ['left', 'top'],
32
- target: ['left', 'top'],
33
- ...options.attach,
34
- },
35
- offset: [0, 0],
36
- ...options,
37
- };
38
-
39
- const position = offset(element);
40
-
41
- for (const [i, [prop, dir, start, end]] of Object.entries(dirs)) {
42
- const targetOffset =
43
- attach.target[i] === attach.element[i] ? offsetViewport(target[i]) : offset(target[i]);
44
-
45
- position[start] = position[dir] =
46
- targetOffset[start] +
47
- moveBy(attach.target[i], end, targetOffset[prop]) -
48
- moveBy(attach.element[i], end, position[prop]) +
49
- +offsetBy[i];
50
- position[end] = position[start] + position[prop];
51
- }
52
- return position;
53
- }
54
-
55
- function moveBy(start, end, dim) {
56
- return start === 'center' ? dim / 2 : start === end ? dim : 0;
57
- }
58
-
59
29
  function getPosition(element, target, options) {
60
30
  const position = attachTo(element, target, options);
61
31
 
62
32
  let {
63
- flip,
64
- shift,
65
33
  attach: { element: elAttach, target: targetAttach },
66
34
  offset: elOffset,
67
35
  boundary,
68
36
  viewportOffset,
37
+ placement,
69
38
  } = options;
70
39
 
71
- if (!flip && !shift) {
72
- return position;
73
- }
74
-
75
- const offsetPosition = { ...position };
76
- for (const [i, [prop, dir, start, end]] of Object.entries(dirs)) {
40
+ let offsetPosition = position;
41
+ for (const [i, [prop, , start, end]] of Object.entries(dirs)) {
77
42
  let viewports = scrollParents(target[i]);
78
43
  const [scrollElement] = viewports;
79
44
 
@@ -96,42 +61,19 @@ function getPosition(element, target, options) {
96
61
  }
97
62
 
98
63
  let offsetBy = 0;
99
- const targetDim = offset(target[i]);
100
64
 
101
65
  // Flip
102
- if (!intersectLine(position, targetDim, i) && intersectLine(position, targetDim, 1 - i)) {
66
+ if (placement[i] === 'flip') {
103
67
  if (
104
- !flip ||
105
- (elAttach[i] === end && isInStartViewport) ||
106
- (elAttach[i] === start && isInEndViewport)
68
+ (targetAttach[i] === end && isInEndViewport) ||
69
+ (targetAttach[i] === start && isInStartViewport)
107
70
  ) {
108
71
  continue;
109
72
  }
110
73
 
111
- offsetBy =
112
- (elAttach[i] === start
113
- ? -position[prop]
114
- : elAttach[i] === end
115
- ? position[prop]
116
- : 0) +
117
- (targetAttach[i] === start
118
- ? targetDim[prop]
119
- : targetAttach[i] === end
120
- ? -targetDim[prop]
121
- : 0) -
122
- elOffset[i] * 2;
74
+ offsetBy = flip(element, target, options, i)[start] - position[start];
123
75
 
124
- if (
125
- !isInScrollArea(
126
- {
127
- ...position,
128
- [start]: position[start] + offsetBy,
129
- [end]: position[end] + offsetBy,
130
- },
131
- scrollElement,
132
- i
133
- )
134
- ) {
76
+ if (!isInScrollArea(applyOffset(position, offsetBy, i), scrollElement, i)) {
135
77
  if (isInScrollArea(position, scrollElement, i)) {
136
78
  continue;
137
79
  }
@@ -143,10 +85,11 @@ function getPosition(element, target, options) {
143
85
  const newPos = getPosition(element, target, {
144
86
  ...options,
145
87
  attach: {
146
- element: elAttach.map(flipDir).reverse(),
147
- target: targetAttach.map(flipDir).reverse(),
88
+ element: elAttach.map(flipAxis).reverse(),
89
+ target: targetAttach.map(flipAxis).reverse(),
148
90
  },
149
91
  offset: elOffset.reverse(),
92
+ placement: placement.reverse(),
150
93
  recursion: true,
151
94
  });
152
95
 
@@ -158,7 +101,8 @@ function getPosition(element, target, options) {
158
101
  }
159
102
 
160
103
  // Shift
161
- } else if (shift) {
104
+ } else if (placement[i] === 'shift') {
105
+ const targetDim = offset(target[i]);
162
106
  offsetBy =
163
107
  clamp(
164
108
  clamp(position[start], viewport[start], viewport[end] - position[prop]),
@@ -167,13 +111,54 @@ function getPosition(element, target, options) {
167
111
  ) - position[start];
168
112
  }
169
113
 
170
- offsetPosition[start] = position[dir] = position[start] + offsetBy;
171
- offsetPosition[end] += offsetBy;
114
+ offsetPosition = applyOffset(offsetPosition, offsetBy, i);
172
115
  }
173
116
 
174
117
  return offsetPosition;
175
118
  }
176
119
 
120
+ function attachTo(element, target, options) {
121
+ let { attach, offset: offsetBy } = {
122
+ attach: {
123
+ element: ['left', 'top'],
124
+ target: ['left', 'top'],
125
+ ...options.attach,
126
+ },
127
+ offset: [0, 0],
128
+ ...options,
129
+ };
130
+
131
+ let elOffset = offset(element);
132
+
133
+ for (const [i, [prop, , start, end]] of Object.entries(dirs)) {
134
+ const targetOffset =
135
+ attach.target[i] === attach.element[i] ? offsetViewport(target[i]) : offset(target[i]);
136
+
137
+ elOffset = applyOffset(
138
+ elOffset,
139
+ targetOffset[start] -
140
+ elOffset[start] +
141
+ moveBy(attach.target[i], end, targetOffset[prop]) -
142
+ moveBy(attach.element[i], end, elOffset[prop]) +
143
+ +offsetBy[i],
144
+ i
145
+ );
146
+ }
147
+ return elOffset;
148
+ }
149
+
150
+ function applyOffset(position, offset, i) {
151
+ const [, dir, start, end] = dirs[i];
152
+ const newPos = { ...position };
153
+ newPos[start] = position[dir] = position[start] + offset;
154
+ newPos[end] += offset;
155
+ return newPos;
156
+ }
157
+
158
+ function moveBy(attach, end, dim) {
159
+ return attach === 'center' ? dim / 2 : attach === end ? dim : 0;
160
+ }
161
+
177
162
  function getIntersectionArea(...rects) {
178
163
  let area = {};
179
164
  for (const rect of rects) {
@@ -194,12 +179,32 @@ function isInScrollArea(position, scrollElement, dir) {
194
179
  return position[start] >= viewport[start] && position[end] <= viewport[end];
195
180
  }
196
181
 
197
- function intersectLine(dimA, dimB, dir) {
198
- const [, , start, end] = dirs[dir];
199
- return dimA[end] > dimB[start] && dimB[end] > dimA[start];
182
+ function flip(element, target, { offset, attach }, i) {
183
+ return attachTo(element, target, {
184
+ attach: {
185
+ element: flipAttach(attach.element, i),
186
+ target: flipAttach(attach.target, i),
187
+ },
188
+ offset: flipOffset(offset, i),
189
+ });
190
+ }
191
+
192
+ function flipAttach(attach, i) {
193
+ const newAttach = [...attach];
194
+ const index = dirs[i].indexOf(attach[i]);
195
+ if (~index) {
196
+ newAttach[i] = dirs[i][1 - (index % 2) + 2];
197
+ }
198
+ return newAttach;
199
+ }
200
+
201
+ function flipOffset(offset, i) {
202
+ offset = [...offset];
203
+ offset[i] *= -1;
204
+ return offset;
200
205
  }
201
206
 
202
- function flipDir(prop) {
207
+ function flipAxis(prop) {
203
208
  for (let i = 0; i < dirs.length; i++) {
204
209
  const index = dirs[i].indexOf(prop);
205
210
  if (~index) {
package/tests/navbar.html CHANGED
@@ -3129,7 +3129,19 @@
3129
3129
  <td><code>target</code></td>
3130
3130
  <td>Boolean, CSS selector</td>
3131
3131
  <td>false</td>
3132
- <td>Align Drop to navbar.</td>
3132
+ <td>The element the drops are positioned to (`true` for window).</td>
3133
+ </tr>
3134
+ <tr>
3135
+ <td><code>target-x</code></td>
3136
+ <td>Boolean, CSS selector</td>
3137
+ <td>false</td>
3138
+ <td>The element's X axis the drops are positioned to (`true` for window).</td>
3139
+ </tr>
3140
+ <tr>
3141
+ <td><code>target-y</code></td>
3142
+ <td>Boolean, CSS selector</td>
3143
+ <td>false</td>
3144
+ <td>The element's Y axis the drop are positioned to (`true` for window).</td>
3133
3145
  </tr>
3134
3146
  <tr>
3135
3147
  <td><code>cls-drop</code></td>
@@ -303,8 +303,22 @@
303
303
 
304
304
  <div class="uk-margin">
305
305
  <span class="uk-form-label">Placement</span>
306
- <label><input id="js-flip" class="uk-checkbox" type="checkbox" checked> Flip</label>
307
- <label><input id="js-shift" class="uk-checkbox" type="checkbox" checked> Shift</label>
306
+ <label>
307
+ Horizontal
308
+ <select id="js-placement_x" class="uk-select uk-form-small uk-form-width-xsmall">
309
+ <option value="">None</option>
310
+ <option value="flip" selected>Flip</option>
311
+ <option value="shift">Shift</option>
312
+ </select>
313
+ </label>
314
+ <label>
315
+ Vertical
316
+ <select id="js-placement_y" class="uk-select uk-form-small uk-form-width-xsmall">
317
+ <option value="">None</option>
318
+ <option value="flip" selected>Flip</option>
319
+ <option value="shift">Shift</option>
320
+ </select>
321
+ </label>
308
322
  </div>
309
323
 
310
324
  </div>
@@ -332,8 +346,7 @@
332
346
  target: [$('#js-target_x').value, $('#js-target_y').value]
333
347
  },
334
348
  offset: [$('#js-offset_x').value, $('#js-offset_y').value],
335
- flip: $('#js-flip').checked,
336
- shift: $('#js-shift').checked
349
+ placement: [$('#js-placement_x').value, $('#js-placement_y').value]
337
350
  }
338
351
  );
339
352
  }