@creative-web-solution/front-library 6.1.3 → 6.2.9
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 +52 -1
- package/DOM/Class.js +1 -1
- package/DOM/OuterSize.js +1 -1
- package/DOM/matrix.js +1 -1
- package/DOM/size.js +1 -1
- package/DOM/wrap.js +2 -2
- package/Events/EventsManager.js +39 -81
- package/Events/HistoryController.js +3 -3
- package/Events/ImageLoad.js +1 -1
- package/Events/IntersectObserver.js +3 -2
- package/Events/KeyboardHandler.js +2 -2
- package/Events/MediaQueriesEvents.js +2 -2
- package/Events/TouchHover.js +3 -3
- package/Events/WindowEvents.js +3 -3
- package/Events/gesture.js +2 -2
- package/Events/onAnimationEnd.js +37 -33
- package/Events/onTransitionEnd.js +38 -29
- package/Events/pubSub.js +2 -2
- package/Helpers/Cookie.js +1 -1
- package/Helpers/TransitionHelpers.js +95 -0
- package/Helpers/extend.js +1 -1
- package/Helpers/getValue.js +1 -1
- package/Helpers/sequential.js +1 -1
- package/Helpers/wait.js +1 -1
- package/ModernizrAddons/css-var-support.js +3 -0
- package/ModernizrAddons/touchdevice.js +1 -1
- package/Modules/Accordion.js +12 -6
- package/Modules/Autocomplete.js +7 -7
- package/Modules/DragSlider.js +583 -0
- package/Modules/Notifications.js +8 -8
- package/Modules/Popin.js +8 -8
- package/Modules/ScrollSnap.js +8 -8
- package/Modules/SkinCheckbox.js +2 -2
- package/Modules/SkinFile.js +4 -4
- package/Modules/SkinRadio.js +3 -3
- package/Modules/SkinSelect.js +12 -12
- package/Modules/Slider.js +100 -32
- package/Modules/Tabs.js +5 -5
- package/Modules/Validator/Tools/RadioButton.js +1 -1
- package/Modules/Validator/Tools/ValidationState.js +1 -1
- package/Modules/Validator/Tools/getQueryFromForm.js +1 -1
- package/Modules/Validator/date.js +3 -3
- package/Modules/Validator/email.js +3 -3
- package/Modules/Validator/equals.js +3 -3
- package/Modules/Validator/index.js +6 -6
- package/Modules/Validator/max.js +2 -2
- package/Modules/Validator/maxlength.js +2 -2
- package/Modules/Validator/min.js +2 -2
- package/Modules/Validator/minlength.js +2 -2
- package/Modules/Validator/multiRequired.js +5 -5
- package/Modules/Validator/number.js +3 -3
- package/Modules/Validator/pattern.js +2 -2
- package/Modules/Validator/recaptcha.js +2 -2
- package/Modules/Validator/required.js +4 -4
- package/Modules/Validator/serverCheck.js +3 -3
- package/Modules/Validator/url.js +3 -3
- package/Modules/YouTubePlayer.js +2 -2
- package/Modules/globalState.js +1 -1
- package/README.md +3 -3
- package/Tools/PrefixedProperties.js +54 -0
- package/Tools/TouchDeviceSupport.js +1 -0
- package/WebGL/GLImageTransition/GLImageTransition.js +4 -4
- package/documentation/extra/events.md +2 -2
- package/documentation/extra/modernizr.md +1 -0
- package/documentation/extra/modules/DragSlider.md +111 -0
- package/documentation/extra/modules/YouTubePlayer.md +1 -1
- package/documentation/extra/modules/autocomplete.md +1 -1
- package/documentation/extra/modules/popin.md +3 -3
- package/documentation/extra/modules/slider.md +7 -3
- package/documentation/extra/modules/template.md +1 -1
- package/documentation/extra/modules/validator.md +13 -13
- package/documentation/extra/webgl/GLImageTransition.md +1 -1
- package/documentation/jsdocs/dom/global.html +389 -2
- package/documentation/jsdocs/dom/index.html +2 -2
- package/documentation/jsdocs/dom/quicksearch.html +1 -1
- package/documentation/jsdocs/events/common/DeviceOrientation.html +1 -1
- package/documentation/jsdocs/events/common/HistoryController.html +1 -1
- package/documentation/jsdocs/events/common/IntersectObserver.html +1 -1
- package/documentation/jsdocs/events/common/KeyboardHandler.html +1 -1
- package/documentation/jsdocs/events/common/MediaQueriesEvents.html +1 -1
- package/documentation/jsdocs/events/common/TouchHover.html +1 -1
- package/documentation/jsdocs/events/common/WindowEvents.html +1 -1
- package/documentation/jsdocs/events/common/classes.list.html +1 -1
- package/documentation/jsdocs/events/common/global.html +1 -1
- package/documentation/jsdocs/events/common/index.html +1 -1
- package/documentation/jsdocs/events/common/namespaces.list.html +1 -1
- package/documentation/jsdocs/events/common/pubSub.html +1 -1
- package/documentation/jsdocs/events/common/quicksearch.html +1 -1
- package/documentation/jsdocs/events/events-manager/global.html +1 -1
- package/documentation/jsdocs/events/events-manager/index.html +1 -1
- package/documentation/jsdocs/events/events-manager/quicksearch.html +1 -1
- package/documentation/jsdocs/events/gesture/global.html +1 -1
- package/documentation/jsdocs/events/gesture/index.html +1 -1
- package/documentation/jsdocs/events/gesture/quicksearch.html +1 -1
- package/documentation/jsdocs/helpers/array/global.html +1 -1
- package/documentation/jsdocs/helpers/array/index.html +1 -1
- package/documentation/jsdocs/helpers/array/quicksearch.html +1 -1
- package/documentation/jsdocs/helpers/colors/global.html +1 -1
- package/documentation/jsdocs/helpers/colors/index.html +1 -1
- package/documentation/jsdocs/helpers/colors/quicksearch.html +1 -1
- package/documentation/jsdocs/helpers/common/Cookie.html +2 -2
- package/documentation/jsdocs/helpers/common/UrlParser.html +1 -1
- package/documentation/jsdocs/helpers/common/classes.list.html +1 -1
- package/documentation/jsdocs/helpers/common/global.html +8 -2
- package/documentation/jsdocs/helpers/common/index.html +1 -1
- package/documentation/jsdocs/helpers/common/quicksearch.html +1 -1
- package/documentation/jsdocs/helpers/types/global.html +1 -1
- package/documentation/jsdocs/helpers/types/index.html +1 -1
- package/documentation/jsdocs/helpers/types/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/accordion/Accordion.html +1 -1
- package/documentation/jsdocs/modules/accordion/classes.list.html +1 -1
- package/documentation/jsdocs/modules/accordion/index.html +1 -1
- package/documentation/jsdocs/modules/accordion/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/autocomplete/Autocomplete.html +1 -1
- package/documentation/jsdocs/modules/autocomplete/classes.list.html +1 -1
- package/documentation/jsdocs/modules/autocomplete/index.html +1 -1
- package/documentation/jsdocs/modules/autocomplete/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/common/DragSlider.html +946 -0
- package/documentation/jsdocs/modules/common/classes.list.html +310 -0
- package/documentation/jsdocs/modules/common/global.html +8 -1
- package/documentation/jsdocs/modules/common/globalState.html +8 -1
- package/documentation/jsdocs/modules/common/index.html +8 -1
- package/documentation/jsdocs/modules/common/namespaces.list.html +15 -1
- package/documentation/jsdocs/modules/common/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/form-skin/SkinCheckbox.html +1 -1
- package/documentation/jsdocs/modules/form-skin/SkinFile.html +1 -1
- package/documentation/jsdocs/modules/form-skin/SkinRadio.html +1 -1
- package/documentation/jsdocs/modules/form-skin/SkinSelect.html +1 -1
- package/documentation/jsdocs/modules/form-skin/classes.list.html +1 -1
- package/documentation/jsdocs/modules/form-skin/global.html +1 -1
- package/documentation/jsdocs/modules/form-skin/index.html +1 -1
- package/documentation/jsdocs/modules/form-skin/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/media-preloader/MediaPreloader.html +1 -1
- package/documentation/jsdocs/modules/media-preloader/classes.list.html +1 -1
- package/documentation/jsdocs/modules/media-preloader/index.html +1 -1
- package/documentation/jsdocs/modules/media-preloader/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/notifications/Notifications.html +1 -1
- package/documentation/jsdocs/modules/notifications/classes.list.html +1 -1
- package/documentation/jsdocs/modules/notifications/index.html +1 -1
- package/documentation/jsdocs/modules/notifications/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/popin/Popin.html +1 -1
- package/documentation/jsdocs/modules/popin/PopinController.html +1 -1
- package/documentation/jsdocs/modules/popin/classes.list.html +1 -1
- package/documentation/jsdocs/modules/popin/index.html +1 -1
- package/documentation/jsdocs/modules/popin/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/scroll-snap/ScrollSnap.html +1 -1
- package/documentation/jsdocs/modules/scroll-snap/classes.list.html +1 -1
- package/documentation/jsdocs/modules/scroll-snap/index.html +1 -1
- package/documentation/jsdocs/modules/scroll-snap/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/slider/Slider.html +1 -1
- package/documentation/jsdocs/modules/slider/SliderControls.html +159 -2
- package/documentation/jsdocs/modules/slider/classes.list.html +1 -1
- package/documentation/jsdocs/modules/slider/index.html +1 -1
- package/documentation/jsdocs/modules/slider/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/tabs/Tabs.html +1 -1
- package/documentation/jsdocs/modules/tabs/classes.list.html +1 -1
- package/documentation/jsdocs/modules/tabs/index.html +1 -1
- package/documentation/jsdocs/modules/tabs/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/validator/Validator.html +1 -1
- package/documentation/jsdocs/modules/validator/classes.list.html +1 -1
- package/documentation/jsdocs/modules/validator/global.html +1 -1
- package/documentation/jsdocs/modules/validator/index.html +1 -1
- package/documentation/jsdocs/modules/validator/quicksearch.html +1 -1
- package/documentation/jsdocs/modules/youtube-player/YouTubePlayer.html +1 -1
- package/documentation/jsdocs/modules/youtube-player/classes.list.html +1 -1
- package/documentation/jsdocs/modules/youtube-player/index.html +1 -1
- package/documentation/jsdocs/modules/youtube-player/quicksearch.html +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
import { wait } from '@creative-web-solution/front-library/Helpers/wait';
|
|
2
|
+
import { debounce } from '@creative-web-solution/front-library/Helpers/debounce';
|
|
3
|
+
import { offset } from '@creative-web-solution/front-library/DOM/offset';
|
|
4
|
+
import { gesture, gestureOff } from '@creative-web-solution/front-library/Events/Gesture';
|
|
5
|
+
import { prop } from '@creative-web-solution/front-library/DOM/Styles';
|
|
6
|
+
import { aClass, rClass, tClass } from '@creative-web-solution/front-library/DOM/Class';
|
|
7
|
+
import { on, off } from '@creative-web-solution/front-library/Events/EventsManager';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* DragSlider
|
|
12
|
+
* @class
|
|
13
|
+
*
|
|
14
|
+
* @param {HTMLElement} $slider
|
|
15
|
+
* @param {Object} options
|
|
16
|
+
* @param {String} options.viewportSelector
|
|
17
|
+
* @param {String} options.listSelector
|
|
18
|
+
* @param {String} options.itemSelector
|
|
19
|
+
* @param {String} options.dragClass
|
|
20
|
+
* @param {String} [options.lockedClass="is-locked"]
|
|
21
|
+
* @param {Function} [options.onStartDrag]
|
|
22
|
+
* @param {Function} [options.onDrag]
|
|
23
|
+
* @param {Function} [options.onStopDrag]
|
|
24
|
+
* @param {Function} [options.onSnap]
|
|
25
|
+
* @param {Function} [options.onSnapUpdate]
|
|
26
|
+
* @param {Function} [options.onMouseEnter]
|
|
27
|
+
* @param {Function} [options.onMouseLeave]
|
|
28
|
+
* @param {Function} [options.onInit]
|
|
29
|
+
* @param {Function} [options.onChangeState]
|
|
30
|
+
* @param {Number} [options.swipeTresholdMin=40] - in px
|
|
31
|
+
* @param {Number} [options.swipeTresholdSize=0.5] - in % (0.5 = 50% of the size of one item)
|
|
32
|
+
*/
|
|
33
|
+
export function DragSlider( $slider, options ) {
|
|
34
|
+
let itemMap, itemArray, listDelta, viewportInfo,
|
|
35
|
+
$items, $list, $viewport, startDragCoords, deltaMove,
|
|
36
|
+
currentSnapItem, firstItem,
|
|
37
|
+
siteOffset,
|
|
38
|
+
debouncedOnResize, isInitialized, hasAlreadyBeenDragged,
|
|
39
|
+
isDragging, isDraggingActive;
|
|
40
|
+
|
|
41
|
+
deltaMove = {
|
|
42
|
+
"x": 0
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
isDraggingActive = false;
|
|
46
|
+
|
|
47
|
+
options.swipeTresholdMin = options.swipeTresholdMin || 40;
|
|
48
|
+
options.swipeTresholdSize = options.swipeTresholdSize || 0.5;
|
|
49
|
+
options.lockedClass = options.lockedClass || 'is-locked';
|
|
50
|
+
|
|
51
|
+
itemArray = [];
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
Object.defineProperty( this, 'isActive', {
|
|
55
|
+
"get": () => isDraggingActive
|
|
56
|
+
} );
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
function cancelLinkClick() {
|
|
60
|
+
aClass( $slider, options.dragClass );
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
function activeLinkClick() {
|
|
65
|
+
wait().then( () => {
|
|
66
|
+
rClass( $slider, options.dragClass );
|
|
67
|
+
} );
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
function onResize() {
|
|
72
|
+
viewportInfo = offset( $viewport );
|
|
73
|
+
siteOffset = parseInt( prop( $items[ 0 ], 'marginLeft' ), 10 );
|
|
74
|
+
listDelta = viewportInfo.width - $list.scrollWidth;
|
|
75
|
+
|
|
76
|
+
const prevIsDraggingActive = isDraggingActive;
|
|
77
|
+
isDraggingActive = listDelta < 0;
|
|
78
|
+
|
|
79
|
+
if ( !isDraggingActive ) {
|
|
80
|
+
isDragging = false;
|
|
81
|
+
gsap.killTweensOf( $list );
|
|
82
|
+
gsap.set( $list, {
|
|
83
|
+
"x": 0,
|
|
84
|
+
"y": 0,
|
|
85
|
+
"z": 0
|
|
86
|
+
} );
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
tClass( $slider, options.lockedClass, !isDraggingActive );
|
|
90
|
+
|
|
91
|
+
if ( prevIsDraggingActive !== isDraggingActive ) {
|
|
92
|
+
options.onChangeState?.( isDraggingActive );
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
itemArray.length = 0;
|
|
96
|
+
|
|
97
|
+
$items.forEach( ( $item, index ) => {
|
|
98
|
+
const ITEM_OFFSET = offset( $item, false, $list );
|
|
99
|
+
|
|
100
|
+
itemArray.push({
|
|
101
|
+
index,
|
|
102
|
+
"isFirst": index === 0,
|
|
103
|
+
"isLast": index === $items.length - 1 || ITEM_OFFSET.left > Math.abs( listDelta ),
|
|
104
|
+
$item,
|
|
105
|
+
"info": ITEM_OFFSET
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
itemMap.set( $item, itemArray[ index ] );
|
|
109
|
+
} );
|
|
110
|
+
|
|
111
|
+
firstItem = itemMap.get( $items[ 0 ] );
|
|
112
|
+
|
|
113
|
+
if ( !currentSnapItem ) {
|
|
114
|
+
currentSnapItem = firstItem;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
currentSnapItem = itemArray[ currentSnapItem.index ];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
function snapToItemAnimation( snapItem, snapToEnd ) {
|
|
123
|
+
let finalX;
|
|
124
|
+
|
|
125
|
+
if ( snapToEnd ) {
|
|
126
|
+
finalX = listDelta;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
finalX = -1 * snapItem.info.left + siteOffset;
|
|
130
|
+
|
|
131
|
+
finalX = Math.max( Math.min( 0, finalX ), listDelta );
|
|
132
|
+
|
|
133
|
+
// If close to the end, then snap to it
|
|
134
|
+
if ( Math.abs( finalX - listDelta ) <= 3 ) {
|
|
135
|
+
finalX = listDelta;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const IS_SNAP_TO_END = finalX === listDelta;
|
|
140
|
+
const IS_SNAP_TO_START = finalX === 0;
|
|
141
|
+
|
|
142
|
+
options.onSnap?.( {
|
|
143
|
+
"item": snapItem,
|
|
144
|
+
"xPos": deltaMove.x,
|
|
145
|
+
"moveMaxSize": listDelta,
|
|
146
|
+
"isAtStart": IS_SNAP_TO_START,
|
|
147
|
+
"isAtEnd": IS_SNAP_TO_END
|
|
148
|
+
} );
|
|
149
|
+
|
|
150
|
+
gsap.to( $list, {
|
|
151
|
+
"duration": 0.3,
|
|
152
|
+
"x": finalX,
|
|
153
|
+
"y": 0,
|
|
154
|
+
"z": 0,
|
|
155
|
+
"onUpdate": function() {
|
|
156
|
+
deltaMove.x = gsap.getProperty( this.targets()[ 0 ], 'x' );
|
|
157
|
+
|
|
158
|
+
options.onSnapUpdate?.( {
|
|
159
|
+
"item": snapItem,
|
|
160
|
+
"xPos": deltaMove.x,
|
|
161
|
+
"moveMaxSize": listDelta,
|
|
162
|
+
"isAtStart": IS_SNAP_TO_START,
|
|
163
|
+
"isAtEnd": IS_SNAP_TO_END
|
|
164
|
+
} );
|
|
165
|
+
}
|
|
166
|
+
} );
|
|
167
|
+
|
|
168
|
+
currentSnapItem = snapItem;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
function getFirstPreviousItem( xPos ) {
|
|
173
|
+
let snapItem;
|
|
174
|
+
|
|
175
|
+
const absXPos = Math.abs( xPos );
|
|
176
|
+
|
|
177
|
+
for ( const item of itemArray ) {
|
|
178
|
+
if ( item.info.left <= absXPos ) {
|
|
179
|
+
snapItem = item;
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
snapItem,
|
|
187
|
+
"snapToEnd": false
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
function getFirstNextItem( xPos ) {
|
|
193
|
+
let lastDelta, snapItem, snapToEnd;
|
|
194
|
+
|
|
195
|
+
const absXPos = Math.abs( xPos );
|
|
196
|
+
|
|
197
|
+
for ( const item of itemArray ) {
|
|
198
|
+
if ( item.info.left < absXPos ) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
lastDelta = Math.abs( absXPos - item.info.left );
|
|
203
|
+
snapItem = item;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const lastItem = itemArray[ itemArray.length - 1 ];
|
|
208
|
+
|
|
209
|
+
if ( !snapItem.isLast &&
|
|
210
|
+
Math.abs( absXPos + viewportInfo.width - ( lastItem.info.left + lastItem.info.width ) ) < lastDelta
|
|
211
|
+
) {
|
|
212
|
+
snapItem = lastItem;
|
|
213
|
+
snapToEnd = true;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
snapItem,
|
|
218
|
+
snapToEnd
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
function getClosestItem( xPos ) {
|
|
224
|
+
let lastDelta, snapItem, snapToEnd;
|
|
225
|
+
|
|
226
|
+
const absXPos = Math.abs( xPos );
|
|
227
|
+
|
|
228
|
+
for ( const item of itemArray ) {
|
|
229
|
+
const IS_LAST_DELTA = typeof lastDelta !== 'undefined';
|
|
230
|
+
let newDelta = Math.abs( absXPos - item.info.left );
|
|
231
|
+
|
|
232
|
+
if ( !IS_LAST_DELTA || newDelta < lastDelta ) {
|
|
233
|
+
lastDelta = newDelta;
|
|
234
|
+
snapItem = item;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if ( !IS_LAST_DELTA ) {
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if ( !snapItem.isLast && item.index === itemMap.size - 1 ) {
|
|
242
|
+
newDelta = Math.abs( Math.abs( deltaMove.x ) + viewportInfo.width - ( item.info.left + item.info.width ) );
|
|
243
|
+
|
|
244
|
+
if ( newDelta < lastDelta ) {
|
|
245
|
+
lastDelta = newDelta;
|
|
246
|
+
snapItem = item;
|
|
247
|
+
snapToEnd = true;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
snapItem,
|
|
254
|
+
snapToEnd
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
function snapToItem() {
|
|
260
|
+
let snapItem;
|
|
261
|
+
|
|
262
|
+
const ABS_DELTA_X = Math.abs( deltaMove.deltaX );
|
|
263
|
+
|
|
264
|
+
if ( ABS_DELTA_X >= options.swipeTresholdMin && ABS_DELTA_X < Math.min( firstItem.info.width * options.swipeTresholdSize, options.swipeTresholdMin * 3 ) ) {
|
|
265
|
+
if ( deltaMove.deltaX < 0 ) {
|
|
266
|
+
snapItem = getFirstNextItem( deltaMove.x );
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
snapItem = getFirstPreviousItem( deltaMove.x );
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
snapItem = getClosestItem( deltaMove.x );
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if ( !snapItem ) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
snapToItemAnimation( snapItem.snapItem, snapItem.snapToEnd );
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
function onStartDrag( e, $target, coords ) {
|
|
285
|
+
if ( !hasAlreadyBeenDragged ) {
|
|
286
|
+
onResize();
|
|
287
|
+
hasAlreadyBeenDragged = true;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if ( !isDraggingActive ) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
isDragging = true;
|
|
295
|
+
|
|
296
|
+
gsap.killTweensOf( $list );
|
|
297
|
+
|
|
298
|
+
startDragCoords = coords;
|
|
299
|
+
listDelta = viewportInfo.width - $list.scrollWidth;
|
|
300
|
+
|
|
301
|
+
gesture( document.body, 'dragSlider', {
|
|
302
|
+
"move": onMove,
|
|
303
|
+
"end": onStopDrag,
|
|
304
|
+
"preventMove": function( e ) {
|
|
305
|
+
if ( !e.cancelable ) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return !Modernizr.touchdevice ||
|
|
310
|
+
Modernizr.touchdevice && Math.abs( deltaMove.deltaY ) < Math.abs( deltaMove.deltaX );
|
|
311
|
+
}
|
|
312
|
+
} );
|
|
313
|
+
|
|
314
|
+
options.onStartDrag?.( {
|
|
315
|
+
"item": currentSnapItem,
|
|
316
|
+
"xPos": deltaMove.x,
|
|
317
|
+
"moveMaxSize": listDelta,
|
|
318
|
+
"isAtStart": deltaMove.x === 0,
|
|
319
|
+
"isAtEnd": deltaMove.x === listDelta
|
|
320
|
+
} );
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
function onMove( e, $target, coords ) {
|
|
325
|
+
cancelLinkClick();
|
|
326
|
+
|
|
327
|
+
deltaMove.deltaX = coords.pageX - startDragCoords.pageX;
|
|
328
|
+
deltaMove.deltaY = coords.pageY - startDragCoords.pageY;
|
|
329
|
+
|
|
330
|
+
deltaMove.newX = deltaMove.deltaX + deltaMove.x;
|
|
331
|
+
|
|
332
|
+
if ( deltaMove.newX > 0 ) {
|
|
333
|
+
deltaMove.newX = 0;
|
|
334
|
+
}
|
|
335
|
+
else if ( deltaMove.newX < listDelta ) {
|
|
336
|
+
deltaMove.newX = listDelta;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
gsap.set( $list, {
|
|
340
|
+
"x": deltaMove.newX,
|
|
341
|
+
"y": 0,
|
|
342
|
+
"z": 0
|
|
343
|
+
} );
|
|
344
|
+
|
|
345
|
+
options.onDrag?.( {
|
|
346
|
+
"item": currentSnapItem,
|
|
347
|
+
"xPos": deltaMove.newX,
|
|
348
|
+
"moveMaxSize": listDelta,
|
|
349
|
+
"isAtStart": deltaMove.newX === 0,
|
|
350
|
+
"isAtEnd": deltaMove.newX === listDelta
|
|
351
|
+
} );
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
function onStopDrag() {
|
|
356
|
+
gestureOff( document.body, 'dragSlider', {
|
|
357
|
+
"move": onMove,
|
|
358
|
+
"end": onStopDrag
|
|
359
|
+
} );
|
|
360
|
+
|
|
361
|
+
isDragging = false;
|
|
362
|
+
|
|
363
|
+
deltaMove.x = deltaMove.newX;
|
|
364
|
+
|
|
365
|
+
activeLinkClick();
|
|
366
|
+
|
|
367
|
+
snapToItem();
|
|
368
|
+
|
|
369
|
+
options.onStopDrag?.({
|
|
370
|
+
"item": currentSnapItem,
|
|
371
|
+
"xPos": deltaMove.x,
|
|
372
|
+
"moveMaxSize": listDelta,
|
|
373
|
+
"isAtStart": deltaMove.x === 0,
|
|
374
|
+
"isAtEnd": deltaMove.x === listDelta
|
|
375
|
+
} );
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
function onMouseenter() {
|
|
380
|
+
if ( isDragging || !isDraggingActive ) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
options.onMouseEnter?.( {
|
|
385
|
+
"item": currentSnapItem,
|
|
386
|
+
"xPos": deltaMove.x,
|
|
387
|
+
"moveMaxSize": listDelta,
|
|
388
|
+
"isAtStart": deltaMove.x === 0,
|
|
389
|
+
"isAtEnd": deltaMove.x === listDelta
|
|
390
|
+
} );
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
function onMouseleave() {
|
|
395
|
+
if ( isDragging || !isDraggingActive ) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
options.onMouseLeave?.( {
|
|
400
|
+
"item": currentSnapItem,
|
|
401
|
+
"xPos": deltaMove.x,
|
|
402
|
+
"moveMaxSize": listDelta,
|
|
403
|
+
"isAtStart": deltaMove.x === 0,
|
|
404
|
+
"isAtEnd": deltaMove.x === listDelta
|
|
405
|
+
} );
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
function cancelDrag( e ) {
|
|
410
|
+
e.preventDefault();
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
this.next = () => {
|
|
415
|
+
if ( !isDraggingActive || currentSnapItem.isLast ) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
snapToItemAnimation( itemArray[ currentSnapItem.index + 1 ] );
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
this.previous = () => {
|
|
424
|
+
if ( !isDraggingActive || currentSnapItem.isFirst ) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
snapToItemAnimation( itemArray[ currentSnapItem.index - 1 ] );
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
this.goToItem = $block => {
|
|
433
|
+
|
|
434
|
+
if ( !isDraggingActive ) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const ITEM = itemMap.get( $block );
|
|
439
|
+
|
|
440
|
+
if ( !ITEM ) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
options.onSnap?.( {
|
|
445
|
+
"item": ITEM,
|
|
446
|
+
"xPos": deltaMove.x,
|
|
447
|
+
"moveMaxSize": listDelta,
|
|
448
|
+
"isAtStart": deltaMove.x === 0,
|
|
449
|
+
"isAtEnd": deltaMove.x === listDelta
|
|
450
|
+
} );
|
|
451
|
+
|
|
452
|
+
gsap.to( $list, {
|
|
453
|
+
"duration": 0.3,
|
|
454
|
+
"x": -1 * ITEM.info.left + siteOffset,
|
|
455
|
+
"y": 0,
|
|
456
|
+
"z": 0,
|
|
457
|
+
"onUpdate": function() {
|
|
458
|
+
deltaMove.x = gsap.getProperty( this.targets()[ 0 ], 'x' );
|
|
459
|
+
|
|
460
|
+
options.onSnapUpdate?.( {
|
|
461
|
+
"item": ITEM,
|
|
462
|
+
"xPos": deltaMove.x,
|
|
463
|
+
"moveMaxSize": listDelta,
|
|
464
|
+
"isAtStart": deltaMove.x === 0,
|
|
465
|
+
"isAtEnd": deltaMove.x === listDelta
|
|
466
|
+
} );
|
|
467
|
+
}
|
|
468
|
+
} );
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
this.init = () => {
|
|
473
|
+
if ( isInitialized ) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
isInitialized = true;
|
|
478
|
+
|
|
479
|
+
if ( !$viewport ) {
|
|
480
|
+
itemMap = new Map();
|
|
481
|
+
|
|
482
|
+
$viewport = $slider.querySelector( options.viewportSelector );
|
|
483
|
+
$list = $viewport.querySelector( options.listSelector );
|
|
484
|
+
$items = $list.querySelectorAll( options.itemSelector );
|
|
485
|
+
debouncedOnResize = debounce( onResize );
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if ( !$items.length ) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
onResize();
|
|
493
|
+
|
|
494
|
+
on( window, {
|
|
495
|
+
"eventsName": "resize",
|
|
496
|
+
"callback": debouncedOnResize
|
|
497
|
+
} );
|
|
498
|
+
|
|
499
|
+
gesture( $viewport, 'dragSlider', {
|
|
500
|
+
"start": onStartDrag
|
|
501
|
+
} );
|
|
502
|
+
|
|
503
|
+
// Avoid image or content drag on Firefox
|
|
504
|
+
on( $items, {
|
|
505
|
+
"eventsName": "dragstart",
|
|
506
|
+
"callback": cancelDrag
|
|
507
|
+
} );
|
|
508
|
+
|
|
509
|
+
on( $viewport, {
|
|
510
|
+
"eventsName": "mouseenter",
|
|
511
|
+
"callback": onMouseenter
|
|
512
|
+
} );
|
|
513
|
+
|
|
514
|
+
on( $viewport, {
|
|
515
|
+
"eventsName": "mouseleave",
|
|
516
|
+
"callback": onMouseleave
|
|
517
|
+
} );
|
|
518
|
+
|
|
519
|
+
options.onInit?.( {
|
|
520
|
+
"item": currentSnapItem,
|
|
521
|
+
"xPos": deltaMove.x,
|
|
522
|
+
"moveMaxSize": listDelta,
|
|
523
|
+
"isAtStart": deltaMove.x === 0,
|
|
524
|
+
"isAtEnd": deltaMove.x === listDelta
|
|
525
|
+
} );
|
|
526
|
+
|
|
527
|
+
aClass( $slider, 'is-active' );
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
this.destroy = () => {
|
|
532
|
+
|
|
533
|
+
isInitialized = false;
|
|
534
|
+
hasAlreadyBeenDragged = false;
|
|
535
|
+
|
|
536
|
+
if ( !$items.length ) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
off( window, {
|
|
541
|
+
"eventsName": "resize",
|
|
542
|
+
"callback": debouncedOnResize
|
|
543
|
+
} );
|
|
544
|
+
|
|
545
|
+
gestureOff( $viewport, 'dragSlider', {
|
|
546
|
+
"start": onStartDrag
|
|
547
|
+
} );
|
|
548
|
+
|
|
549
|
+
gestureOff( document.body, 'dragSlider', {
|
|
550
|
+
"move": onMove,
|
|
551
|
+
"end": onStopDrag
|
|
552
|
+
} );
|
|
553
|
+
|
|
554
|
+
off( $items, {
|
|
555
|
+
"eventsName": "dragstart",
|
|
556
|
+
"callback": cancelDrag
|
|
557
|
+
} );
|
|
558
|
+
|
|
559
|
+
off( $viewport, {
|
|
560
|
+
"eventsName": "mouseenter",
|
|
561
|
+
"callback": onMouseenter
|
|
562
|
+
} );
|
|
563
|
+
|
|
564
|
+
off( $viewport, {
|
|
565
|
+
"eventsName": "mouseleave",
|
|
566
|
+
"callback": onMouseleave
|
|
567
|
+
} );
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
gsap.killTweensOf( $list );
|
|
571
|
+
|
|
572
|
+
gsap.set( $list, {
|
|
573
|
+
"clearProps": "all"
|
|
574
|
+
} );
|
|
575
|
+
|
|
576
|
+
rClass( $viewport, options.dragClass );
|
|
577
|
+
|
|
578
|
+
rClass( $slider, 'is-active' );
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
wait( 'idle' ).then( this.init );
|
|
583
|
+
}
|
package/Modules/Notifications.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { extend } from "front-library/Helpers/Extend";
|
|
2
|
-
import { strToDOM } from "front-library/DOM/strToDOM";
|
|
3
|
-
import { slice } from "front-library/Helpers/slice";
|
|
4
|
-
import { aClass, rClass } from "front-library/DOM/Class";
|
|
5
|
-
import { append, remove } from "front-library/DOM/Manipulation";
|
|
6
|
-
import { one, off } from "front-library/Events/EventsManager";
|
|
7
|
-
import { wait } from "front-library/Helpers/wait";
|
|
8
|
-
import { onTransitionEnd } from "front-library/Events/onTransitionEnd";
|
|
1
|
+
import { extend } from "@creative-web-solution/front-library/Helpers/Extend";
|
|
2
|
+
import { strToDOM } from "@creative-web-solution/front-library/DOM/strToDOM";
|
|
3
|
+
import { slice } from "@creative-web-solution/front-library/Helpers/slice";
|
|
4
|
+
import { aClass, rClass } from "@creative-web-solution/front-library/DOM/Class";
|
|
5
|
+
import { append, remove } from "@creative-web-solution/front-library/DOM/Manipulation";
|
|
6
|
+
import { one, off } from "@creative-web-solution/front-library/Events/EventsManager";
|
|
7
|
+
import { wait } from "@creative-web-solution/front-library/Helpers/wait";
|
|
8
|
+
import { onTransitionEnd } from "@creative-web-solution/front-library/Events/onTransitionEnd";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
const DEFAULT_OPTIONS = {
|
package/Modules/Popin.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { on, off } from 'front-library/Events/EventsManager';
|
|
2
|
-
import { KeyboardHandler } from 'front-library/Events/KeyboardHandler';
|
|
3
|
-
import { extend } from 'front-library/Helpers/Extend';
|
|
4
|
-
import { defer } from 'front-library/Helpers/defer';
|
|
5
|
-
import { strToDOM } from 'front-library/DOM/strToDOM';
|
|
6
|
-
import { append } from 'front-library/DOM/Manipulation';
|
|
7
|
-
import { windowSize } from 'front-library/DOM/windowSize';
|
|
8
|
-
import { template } from 'front-library/Modules/template';
|
|
1
|
+
import { on, off } from '@creative-web-solution/front-library/Events/EventsManager';
|
|
2
|
+
import { KeyboardHandler } from '@creative-web-solution/front-library/Events/KeyboardHandler';
|
|
3
|
+
import { extend } from '@creative-web-solution/front-library/Helpers/Extend';
|
|
4
|
+
import { defer } from '@creative-web-solution/front-library/Helpers/defer';
|
|
5
|
+
import { strToDOM } from '@creative-web-solution/front-library/DOM/strToDOM';
|
|
6
|
+
import { append } from '@creative-web-solution/front-library/DOM/Manipulation';
|
|
7
|
+
import { windowSize } from '@creative-web-solution/front-library/DOM/windowSize';
|
|
8
|
+
import { template } from '@creative-web-solution/front-library/Modules/template';
|
|
9
9
|
|
|
10
10
|
let $body = document.body;
|
|
11
11
|
|
package/Modules/ScrollSnap.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { on, off } from 'front-library/Events/EventsManager';
|
|
2
|
-
import { gesture, gestureOff } from 'front-library/Events/Gesture';
|
|
3
|
-
import { extend } from 'front-library/Helpers/Extend';
|
|
4
|
-
import { wait } from 'front-library/Helpers/wait';
|
|
5
|
-
import { aClass, rClass } from 'front-library/DOM/Class';
|
|
6
|
-
import { prop } from 'front-library/DOM/Styles';
|
|
7
|
-
import { position } from 'front-library/DOM/position';
|
|
8
|
-
import { width, height } from 'front-library/DOM/Size';
|
|
1
|
+
import { on, off } from '@creative-web-solution/front-library/Events/EventsManager';
|
|
2
|
+
import { gesture, gestureOff } from '@creative-web-solution/front-library/Events/Gesture';
|
|
3
|
+
import { extend } from '@creative-web-solution/front-library/Helpers/Extend';
|
|
4
|
+
import { wait } from '@creative-web-solution/front-library/Helpers/wait';
|
|
5
|
+
import { aClass, rClass } from '@creative-web-solution/front-library/DOM/Class';
|
|
6
|
+
import { prop } from '@creative-web-solution/front-library/DOM/Styles';
|
|
7
|
+
import { position } from '@creative-web-solution/front-library/DOM/position';
|
|
8
|
+
import { width, height } from '@creative-web-solution/front-library/DOM/Size';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @callback ScrollSnap_Handler
|
package/Modules/SkinCheckbox.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { extend } from 'front-library/Helpers/Extend';
|
|
2
|
-
import { wrap } from 'front-library/DOM/Wrap';
|
|
1
|
+
import { extend } from '@creative-web-solution/front-library/Helpers/Extend';
|
|
2
|
+
import { wrap } from '@creative-web-solution/front-library/DOM/Wrap';
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const defaultOptions = {
|
package/Modules/SkinFile.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { extend } from 'front-library/Helpers/Extend';
|
|
2
|
-
import { strToDOM } from 'front-library/DOM/strToDOM';
|
|
3
|
-
import { insertAfter, append } from 'front-library/DOM/Manipulation';
|
|
4
|
-
import { on } from 'front-library/Events/EventsManager';
|
|
1
|
+
import { extend } from '@creative-web-solution/front-library/Helpers/Extend';
|
|
2
|
+
import { strToDOM } from '@creative-web-solution/front-library/DOM/strToDOM';
|
|
3
|
+
import { insertAfter, append } from '@creative-web-solution/front-library/DOM/Manipulation';
|
|
4
|
+
import { on } from '@creative-web-solution/front-library/Events/EventsManager';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
const defaultOptions = {
|
package/Modules/SkinRadio.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { extend } from 'front-library/Helpers/Extend';
|
|
2
|
-
import { wrap } from 'front-library/DOM/wrap';
|
|
3
|
-
import { isString } from 'front-library/Helpers/Type';
|
|
1
|
+
import { extend } from '@creative-web-solution/front-library/Helpers/Extend';
|
|
2
|
+
import { wrap } from '@creative-web-solution/front-library/DOM/wrap';
|
|
3
|
+
import { isString } from '@creative-web-solution/front-library/Helpers/Type';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const defaultOptions = {
|