uikit 3.11.2-dev.03e47c2ff → 3.11.2-dev.06fe7f1d0
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/CHANGELOG.md +5 -1
- package/dist/css/uikit-core-rtl.css +12 -6
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +12 -6
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +12 -6
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +12 -6
- package/dist/css/uikit.min.css +1 -1
- package/dist/js/components/countdown.js +3 -3
- package/dist/js/components/countdown.min.js +1 -1
- package/dist/js/components/filter.js +1 -1
- package/dist/js/components/filter.min.js +1 -1
- package/dist/js/components/lightbox-panel.js +4 -14
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +4 -14
- package/dist/js/components/lightbox.min.js +1 -1
- package/dist/js/components/notification.js +1 -1
- package/dist/js/components/notification.min.js +1 -1
- package/dist/js/components/parallax.js +8 -9
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +8 -9
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +59 -78
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +8 -9
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +23 -45
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +1 -1
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +1 -1
- package/dist/js/components/tooltip.min.js +1 -1
- package/dist/js/components/upload.js +2 -1
- package/dist/js/components/upload.min.js +1 -1
- package/dist/js/uikit-core.js +357 -264
- package/dist/js/uikit-core.min.js +1 -1
- package/dist/js/uikit-icons.js +1 -1
- package/dist/js/uikit-icons.min.js +1 -1
- package/dist/js/uikit.js +414 -361
- package/dist/js/uikit.min.js +1 -1
- package/package.json +1 -1
- package/src/js/api/hooks.js +2 -2
- package/src/js/api/state.js +173 -140
- package/src/js/components/countdown.js +2 -2
- package/src/js/components/internal/slider-preload.js +4 -32
- package/src/js/components/slider.js +39 -42
- package/src/js/components/upload.js +2 -1
- package/src/js/core/accordion.js +6 -1
- package/src/js/core/core.js +2 -75
- package/src/js/core/cover.js +5 -1
- package/src/js/core/drop.js +3 -1
- package/src/js/core/form-custom.js +2 -2
- package/src/js/core/height-viewport.js +3 -0
- package/src/js/core/img.js +16 -24
- package/src/js/core/offcanvas.js +2 -1
- package/src/js/core/sticky.js +27 -33
- package/src/js/core/switcher.js +11 -3
- package/src/js/core/toggle.js +3 -1
- package/src/js/core/video.js +13 -1
- package/src/js/mixin/lazyload.js +20 -0
- package/src/js/mixin/parallax.js +8 -9
- package/src/js/mixin/slider.js +0 -6
- package/src/js/mixin/slideshow.js +0 -4
- package/src/js/mixin/swipe.js +72 -0
- package/src/js/util/index.js +1 -0
- package/src/js/util/observer.js +36 -0
- package/src/less/components/utility.less +6 -3
- package/src/scss/components/utility.scss +6 -3
- package/tests/parallax.html +2 -2
- package/tests/sticky-parallax.html +1 -1
- package/tests/utility.html +17 -0
package/src/js/core/core.js
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
css,
|
|
3
|
-
fastdom,
|
|
4
|
-
getEventPos,
|
|
5
|
-
inBrowser,
|
|
6
|
-
isTouch,
|
|
7
|
-
on,
|
|
8
|
-
once,
|
|
9
|
-
parent,
|
|
10
|
-
pointerCancel,
|
|
11
|
-
pointerDown,
|
|
12
|
-
pointerUp,
|
|
13
|
-
toMs,
|
|
14
|
-
trigger,
|
|
15
|
-
} from 'uikit-util';
|
|
1
|
+
import { css, fastdom, inBrowser, observeResize, on, toMs } from 'uikit-util';
|
|
16
2
|
|
|
17
3
|
export default function (UIkit) {
|
|
18
4
|
if (!inBrowser) {
|
|
@@ -32,27 +18,7 @@ export default function (UIkit) {
|
|
|
32
18
|
|
|
33
19
|
on(window, 'load resize', handleResize);
|
|
34
20
|
on(document, 'loadedmetadata load', handleResize, true);
|
|
35
|
-
|
|
36
|
-
if ('ResizeObserver' in window) {
|
|
37
|
-
new ResizeObserver(handleResize).observe(document.documentElement);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// throttle `scroll` event (Safari triggers multiple `scroll` events per frame)
|
|
41
|
-
let pending;
|
|
42
|
-
on(
|
|
43
|
-
window,
|
|
44
|
-
'scroll',
|
|
45
|
-
(e) => {
|
|
46
|
-
if (pending) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
pending = true;
|
|
50
|
-
fastdom.read(() => (pending = false));
|
|
51
|
-
|
|
52
|
-
UIkit.update(null, e.type);
|
|
53
|
-
},
|
|
54
|
-
{ passive: true, capture: true }
|
|
55
|
-
);
|
|
21
|
+
observeResize(document.documentElement, handleResize);
|
|
56
22
|
|
|
57
23
|
let started = 0;
|
|
58
24
|
on(
|
|
@@ -71,43 +37,4 @@ export default function (UIkit) {
|
|
|
71
37
|
},
|
|
72
38
|
true
|
|
73
39
|
);
|
|
74
|
-
|
|
75
|
-
on(
|
|
76
|
-
document,
|
|
77
|
-
pointerDown,
|
|
78
|
-
(e) => {
|
|
79
|
-
if (!isTouch(e)) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Handle Swipe Gesture
|
|
84
|
-
const pos = getEventPos(e);
|
|
85
|
-
const target = 'tagName' in e.target ? e.target : parent(e.target);
|
|
86
|
-
once(document, `${pointerUp} ${pointerCancel} scroll`, (e) => {
|
|
87
|
-
const { x, y } = getEventPos(e);
|
|
88
|
-
|
|
89
|
-
// swipe
|
|
90
|
-
if (
|
|
91
|
-
(e.type !== 'scroll' && target && x && Math.abs(pos.x - x) > 100) ||
|
|
92
|
-
(y && Math.abs(pos.y - y) > 100)
|
|
93
|
-
) {
|
|
94
|
-
setTimeout(() => {
|
|
95
|
-
trigger(target, 'swipe');
|
|
96
|
-
trigger(target, `swipe${swipeDirection(pos.x, pos.y, x, y)}`);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
{ passive: true }
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function swipeDirection(x1, y1, x2, y2) {
|
|
106
|
-
return Math.abs(x1 - x2) >= Math.abs(y1 - y2)
|
|
107
|
-
? x1 - x2 > 0
|
|
108
|
-
? 'Left'
|
|
109
|
-
: 'Right'
|
|
110
|
-
: y1 - y2 > 0
|
|
111
|
-
? 'Up'
|
|
112
|
-
: 'Down';
|
|
113
40
|
}
|
package/src/js/core/cover.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Video from './video';
|
|
2
|
-
import { css, Dimensions, parent } from 'uikit-util';
|
|
2
|
+
import { css, Dimensions, observeResize, parent } from 'uikit-util';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
mixins: [Video],
|
|
@@ -13,6 +13,10 @@ export default {
|
|
|
13
13
|
automute: true,
|
|
14
14
|
},
|
|
15
15
|
|
|
16
|
+
connected() {
|
|
17
|
+
this.registerObserver(observeResize(this.$el, () => this.$emit('resize')));
|
|
18
|
+
},
|
|
19
|
+
|
|
16
20
|
update: {
|
|
17
21
|
read() {
|
|
18
22
|
const el = this.$el;
|
package/src/js/core/drop.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Container from '../mixin/container';
|
|
2
|
+
import Lazyload from '../mixin/lazyload';
|
|
2
3
|
import Position from '../mixin/position';
|
|
3
4
|
import Togglable from '../mixin/togglable';
|
|
4
5
|
import {
|
|
@@ -30,7 +31,7 @@ import {
|
|
|
30
31
|
export let active;
|
|
31
32
|
|
|
32
33
|
export default {
|
|
33
|
-
mixins: [Container, Position, Togglable],
|
|
34
|
+
mixins: [Container, Lazyload, Position, Togglable],
|
|
34
35
|
|
|
35
36
|
args: 'pos',
|
|
36
37
|
|
|
@@ -84,6 +85,7 @@ export default {
|
|
|
84
85
|
mode: this.mode,
|
|
85
86
|
}).$el;
|
|
86
87
|
attr(this.target, 'aria-haspopup', true);
|
|
88
|
+
this.lazyload(this.target);
|
|
87
89
|
}
|
|
88
90
|
},
|
|
89
91
|
|
package/src/js/core/img.js
CHANGED
|
@@ -8,10 +8,12 @@ import {
|
|
|
8
8
|
escape,
|
|
9
9
|
fragment,
|
|
10
10
|
hasAttr,
|
|
11
|
+
hasIntersectionObserver,
|
|
11
12
|
includes,
|
|
12
13
|
isArray,
|
|
13
14
|
isEmpty,
|
|
14
15
|
isTag,
|
|
16
|
+
observeIntersection,
|
|
15
17
|
parent,
|
|
16
18
|
parseOptions,
|
|
17
19
|
queryAll,
|
|
@@ -23,7 +25,6 @@ import {
|
|
|
23
25
|
} from 'uikit-util';
|
|
24
26
|
|
|
25
27
|
const nativeLazyLoad = 'loading' in HTMLImageElement.prototype;
|
|
26
|
-
const nativeIsIntersecting = 'isIntersecting' in IntersectionObserverEntry.prototype; // Old chromium based browsers (UC Browser) did not implement `isIntersecting`
|
|
27
28
|
|
|
28
29
|
export default {
|
|
29
30
|
args: 'dataSrc',
|
|
@@ -53,13 +54,13 @@ export default {
|
|
|
53
54
|
},
|
|
54
55
|
|
|
55
56
|
watch() {
|
|
56
|
-
this
|
|
57
|
+
this.$reset();
|
|
57
58
|
},
|
|
58
59
|
},
|
|
59
60
|
},
|
|
60
61
|
|
|
61
62
|
connected() {
|
|
62
|
-
if (this.loading !== 'lazy' || !
|
|
63
|
+
if (this.loading !== 'lazy' || !hasIntersectionObserver) {
|
|
63
64
|
this.load();
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
@@ -75,28 +76,27 @@ export default {
|
|
|
75
76
|
|
|
76
77
|
ensureSrcAttribute(this.$el);
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.observer = new IntersectionObserver(
|
|
83
|
-
(entries) => {
|
|
84
|
-
if (entries.some((entry) => entry.isIntersecting)) {
|
|
79
|
+
this.registerObserver(
|
|
80
|
+
observeIntersection(
|
|
81
|
+
this.target,
|
|
82
|
+
(entries, observer) => {
|
|
85
83
|
this.load();
|
|
86
|
-
|
|
84
|
+
observer.disconnect();
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
rootMargin: `${toPx(this.offsetTop, 'height')}px ${toPx(
|
|
88
|
+
this.offsetLeft,
|
|
89
|
+
'width'
|
|
90
|
+
)}px`,
|
|
87
91
|
}
|
|
88
|
-
|
|
89
|
-
{ rootMargin }
|
|
92
|
+
)
|
|
90
93
|
);
|
|
91
|
-
this.observe();
|
|
92
94
|
},
|
|
93
95
|
|
|
94
96
|
disconnected() {
|
|
95
97
|
if (this._data.image) {
|
|
96
98
|
this._data.image.onload = '';
|
|
97
99
|
}
|
|
98
|
-
|
|
99
|
-
this.observer?.disconnect();
|
|
100
100
|
},
|
|
101
101
|
|
|
102
102
|
update: {
|
|
@@ -132,14 +132,6 @@ export default {
|
|
|
132
132
|
setSrcAttrs(this.$el, image.currentSrc);
|
|
133
133
|
return (this._data.image = image);
|
|
134
134
|
},
|
|
135
|
-
|
|
136
|
-
observe() {
|
|
137
|
-
if (this._connected && !this._data.image) {
|
|
138
|
-
for (const el of this.target) {
|
|
139
|
-
this.observer.observe(el);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
135
|
},
|
|
144
136
|
};
|
|
145
137
|
|
package/src/js/core/offcanvas.js
CHANGED
package/src/js/core/sticky.js
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
offset as getOffset,
|
|
14
14
|
getScrollingElement,
|
|
15
15
|
hasClass,
|
|
16
|
-
isNumeric,
|
|
17
16
|
isString,
|
|
18
17
|
isVisible,
|
|
19
18
|
noop,
|
|
@@ -29,6 +28,7 @@ import {
|
|
|
29
28
|
toPx,
|
|
30
29
|
trigger,
|
|
31
30
|
within,
|
|
31
|
+
intersectRect,
|
|
32
32
|
} from 'uikit-util';
|
|
33
33
|
|
|
34
34
|
export default {
|
|
@@ -119,34 +119,29 @@ export default {
|
|
|
119
119
|
return window;
|
|
120
120
|
},
|
|
121
121
|
|
|
122
|
+
filter() {
|
|
123
|
+
return this.targetOffset !== false;
|
|
124
|
+
},
|
|
125
|
+
|
|
122
126
|
handler() {
|
|
123
|
-
if (!
|
|
127
|
+
if (!location.hash || scrollTop(window) === 0) {
|
|
124
128
|
return;
|
|
125
129
|
}
|
|
126
130
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
window,
|
|
142
|
-
top -
|
|
143
|
-
elHeight -
|
|
144
|
-
(isNumeric(this.targetOffset) ? this.targetOffset : 0) -
|
|
145
|
-
this._data.offset
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
131
|
+
fastdom.read(() => {
|
|
132
|
+
const targetOffset = getOffset($(location.hash));
|
|
133
|
+
const elOffset = getOffset(this.$el);
|
|
134
|
+
|
|
135
|
+
if (this.isFixed && intersectRect(targetOffset, elOffset)) {
|
|
136
|
+
scrollTop(
|
|
137
|
+
window,
|
|
138
|
+
targetOffset.top -
|
|
139
|
+
elOffset.height -
|
|
140
|
+
toPx(this.targetOffset, 'height') -
|
|
141
|
+
toPx(this.offset, 'height')
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
150
145
|
},
|
|
151
146
|
},
|
|
152
147
|
],
|
|
@@ -177,20 +172,19 @@ export default {
|
|
|
177
172
|
}
|
|
178
173
|
|
|
179
174
|
const referenceElement = this.isFixed ? this.placeholder : this.$el;
|
|
175
|
+
const windowHeight = getHeight(window);
|
|
180
176
|
|
|
181
177
|
let position = this.position;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
position = height > getHeight(window) ? 'bottom' : 'top';
|
|
178
|
+
if (position === 'auto' && height > windowHeight) {
|
|
179
|
+
position = 'bottom';
|
|
185
180
|
}
|
|
186
181
|
|
|
187
|
-
let offset = this.offset;
|
|
182
|
+
let offset = toPx(this.offset, 'height', referenceElement);
|
|
188
183
|
if (position === 'bottom') {
|
|
189
|
-
offset +=
|
|
184
|
+
offset += windowHeight - height;
|
|
190
185
|
}
|
|
191
|
-
offset = toPx(offset, 'height', referenceElement);
|
|
192
186
|
|
|
193
|
-
const overflow = Math.max(0, height + offset -
|
|
187
|
+
const overflow = Math.max(0, height + offset - windowHeight);
|
|
194
188
|
const topOffset = getOffset(referenceElement).top;
|
|
195
189
|
const offsetParentTop = getOffset(referenceElement.offsetParent).top;
|
|
196
190
|
|
|
@@ -200,7 +194,7 @@ export default {
|
|
|
200
194
|
const start = Math.max(top, topOffset) - offset;
|
|
201
195
|
const end = bottom
|
|
202
196
|
? bottom - getOffset(this.$el).height + overflow - offset
|
|
203
|
-
: getScrollingElement(this.$el).scrollHeight -
|
|
197
|
+
: getScrollingElement(this.$el).scrollHeight - windowHeight;
|
|
204
198
|
|
|
205
199
|
return {
|
|
206
200
|
start,
|
package/src/js/core/switcher.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import Lazyload from '../mixin/lazyload';
|
|
2
|
+
import Swipe from '../mixin/swipe';
|
|
1
3
|
import Togglable from '../mixin/togglable';
|
|
2
4
|
import {
|
|
3
5
|
$$,
|
|
@@ -17,7 +19,7 @@ import {
|
|
|
17
19
|
} from 'uikit-util';
|
|
18
20
|
|
|
19
21
|
export default {
|
|
20
|
-
mixins: [Togglable],
|
|
22
|
+
mixins: [Lazyload, Swipe, Togglable],
|
|
21
23
|
|
|
22
24
|
args: 'connect',
|
|
23
25
|
|
|
@@ -26,7 +28,6 @@ export default {
|
|
|
26
28
|
toggle: String,
|
|
27
29
|
itemNav: String,
|
|
28
30
|
active: Number,
|
|
29
|
-
swiping: Boolean,
|
|
30
31
|
},
|
|
31
32
|
|
|
32
33
|
data: {
|
|
@@ -34,7 +35,6 @@ export default {
|
|
|
34
35
|
toggle: '> * > :first-child',
|
|
35
36
|
itemNav: false,
|
|
36
37
|
active: 0,
|
|
37
|
-
swiping: true,
|
|
38
38
|
cls: 'uk-active',
|
|
39
39
|
attrItem: 'uk-switcher-item',
|
|
40
40
|
},
|
|
@@ -79,6 +79,14 @@ export default {
|
|
|
79
79
|
this.toggles.some((toggle) => within(toggle, child))
|
|
80
80
|
);
|
|
81
81
|
},
|
|
82
|
+
|
|
83
|
+
swipeTarget() {
|
|
84
|
+
return this.connects;
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
connected() {
|
|
89
|
+
this.lazyload(this.$el, this.connects);
|
|
82
90
|
},
|
|
83
91
|
|
|
84
92
|
events: [
|
package/src/js/core/toggle.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Lazyload from '../mixin/lazyload';
|
|
1
2
|
import Media from '../mixin/media';
|
|
2
3
|
import Togglable from '../mixin/togglable';
|
|
3
4
|
import {
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
const KEY_SPACE = 32;
|
|
23
24
|
|
|
24
25
|
export default {
|
|
25
|
-
mixins: [Media, Togglable],
|
|
26
|
+
mixins: [Lazyload, Media, Togglable],
|
|
26
27
|
|
|
27
28
|
args: 'target',
|
|
28
29
|
|
|
@@ -44,6 +45,7 @@ export default {
|
|
|
44
45
|
if (!includes(this.mode, 'media') && !isFocusable(this.$el)) {
|
|
45
46
|
attr(this.$el, 'tabindex', '0');
|
|
46
47
|
}
|
|
48
|
+
this.lazyload(this.$el, this.target);
|
|
47
49
|
},
|
|
48
50
|
|
|
49
51
|
computed: {
|
package/src/js/core/video.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
css,
|
|
3
|
+
hasAttr,
|
|
4
|
+
isInView,
|
|
5
|
+
isVideo,
|
|
6
|
+
isVisible,
|
|
7
|
+
mute,
|
|
8
|
+
observeIntersection,
|
|
9
|
+
pause,
|
|
10
|
+
play,
|
|
11
|
+
} from 'uikit-util';
|
|
2
12
|
|
|
3
13
|
export default {
|
|
4
14
|
args: 'autoplay',
|
|
@@ -27,6 +37,8 @@ export default {
|
|
|
27
37
|
if (this.automute) {
|
|
28
38
|
mute(this.$el);
|
|
29
39
|
}
|
|
40
|
+
|
|
41
|
+
this.registerObserver(observeIntersection(this.$el, () => this.$emit('resize')));
|
|
30
42
|
},
|
|
31
43
|
|
|
32
44
|
update: {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { $$, isFunction, observeIntersection, removeAttr, toNodes } from 'uikit-util';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
methods: {
|
|
5
|
+
lazyload(observeTargets = this.$el, targets = this.$el) {
|
|
6
|
+
this.registerObserver(
|
|
7
|
+
observeIntersection(observeTargets, (entries, observer) => {
|
|
8
|
+
for (const el of toNodes(isFunction(targets) ? targets() : targets)) {
|
|
9
|
+
$$('[loading="lazy"]', el).forEach((el) => removeAttr(el, 'loading'));
|
|
10
|
+
}
|
|
11
|
+
for (const el of entries
|
|
12
|
+
.filter(({ isIntersecting }) => isIntersecting)
|
|
13
|
+
.map(({ target }) => target)) {
|
|
14
|
+
observer.unobserve(el);
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
package/src/js/mixin/parallax.js
CHANGED
|
@@ -57,7 +57,7 @@ export default {
|
|
|
57
57
|
},
|
|
58
58
|
|
|
59
59
|
events: {
|
|
60
|
-
|
|
60
|
+
load() {
|
|
61
61
|
this.$emit();
|
|
62
62
|
},
|
|
63
63
|
},
|
|
@@ -68,13 +68,11 @@ export default {
|
|
|
68
68
|
},
|
|
69
69
|
|
|
70
70
|
getCss(percent) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{ transform: '', filter: '' }
|
|
77
|
-
);
|
|
71
|
+
const css = { transform: '', filter: '' };
|
|
72
|
+
for (const prop in this.props) {
|
|
73
|
+
this.props[prop](css, percent);
|
|
74
|
+
}
|
|
75
|
+
return css;
|
|
78
76
|
},
|
|
79
77
|
},
|
|
80
78
|
};
|
|
@@ -257,8 +255,9 @@ function getBackgroundImageDimensions(el) {
|
|
|
257
255
|
if (!image.naturalWidth) {
|
|
258
256
|
image.onload = () => {
|
|
259
257
|
dimensions[src] = toDimensions(image);
|
|
260
|
-
trigger(el, '
|
|
258
|
+
trigger(el, 'load');
|
|
261
259
|
};
|
|
260
|
+
return toDimensions(image);
|
|
262
261
|
}
|
|
263
262
|
}
|
|
264
263
|
|
package/src/js/mixin/slider.js
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getEventPos,
|
|
3
|
+
isTouch,
|
|
4
|
+
once,
|
|
5
|
+
parent,
|
|
6
|
+
pointerCancel,
|
|
7
|
+
pointerDown,
|
|
8
|
+
pointerUp,
|
|
9
|
+
trigger,
|
|
10
|
+
} from 'uikit-util';
|
|
11
|
+
import { registerEvent } from '../api/state';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
props: {
|
|
15
|
+
swiping: Boolean,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
data: {
|
|
19
|
+
swiping: true,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
computed: {
|
|
23
|
+
swipeTarget(props, $el) {
|
|
24
|
+
return $el;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
connected() {
|
|
29
|
+
if (!this.swiping) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
registerEvent(this, {
|
|
34
|
+
el: this.swipeTarget,
|
|
35
|
+
name: pointerDown,
|
|
36
|
+
passive: true,
|
|
37
|
+
handler(e) {
|
|
38
|
+
if (!isTouch(e)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Handle Swipe Gesture
|
|
43
|
+
const pos = getEventPos(e);
|
|
44
|
+
const target = 'tagName' in e.target ? e.target : parent(e.target);
|
|
45
|
+
once(document, `${pointerUp} ${pointerCancel} scroll`, (e) => {
|
|
46
|
+
const { x, y } = getEventPos(e);
|
|
47
|
+
|
|
48
|
+
// swipe
|
|
49
|
+
if (
|
|
50
|
+
(e.type !== 'scroll' && target && x && Math.abs(pos.x - x) > 100) ||
|
|
51
|
+
(y && Math.abs(pos.y - y) > 100)
|
|
52
|
+
) {
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
trigger(target, 'swipe');
|
|
55
|
+
trigger(target, `swipe${swipeDirection(pos.x, pos.y, x, y)}`);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function swipeDirection(x1, y1, x2, y2) {
|
|
65
|
+
return Math.abs(x1 - x2) >= Math.abs(y1 - y2)
|
|
66
|
+
? x1 - x2 > 0
|
|
67
|
+
? 'Left'
|
|
68
|
+
: 'Right'
|
|
69
|
+
: y1 - y2 > 0
|
|
70
|
+
? 'Up'
|
|
71
|
+
: 'Down';
|
|
72
|
+
}
|
package/src/js/util/index.js
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { toNodes } from './lang';
|
|
2
|
+
|
|
3
|
+
// Old chromium based browsers (UC Browser) did not implement `isIntersecting`
|
|
4
|
+
export const hasIntersectionObserver =
|
|
5
|
+
window.IntersectionObserver && 'isIntersecting' in IntersectionObserverEntry.prototype;
|
|
6
|
+
export function observeIntersection(targets, cb, options, intersecting = true) {
|
|
7
|
+
if (!hasIntersectionObserver) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const observer = new IntersectionObserver((entries, observer) => {
|
|
12
|
+
if (!intersecting || entries.some((entry) => entry.isIntersecting)) {
|
|
13
|
+
cb(entries, observer);
|
|
14
|
+
}
|
|
15
|
+
}, options);
|
|
16
|
+
for (const el of toNodes(targets)) {
|
|
17
|
+
observer.observe(el);
|
|
18
|
+
}
|
|
19
|
+
return observer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const hasResizeObserver = window.ResizeObserver;
|
|
23
|
+
export function observeResize(targets, cb, options = { box: 'border-box' }) {
|
|
24
|
+
if (!hasResizeObserver) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const observer = new ResizeObserver((entries, observer) => {
|
|
29
|
+
cb(entries, observer);
|
|
30
|
+
});
|
|
31
|
+
for (const el of toNodes(targets)) {
|
|
32
|
+
observer.observe(el, options);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return observer;
|
|
36
|
+
}
|