vevet 3.0.0-beta.2 → 3.0.0-beta.3
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/lib/cjs/version.js +1 -1
- package/lib/esm/Application/events/PageLoad/index.js +28 -54
- package/lib/esm/Application/events/PageLoad/index.js.map +1 -1
- package/lib/esm/Application/events/Viewport/index.js +107 -180
- package/lib/esm/Application/events/Viewport/index.js.map +1 -1
- package/lib/esm/Application/index.js +96 -178
- package/lib/esm/Application/index.js.map +1 -1
- package/lib/esm/base/Callbacks/index.js +45 -78
- package/lib/esm/base/Callbacks/index.js.map +1 -1
- package/lib/esm/base/Component/index.js +10 -31
- package/lib/esm/base/Component/index.js.map +1 -1
- package/lib/esm/base/Module/index.js +77 -132
- package/lib/esm/base/Module/index.js.map +1 -1
- package/lib/esm/base/MutableProps/index.js +30 -49
- package/lib/esm/base/MutableProps/index.js.map +1 -1
- package/lib/esm/base/Plugin/index.js +13 -35
- package/lib/esm/base/Plugin/index.js.map +1 -1
- package/lib/esm/components/AnimationFrame/index.js +55 -98
- package/lib/esm/components/AnimationFrame/index.js.map +1 -1
- package/lib/esm/components/BaseTimeline/index.js +41 -88
- package/lib/esm/components/BaseTimeline/index.js.map +1 -1
- package/lib/esm/components/Ctx2D/index.js +82 -150
- package/lib/esm/components/Ctx2D/index.js.map +1 -1
- package/lib/esm/components/Ctx2DPrerender/index.js +20 -54
- package/lib/esm/components/Ctx2DPrerender/index.js.map +1 -1
- package/lib/esm/components/CustomCursor/index.js +149 -216
- package/lib/esm/components/CustomCursor/index.js.map +1 -1
- package/lib/esm/components/DraggerBase/index.js +98 -164
- package/lib/esm/components/DraggerBase/index.js.map +1 -1
- package/lib/esm/components/DraggerDirection/index.js +10 -42
- package/lib/esm/components/DraggerDirection/index.js.map +1 -1
- package/lib/esm/components/DraggerMove/index.js +42 -83
- package/lib/esm/components/DraggerMove/index.js.map +1 -1
- package/lib/esm/components/Preloader/index.js +77 -135
- package/lib/esm/components/Preloader/index.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/index.js +112 -190
- package/lib/esm/components/ProgressPreloader/index.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/utils/preloadCustomElement.js +9 -10
- package/lib/esm/components/ProgressPreloader/utils/preloadCustomElement.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/utils/preloadImage.js +3 -3
- package/lib/esm/components/ProgressPreloader/utils/preloadImage.js.map +1 -1
- package/lib/esm/components/ProgressPreloader/utils/preloadVideo.js +2 -2
- package/lib/esm/components/ProgressPreloader/utils/preloadVideo.js.map +1 -1
- package/lib/esm/components/ScrollBar/Bar/index.js +90 -136
- package/lib/esm/components/ScrollBar/Bar/index.js.map +1 -1
- package/lib/esm/components/ScrollBar/index.js +70 -118
- package/lib/esm/components/ScrollBar/index.js.map +1 -1
- package/lib/esm/components/ScrollView/index.js +103 -154
- package/lib/esm/components/ScrollView/index.js.map +1 -1
- package/lib/esm/components/SectionScrollProgress/index.js +95 -170
- package/lib/esm/components/SectionScrollProgress/index.js.map +1 -1
- package/lib/esm/components/SmoothScroll/AnimatonFrame.js +20 -37
- package/lib/esm/components/SmoothScroll/AnimatonFrame.js.map +1 -1
- package/lib/esm/components/SmoothScroll/Elements.js +42 -59
- package/lib/esm/components/SmoothScroll/Elements.js.map +1 -1
- package/lib/esm/components/SmoothScroll/index.js +205 -304
- package/lib/esm/components/SmoothScroll/index.js.map +1 -1
- package/lib/esm/components/SmoothScrollDragPlugin/index.js +48 -86
- package/lib/esm/components/SmoothScrollDragPlugin/index.js.map +1 -1
- package/lib/esm/components/SmoothScrollKeyboardPlugin/index.js +34 -70
- package/lib/esm/components/SmoothScrollKeyboardPlugin/index.js.map +1 -1
- package/lib/esm/components/SplitText/index.js +117 -177
- package/lib/esm/components/SplitText/index.js.map +1 -1
- package/lib/esm/components/Timeline/index.js +45 -88
- package/lib/esm/components/Timeline/index.js.map +1 -1
- package/lib/esm/utils/common/mergeWithoutArrays.js +1 -1
- package/lib/esm/utils/common/mergeWithoutArrays.js.map +1 -1
- package/lib/esm/utils/common/normalizedTimeoutCallback.js +3 -3
- package/lib/esm/utils/common/normalizedTimeoutCallback.js.map +1 -1
- package/lib/esm/utils/common/pickObjectProps.js +2 -2
- package/lib/esm/utils/common/pickObjectProps.js.map +1 -1
- package/lib/esm/utils/common/times.js +2 -2
- package/lib/esm/utils/common/times.js.map +1 -1
- package/lib/esm/utils/common/uid.js +3 -4
- package/lib/esm/utils/common/uid.js.map +1 -1
- package/lib/esm/utils/image/load.js +15 -26
- package/lib/esm/utils/image/load.js.map +1 -1
- package/lib/esm/utils/image/pathsToProps.js +5 -5
- package/lib/esm/utils/image/pathsToProps.js.map +1 -1
- package/lib/esm/utils/image/sizesToSrcSet.js +5 -5
- package/lib/esm/utils/image/sizesToSrcSet.js.map +1 -1
- package/lib/esm/utils/internal/fetchWebpSupport.js +3 -3
- package/lib/esm/utils/internal/fetchWebpSupport.js.map +1 -1
- package/lib/esm/utils/internal/getDeviceInfo.js +7 -7
- package/lib/esm/utils/internal/getDeviceInfo.js.map +1 -1
- package/lib/esm/utils/internal/onResize.js +13 -16
- package/lib/esm/utils/internal/onResize.js.map +1 -1
- package/lib/esm/utils/math/clamp.js +1 -2
- package/lib/esm/utils/math/clamp.js.map +1 -1
- package/lib/esm/utils/math/clampScope.js +1 -3
- package/lib/esm/utils/math/clampScope.js.map +1 -1
- package/lib/esm/utils/math/easing.js +1 -5
- package/lib/esm/utils/math/easing.js.map +1 -1
- package/lib/esm/utils/math/inScope.js +1 -2
- package/lib/esm/utils/math/inScope.js.map +1 -1
- package/lib/esm/utils/math/lerp.js +3 -4
- package/lib/esm/utils/math/lerp.js.map +1 -1
- package/lib/esm/utils/math/normalizeNestedScope.js +1 -1
- package/lib/esm/utils/math/normalizeNestedScope.js.map +1 -1
- package/lib/esm/utils/math/scoped.js +2 -3
- package/lib/esm/utils/math/scoped.js.map +1 -1
- package/lib/esm/utils/math/spreadScope.js +5 -5
- package/lib/esm/utils/math/spreadScope.js.map +1 -1
- package/lib/esm/utils/math/wrap.js +2 -2
- package/lib/esm/utils/math/wrap.js.map +1 -1
- package/lib/esm/utils/scroll/getScrollValues.js +5 -6
- package/lib/esm/utils/scroll/getScrollValues.js.map +1 -1
- package/lib/esm/utils/scroll/onScroll.js +20 -23
- package/lib/esm/utils/scroll/onScroll.js.map +1 -1
- package/lib/esm/utils/scroll/scrollTo.js +10 -12
- package/lib/esm/utils/scroll/scrollTo.js.map +1 -1
- package/lib/esm/utils/scroll/scrollToElement.js +8 -19
- package/lib/esm/utils/scroll/scrollToElement.js.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/esm/vevet.js +1 -1
- package/lib/esm/vevet.js.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/version.ts +1 -1
|
@@ -3,10 +3,45 @@ import { DraggerMove } from '../../DraggerMove';
|
|
|
3
3
|
import { onScroll } from '../../../utils/scroll/onScroll';
|
|
4
4
|
import { clamp } from '../../../utils/math';
|
|
5
5
|
import { getScrollValues } from '../../../utils/scroll';
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
export default class Bar {
|
|
7
|
+
get outer() {
|
|
8
|
+
return this._outer;
|
|
9
|
+
}
|
|
10
|
+
get thumb() {
|
|
11
|
+
return this._thumb;
|
|
12
|
+
}
|
|
13
|
+
get prefix() {
|
|
14
|
+
return this.props.prefix;
|
|
15
|
+
}
|
|
16
|
+
get isHorizontal() {
|
|
17
|
+
return this.props.direction === 'x';
|
|
18
|
+
}
|
|
19
|
+
get isVertical() {
|
|
20
|
+
return !this.isHorizontal;
|
|
21
|
+
}
|
|
22
|
+
get scrollElement() {
|
|
23
|
+
return this.props.container instanceof Window
|
|
24
|
+
? document.documentElement
|
|
25
|
+
: this.props.container;
|
|
26
|
+
}
|
|
27
|
+
get scrollLine() {
|
|
28
|
+
const { scrollElement } = this;
|
|
29
|
+
return this.isHorizontal
|
|
30
|
+
? scrollElement.scrollWidth - scrollElement.clientWidth
|
|
31
|
+
: scrollElement.scrollHeight - scrollElement.clientHeight;
|
|
32
|
+
}
|
|
33
|
+
get scrollWidth() {
|
|
34
|
+
return this.scrollElement.scrollWidth;
|
|
35
|
+
}
|
|
36
|
+
get scrollHeight() {
|
|
37
|
+
return this.scrollElement.scrollHeight;
|
|
38
|
+
}
|
|
39
|
+
get props() {
|
|
40
|
+
return this._props;
|
|
41
|
+
}
|
|
42
|
+
constructor(_props) {
|
|
8
43
|
this._props = _props;
|
|
9
|
-
|
|
44
|
+
const { direction, domParent, container, canAutoHide } = _props;
|
|
10
45
|
// set default vars
|
|
11
46
|
this._outerHeight = 0;
|
|
12
47
|
this._outerWidth = 0;
|
|
@@ -15,140 +50,62 @@ var Bar = /** @class */ (function () {
|
|
|
15
50
|
this._prevScrollValue = 0;
|
|
16
51
|
this._coordsAtDragStart = { scrollLeft: 0, scrollTop: 0 };
|
|
17
52
|
// create container
|
|
18
|
-
|
|
53
|
+
const outer = document.createElement('div');
|
|
19
54
|
this._outer = outer;
|
|
20
55
|
outer.classList.add(this.className(''));
|
|
21
|
-
outer.classList.add(this.className(
|
|
56
|
+
outer.classList.add(this.className(`_${direction}`));
|
|
22
57
|
if (container instanceof Window) {
|
|
23
58
|
outer.classList.add(this.className('_in-window'));
|
|
24
59
|
}
|
|
25
60
|
outer.classList.toggle(this.className('_auto-hide'), canAutoHide);
|
|
26
61
|
domParent.append(outer);
|
|
27
62
|
// create a thumb
|
|
28
|
-
|
|
63
|
+
const thumb = document.createElement('div');
|
|
29
64
|
this._thumb = thumb;
|
|
30
65
|
thumb.classList.add(this.className('__thumb'));
|
|
31
|
-
thumb.classList.add(this.className(
|
|
66
|
+
thumb.classList.add(this.className(`__thumb_${direction}`));
|
|
32
67
|
outer.append(thumb);
|
|
33
68
|
// set events
|
|
34
69
|
this._setEvents();
|
|
35
70
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
enumerable: false,
|
|
41
|
-
configurable: true
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(Bar.prototype, "thumb", {
|
|
44
|
-
get: function () {
|
|
45
|
-
return this._thumb;
|
|
46
|
-
},
|
|
47
|
-
enumerable: false,
|
|
48
|
-
configurable: true
|
|
49
|
-
});
|
|
50
|
-
Object.defineProperty(Bar.prototype, "prefix", {
|
|
51
|
-
get: function () {
|
|
52
|
-
return this.props.prefix;
|
|
53
|
-
},
|
|
54
|
-
enumerable: false,
|
|
55
|
-
configurable: true
|
|
56
|
-
});
|
|
57
|
-
Object.defineProperty(Bar.prototype, "isHorizontal", {
|
|
58
|
-
get: function () {
|
|
59
|
-
return this.props.direction === 'x';
|
|
60
|
-
},
|
|
61
|
-
enumerable: false,
|
|
62
|
-
configurable: true
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(Bar.prototype, "isVertical", {
|
|
65
|
-
get: function () {
|
|
66
|
-
return !this.isHorizontal;
|
|
67
|
-
},
|
|
68
|
-
enumerable: false,
|
|
69
|
-
configurable: true
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(Bar.prototype, "scrollElement", {
|
|
72
|
-
get: function () {
|
|
73
|
-
return this.props.container instanceof Window
|
|
74
|
-
? document.documentElement
|
|
75
|
-
: this.props.container;
|
|
76
|
-
},
|
|
77
|
-
enumerable: false,
|
|
78
|
-
configurable: true
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(Bar.prototype, "scrollLine", {
|
|
81
|
-
get: function () {
|
|
82
|
-
var scrollElement = this.scrollElement;
|
|
83
|
-
return this.isHorizontal
|
|
84
|
-
? scrollElement.scrollWidth - scrollElement.clientWidth
|
|
85
|
-
: scrollElement.scrollHeight - scrollElement.clientHeight;
|
|
86
|
-
},
|
|
87
|
-
enumerable: false,
|
|
88
|
-
configurable: true
|
|
89
|
-
});
|
|
90
|
-
Object.defineProperty(Bar.prototype, "scrollWidth", {
|
|
91
|
-
get: function () {
|
|
92
|
-
return this.scrollElement.scrollWidth;
|
|
93
|
-
},
|
|
94
|
-
enumerable: false,
|
|
95
|
-
configurable: true
|
|
96
|
-
});
|
|
97
|
-
Object.defineProperty(Bar.prototype, "scrollHeight", {
|
|
98
|
-
get: function () {
|
|
99
|
-
return this.scrollElement.scrollHeight;
|
|
100
|
-
},
|
|
101
|
-
enumerable: false,
|
|
102
|
-
configurable: true
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(Bar.prototype, "props", {
|
|
105
|
-
get: function () {
|
|
106
|
-
return this._props;
|
|
107
|
-
},
|
|
108
|
-
enumerable: false,
|
|
109
|
-
configurable: true
|
|
110
|
-
});
|
|
111
|
-
Bar.prototype.className = function (value) {
|
|
112
|
-
return "".concat(this.props.prefix).concat(value);
|
|
113
|
-
};
|
|
71
|
+
className(value) {
|
|
72
|
+
return `${this.props.prefix}${value}`;
|
|
73
|
+
}
|
|
114
74
|
/** Set scrolblar events */
|
|
115
|
-
|
|
116
|
-
var _this = this;
|
|
75
|
+
_setEvents() {
|
|
117
76
|
if (!this._listeners) {
|
|
118
77
|
this._listeners = [];
|
|
119
78
|
}
|
|
120
|
-
|
|
121
|
-
this._listeners.push(addEventListener(outer, 'mouseenter',
|
|
122
|
-
this._listeners.push(addEventListener(outer, 'mouseleave',
|
|
79
|
+
const { outer, thumb, props } = this;
|
|
80
|
+
this._listeners.push(addEventListener(outer, 'mouseenter', () => this._handleHover(true)));
|
|
81
|
+
this._listeners.push(addEventListener(outer, 'mouseleave', () => this._handleHover(false)));
|
|
123
82
|
this._scrollEvent = onScroll({
|
|
124
83
|
container: props.container,
|
|
125
|
-
callback:
|
|
84
|
+
callback: (data) => this._handleScroll(data),
|
|
126
85
|
});
|
|
127
86
|
if (this.props.isDraggable) {
|
|
128
87
|
this._dragger = new DraggerMove({ container: thumb });
|
|
129
|
-
this._dragger.addCallback('start',
|
|
130
|
-
|
|
88
|
+
this._dragger.addCallback('start', () => {
|
|
89
|
+
this._coordsAtDragStart = getScrollValues(this.props.container);
|
|
131
90
|
});
|
|
132
|
-
this._dragger.addCallback('move',
|
|
91
|
+
this._dragger.addCallback('move', (data) => this._handleThumbDrag(data));
|
|
133
92
|
}
|
|
134
|
-
}
|
|
93
|
+
}
|
|
135
94
|
/** Remove events */
|
|
136
|
-
|
|
95
|
+
_removeEvents() {
|
|
137
96
|
var _a, _b, _c;
|
|
138
|
-
(_a = this._listeners) === null || _a === void 0 ? void 0 : _a.forEach(
|
|
97
|
+
(_a = this._listeners) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.remove());
|
|
139
98
|
(_b = this._scrollEvent) === null || _b === void 0 ? void 0 : _b.remove();
|
|
140
99
|
(_c = this._dragger) === null || _c === void 0 ? void 0 : _c.destroy();
|
|
141
|
-
}
|
|
100
|
+
}
|
|
142
101
|
/** Handle hover state */
|
|
143
|
-
|
|
144
|
-
|
|
102
|
+
_handleHover(isHovered) {
|
|
103
|
+
const className = this.className('_is-hovered');
|
|
145
104
|
this.outer.classList.toggle(className, isHovered);
|
|
146
|
-
}
|
|
105
|
+
}
|
|
147
106
|
/** Handle Scroll Event */
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
var scrollLeft = _a.scrollLeft, scrollTop = _a.scrollTop;
|
|
151
|
-
var hasChanged = false;
|
|
107
|
+
_handleScroll({ scrollLeft, scrollTop }) {
|
|
108
|
+
let hasChanged = false;
|
|
152
109
|
// check if changes happened
|
|
153
110
|
if (this.isHorizontal) {
|
|
154
111
|
hasChanged = scrollLeft !== this._prevScrollValue;
|
|
@@ -164,29 +121,28 @@ var Bar = /** @class */ (function () {
|
|
|
164
121
|
}
|
|
165
122
|
// set auto hide
|
|
166
123
|
if (this.props.canAutoHide && hasChanged) {
|
|
167
|
-
|
|
168
|
-
this.outer.classList.add(
|
|
124
|
+
const actionClassName = this.className('_in-action');
|
|
125
|
+
this.outer.classList.add(actionClassName);
|
|
169
126
|
if (this._actionTimeout) {
|
|
170
127
|
clearTimeout(this._actionTimeout);
|
|
171
128
|
}
|
|
172
|
-
this._actionTimeout = setTimeout(
|
|
129
|
+
this._actionTimeout = setTimeout(() => this.outer.classList.remove(actionClassName), 500);
|
|
173
130
|
}
|
|
174
131
|
// render elements
|
|
175
132
|
this._renderThumb();
|
|
176
|
-
}
|
|
133
|
+
}
|
|
177
134
|
/** Event on dragger move */
|
|
178
|
-
|
|
179
|
-
var event = _a.event, coords = _a.coords, start = _a.start;
|
|
135
|
+
_handleThumbDrag({ event, coords, start, }) {
|
|
180
136
|
event.preventDefault();
|
|
181
|
-
|
|
182
|
-
|
|
137
|
+
const { scrollLine } = this;
|
|
138
|
+
const { container } = this.props;
|
|
183
139
|
// calculate scroll iterators
|
|
184
|
-
|
|
140
|
+
const leftIterator = ((coords.x - start.x) / (this._outerWidth - this._thumbWidth)) *
|
|
185
141
|
scrollLine;
|
|
186
|
-
|
|
142
|
+
const topIterator = ((coords.y - start.y) / (this._outerHeight - this._thumbHeight)) *
|
|
187
143
|
scrollLine;
|
|
188
144
|
// calculate new scroll values
|
|
189
|
-
|
|
145
|
+
let { scrollLeft, scrollTop } = this._coordsAtDragStart;
|
|
190
146
|
if (this.isHorizontal) {
|
|
191
147
|
scrollLeft += leftIterator;
|
|
192
148
|
}
|
|
@@ -201,34 +157,34 @@ var Bar = /** @class */ (function () {
|
|
|
201
157
|
? this.props.scrollBehavior
|
|
202
158
|
: 'auto',
|
|
203
159
|
});
|
|
204
|
-
}
|
|
160
|
+
}
|
|
205
161
|
/** Render thumb */
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
162
|
+
_renderThumb() {
|
|
163
|
+
const progress = clamp(this._prevScrollValue / this.scrollLine, [0, 1]);
|
|
164
|
+
const x = this.isHorizontal
|
|
209
165
|
? (this._outerWidth - this._thumbWidth) * progress
|
|
210
166
|
: 0;
|
|
211
|
-
|
|
167
|
+
const y = this.isVertical
|
|
212
168
|
? (this._outerHeight - this._thumbHeight) * progress
|
|
213
169
|
: 0;
|
|
214
|
-
this._thumb.style.transform =
|
|
215
|
-
}
|
|
170
|
+
this._thumb.style.transform = `translate(${x}px, ${y}px)`;
|
|
171
|
+
}
|
|
216
172
|
/** Resize the scene */
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
173
|
+
resize() {
|
|
174
|
+
const { outer, thumb, scrollLine, scrollWidth, scrollHeight, isHorizontal, } = this;
|
|
175
|
+
const { minSize, hasAutoSize } = this.props;
|
|
220
176
|
// get outer sizes
|
|
221
177
|
this._outerHeight = outer.clientHeight;
|
|
222
178
|
this._outerWidth = outer.clientWidth;
|
|
223
179
|
// calculate thumb sizes
|
|
224
180
|
if (hasAutoSize) {
|
|
225
181
|
if (isHorizontal) {
|
|
226
|
-
|
|
227
|
-
thumb.style.width =
|
|
182
|
+
const barSize = clamp(this._outerWidth / (scrollWidth / (scrollWidth - scrollLine)), [minSize, Infinity]);
|
|
183
|
+
thumb.style.width = `${barSize}px`;
|
|
228
184
|
}
|
|
229
185
|
else {
|
|
230
|
-
|
|
231
|
-
thumb.style.height =
|
|
186
|
+
const barSize = clamp(this._outerHeight / (scrollHeight / (scrollHeight - scrollLine)), [minSize, Infinity]);
|
|
187
|
+
thumb.style.height = `${barSize}px`;
|
|
232
188
|
}
|
|
233
189
|
}
|
|
234
190
|
// get thumb sizes
|
|
@@ -238,15 +194,13 @@ var Bar = /** @class */ (function () {
|
|
|
238
194
|
outer.classList.toggle(this.className('_is-empty'), scrollLine === 0);
|
|
239
195
|
// render elements
|
|
240
196
|
this._renderThumb();
|
|
241
|
-
}
|
|
242
|
-
|
|
197
|
+
}
|
|
198
|
+
destroy() {
|
|
243
199
|
this._removeEvents();
|
|
244
200
|
if (this._actionTimeout) {
|
|
245
201
|
clearTimeout(this._actionTimeout);
|
|
246
202
|
}
|
|
247
203
|
this._outer.remove();
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
}());
|
|
251
|
-
export default Bar;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
252
206
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/ScrollBar/Bar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAA8B,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/ScrollBar/Bar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAA8B,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,CAAC,OAAO,OAAO,GAAG;IAGtB,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAID,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,KAAK,GAAG,CAAC;IACtC,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;IAC5B,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,YAAY,MAAM;YAC3C,CAAC,CAAC,QAAQ,CAAC,eAAe;YAC1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,CAAC,CAAC,CAAC;QAEtE,kBAAkB;QAClB,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,aAAa,EAAE,CAAC;QAErB,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;SACnC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __assign = (this && this.__assign) || function () {
|
|
17
|
-
__assign = Object.assign || function(t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
-
t[p] = s[p];
|
|
22
|
-
}
|
|
23
|
-
return t;
|
|
24
|
-
};
|
|
25
|
-
return __assign.apply(this, arguments);
|
|
26
|
-
};
|
|
27
1
|
import { selectOne } from 'vevet-dom';
|
|
28
2
|
import Bar from './Bar';
|
|
29
3
|
import { Component as ComponentClass } from '../../base/Component';
|
|
@@ -31,135 +5,113 @@ import { onResize } from '../../utils/internal/onResize';
|
|
|
31
5
|
/**
|
|
32
6
|
* Create custom scroll bar
|
|
33
7
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
8
|
+
export class ScrollBar extends ComponentClass {
|
|
9
|
+
_getDefaultProps() {
|
|
10
|
+
return Object.assign(Object.assign({}, super._getDefaultProps()), { container: window, domParent: false, resizeDebounce: 16, isDraggable: true, hasAutoSize: true, canAutoHide: true, minSize: 50, scrollBehavior: 'smooth' });
|
|
11
|
+
}
|
|
12
|
+
get prefix() {
|
|
13
|
+
return `${this.app.prefix}scrollbar`;
|
|
14
|
+
}
|
|
15
|
+
/** Scroll container */
|
|
16
|
+
get container() {
|
|
17
|
+
return this._container;
|
|
18
|
+
}
|
|
19
|
+
/** Scrollable element */
|
|
20
|
+
get scrollableElement() {
|
|
21
|
+
const { container } = this;
|
|
22
|
+
if (container instanceof Window) {
|
|
23
|
+
return this.app.body;
|
|
24
|
+
}
|
|
25
|
+
if (container instanceof Element) {
|
|
26
|
+
return container;
|
|
27
|
+
}
|
|
28
|
+
return container.container;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The element where scrollbars will be appended
|
|
32
|
+
*/
|
|
33
|
+
get domParent() {
|
|
34
|
+
const { domParent } = this.props;
|
|
35
|
+
if (domParent) {
|
|
36
|
+
return domParent;
|
|
37
|
+
}
|
|
38
|
+
const { container } = this;
|
|
39
|
+
if (container instanceof Window) {
|
|
40
|
+
return this.app.body;
|
|
41
|
+
}
|
|
42
|
+
if (container instanceof Element) {
|
|
43
|
+
return container;
|
|
44
|
+
}
|
|
45
|
+
return container.container;
|
|
46
|
+
}
|
|
47
|
+
constructor(initialProps, canInit = true) {
|
|
48
|
+
super(initialProps, false);
|
|
49
|
+
const { container } = this.props;
|
|
40
50
|
// get container
|
|
41
51
|
if (typeof container === 'string') {
|
|
42
|
-
|
|
52
|
+
const element = selectOne(container);
|
|
43
53
|
if (element) {
|
|
44
|
-
|
|
54
|
+
this._container = element;
|
|
45
55
|
}
|
|
46
56
|
else {
|
|
47
57
|
throw new Error('No scroll container');
|
|
48
58
|
}
|
|
49
59
|
}
|
|
50
60
|
else {
|
|
51
|
-
|
|
61
|
+
this._container = container;
|
|
52
62
|
}
|
|
53
63
|
// create bars
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
const barProps = Object.assign(Object.assign({}, this.props), { container: this.container, domParent: this.domParent, prefix: this.prefix });
|
|
65
|
+
this._xBar = new Bar(Object.assign(Object.assign({}, barProps), { direction: 'x' }));
|
|
66
|
+
this._yBar = new Bar(Object.assign(Object.assign({}, barProps), { direction: 'y' }));
|
|
57
67
|
// add classnames
|
|
58
|
-
|
|
68
|
+
this.toggleClassName(this.scrollableElement, this.className('-parent'), true);
|
|
59
69
|
// initialize the class
|
|
60
70
|
if (canInit) {
|
|
61
|
-
|
|
71
|
+
this.init();
|
|
62
72
|
}
|
|
63
|
-
return _this;
|
|
64
73
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
68
|
-
Object.defineProperty(ScrollBar.prototype, "prefix", {
|
|
69
|
-
get: function () {
|
|
70
|
-
return "".concat(this.app.prefix, "scrollbar");
|
|
71
|
-
},
|
|
72
|
-
enumerable: false,
|
|
73
|
-
configurable: true
|
|
74
|
-
});
|
|
75
|
-
Object.defineProperty(ScrollBar.prototype, "container", {
|
|
76
|
-
/** Scroll container */
|
|
77
|
-
get: function () {
|
|
78
|
-
return this._container;
|
|
79
|
-
},
|
|
80
|
-
enumerable: false,
|
|
81
|
-
configurable: true
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(ScrollBar.prototype, "scrollableElement", {
|
|
84
|
-
/** Scrollable element */
|
|
85
|
-
get: function () {
|
|
86
|
-
var container = this.container;
|
|
87
|
-
if (container instanceof Window) {
|
|
88
|
-
return this.app.body;
|
|
89
|
-
}
|
|
90
|
-
if (container instanceof Element) {
|
|
91
|
-
return container;
|
|
92
|
-
}
|
|
93
|
-
return container.container;
|
|
94
|
-
},
|
|
95
|
-
enumerable: false,
|
|
96
|
-
configurable: true
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(ScrollBar.prototype, "domParent", {
|
|
99
|
-
/**
|
|
100
|
-
* The element where scrollbars will be appended
|
|
101
|
-
*/
|
|
102
|
-
get: function () {
|
|
103
|
-
var domParent = this.props.domParent;
|
|
104
|
-
if (domParent) {
|
|
105
|
-
return domParent;
|
|
106
|
-
}
|
|
107
|
-
var container = this.container;
|
|
108
|
-
if (container instanceof Window) {
|
|
109
|
-
return this.app.body;
|
|
110
|
-
}
|
|
111
|
-
if (container instanceof Element) {
|
|
112
|
-
return container;
|
|
113
|
-
}
|
|
114
|
-
return container.container;
|
|
115
|
-
},
|
|
116
|
-
enumerable: false,
|
|
117
|
-
configurable: true
|
|
118
|
-
});
|
|
119
|
-
ScrollBar.prototype._init = function () {
|
|
120
|
-
_super.prototype._init.call(this);
|
|
74
|
+
_init() {
|
|
75
|
+
super._init();
|
|
121
76
|
this._setEvents();
|
|
122
|
-
}
|
|
77
|
+
}
|
|
123
78
|
// Set Module Events
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
var _a = this, container = _a.container, props = _a.props;
|
|
79
|
+
_setEvents() {
|
|
80
|
+
const { container, props } = this;
|
|
127
81
|
// default resize handler
|
|
128
|
-
|
|
129
|
-
onResize:
|
|
82
|
+
const resizeHandler = onResize({
|
|
83
|
+
onResize: () => this.resize(),
|
|
130
84
|
element: [this._xBar.outer, this._yBar.outer],
|
|
131
85
|
viewportTarget: 'any',
|
|
132
86
|
hasBothEvents: true,
|
|
133
87
|
resizeDebounce: props.resizeDebounce,
|
|
134
88
|
});
|
|
135
89
|
// resize for smoothscroll
|
|
136
|
-
|
|
137
|
-
? container.addCallback('resize',
|
|
90
|
+
const smoothScrollResize = 'isSmoothScroll' in container
|
|
91
|
+
? container.addCallback('resize', () => resizeHandler.debounceResize(), { name: this.name })
|
|
138
92
|
: undefined;
|
|
139
|
-
this.addDestroyableAction(
|
|
93
|
+
this.addDestroyableAction(() => {
|
|
140
94
|
resizeHandler.remove();
|
|
141
95
|
smoothScrollResize === null || smoothScrollResize === void 0 ? void 0 : smoothScrollResize.remove();
|
|
142
96
|
});
|
|
143
97
|
// initial resize
|
|
144
98
|
resizeHandler.resize();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
99
|
+
}
|
|
100
|
+
_onPropsMutate() {
|
|
101
|
+
super._onPropsMutate();
|
|
148
102
|
this.resize();
|
|
149
|
-
}
|
|
103
|
+
}
|
|
150
104
|
/** Resize the scene */
|
|
151
|
-
|
|
105
|
+
resize() {
|
|
152
106
|
this._xBar.resize();
|
|
153
107
|
this._yBar.resize();
|
|
154
|
-
}
|
|
108
|
+
}
|
|
155
109
|
/** Destroy the module */
|
|
156
|
-
|
|
157
|
-
|
|
110
|
+
_destroy() {
|
|
111
|
+
super._destroy();
|
|
158
112
|
// destroy bars
|
|
159
113
|
this._xBar.destroy();
|
|
160
114
|
this._yBar.destroy();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
}(ComponentClass));
|
|
164
|
-
export { ScrollBar };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
165
117
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ScrollBar/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ScrollBar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB,OAAO,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAIrD;;G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