@materializecss/materialize 1.2.2 → 2.0.0-alpha
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/Gruntfile.js +68 -313
- package/README.md +2 -2
- package/dist/css/materialize.css +1009 -1822
- package/dist/css/materialize.min.css +2 -8
- package/dist/js/materialize.js +8402 -12300
- package/dist/js/materialize.min.js +3 -2
- package/dist/js/materialize.min.js.map +1 -0
- package/package.json +13 -9
- package/sass/components/_badges.scss +12 -2
- package/sass/components/_buttons.scss +16 -11
- package/sass/components/_cards.scss +14 -9
- package/sass/components/_carousel.scss +5 -2
- package/sass/components/_chips.scss +3 -3
- package/sass/components/_collapsible.scss +22 -8
- package/sass/components/_collection.scss +14 -6
- package/sass/components/_datepicker.scss +30 -11
- package/sass/components/_dropdown.scss +6 -4
- package/sass/components/_global.scss +132 -111
- package/sass/components/_grid.scss +119 -98
- package/sass/components/_modal.scss +3 -3
- package/sass/components/_navbar.scss +31 -17
- package/sass/components/_normalize.scss +26 -124
- package/sass/components/_sidenav.scss +21 -20
- package/sass/components/_slider.scss +27 -7
- package/sass/components/_table_of_contents.scss +12 -12
- package/sass/components/_tabs.scss +47 -16
- package/sass/components/_tapTarget.scss +6 -6
- package/sass/components/_timepicker.scss +54 -46
- package/sass/components/_toast.scss +3 -3
- package/sass/components/_tooltip.scss +4 -5
- package/sass/components/_typography.scss +1 -1
- package/sass/components/_variables.scss +185 -120
- package/sass/components/forms/_checkboxes.scss +9 -9
- package/sass/components/forms/_file-input.scss +9 -7
- package/sass/components/forms/_input-fields.scss +173 -234
- package/sass/components/forms/_radio-buttons.scss +1 -1
- package/sass/components/forms/_range.scss +11 -11
- package/sass/components/forms/_select.scss +29 -19
- package/sass/components/forms/_switches.scss +22 -18
- package/sass/materialize.scss +1 -1
- package/src/autocomplete.ts +459 -0
- package/src/bounding.ts +6 -0
- package/{js/buttons.js → src/buttons.ts} +103 -162
- package/src/cards.ts +54 -0
- package/{js/carousel.js → src/carousel.ts} +137 -262
- package/src/characterCounter.ts +88 -0
- package/src/chips.ts +350 -0
- package/src/collapsible.ts +184 -0
- package/{js/component.js → src/component.ts} +6 -19
- package/{js/datepicker.js → src/datepicker.ts} +213 -299
- package/{js/dropdown.js → src/dropdown.ts} +140 -254
- package/src/edges.ts +6 -0
- package/src/forms.ts +120 -0
- package/src/global.ts +385 -0
- package/src/materialbox.ts +348 -0
- package/src/modal.ts +256 -0
- package/{js/parallax.js → src/parallax.ts} +47 -60
- package/{js/pushpin.js → src/pushpin.ts} +19 -47
- package/{js/range.js → src/range.ts} +58 -139
- package/{js/scrollspy.js → src/scrollspy.ts} +81 -153
- package/src/select.ts +448 -0
- package/{js/sidenav.js → src/sidenav.ts} +96 -202
- package/src/slider.ts +415 -0
- package/src/tabs.ts +290 -0
- package/src/tapTarget.ts +240 -0
- package/{js/timepicker.js → src/timepicker.ts} +268 -272
- package/{js/toasts.js → src/toasts.ts} +75 -134
- package/{js/tooltip.js → src/tooltip.ts} +59 -96
- package/src/waves.ts +70 -0
- package/extras/noUiSlider/nouislider.css +0 -404
- package/extras/noUiSlider/nouislider.js +0 -2147
- package/extras/noUiSlider/nouislider.min.js +0 -1
- package/js/anime.min.js +0 -34
- package/js/autocomplete.js +0 -479
- package/js/cards.js +0 -40
- package/js/cash.js +0 -960
- package/js/characterCounter.js +0 -136
- package/js/chips.js +0 -486
- package/js/collapsible.js +0 -275
- package/js/forms.js +0 -285
- package/js/global.js +0 -428
- package/js/materialbox.js +0 -453
- package/js/modal.js +0 -382
- package/js/select.js +0 -391
- package/js/slider.js +0 -497
- package/js/tabs.js +0 -402
- package/js/tapTarget.js +0 -315
- package/js/waves.js +0 -615
- package/sass/components/_waves.scss +0 -187
|
@@ -1,78 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { Component } from "./component";
|
|
2
|
+
import { M } from "./global";
|
|
3
|
+
import anim from "animejs";
|
|
4
|
+
|
|
5
|
+
const _defaults = {
|
|
6
|
+
edge: 'left',
|
|
7
|
+
draggable: true,
|
|
8
|
+
dragTargetWidth: '10px',
|
|
9
|
+
inDuration: 250,
|
|
10
|
+
outDuration: 200,
|
|
11
|
+
onOpenStart: null,
|
|
12
|
+
onOpenEnd: null,
|
|
13
|
+
onCloseStart: null,
|
|
14
|
+
onCloseEnd: null,
|
|
15
|
+
preventScrolling: true
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export class Sidenav extends Component {
|
|
19
|
+
id: any;
|
|
20
|
+
isOpen: boolean;
|
|
21
|
+
isFixed: boolean;
|
|
22
|
+
isDragged: boolean;
|
|
23
|
+
lastWindowWidth: number;
|
|
24
|
+
lastWindowHeight: number;
|
|
25
|
+
static _sidenavs: any;
|
|
26
|
+
private _overlay: HTMLElement;
|
|
27
|
+
dragTarget: Element;
|
|
28
|
+
private _closeBound: any;
|
|
29
|
+
private _handleDragTargetDragBound: any;
|
|
30
|
+
private _handleDragTargetReleaseBound: any;
|
|
31
|
+
private _handleCloseDragBound: any;
|
|
32
|
+
private _handleCloseReleaseBound: any;
|
|
33
|
+
private _handleCloseTriggerClickBound: any;
|
|
34
|
+
private _handleWindowResizeBound: any;
|
|
35
|
+
private _startingXpos: number;
|
|
36
|
+
private _xPos: number;
|
|
37
|
+
private _time: number;
|
|
38
|
+
private _width: number;
|
|
39
|
+
private _initialScrollTop: number;
|
|
40
|
+
private _verticallyScrolling: boolean;
|
|
41
|
+
private deltaX: number;
|
|
42
|
+
private velocityX: number;
|
|
43
|
+
private percentOpen: number;
|
|
44
|
+
|
|
27
45
|
constructor(el, options) {
|
|
28
46
|
super(Sidenav, el, options);
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Options for the Sidenav
|
|
35
|
-
* @member Sidenav#options
|
|
36
|
-
* @prop {String} [edge='left'] - Side of screen on which Sidenav appears
|
|
37
|
-
* @prop {Boolean} [draggable=true] - Allow swipe gestures to open/close Sidenav
|
|
38
|
-
* @prop {String} [dragTargetWidth='10px'] - Width of the area where you can start dragging
|
|
39
|
-
* @prop {Number} [inDuration=250] - Length in ms of enter transition
|
|
40
|
-
* @prop {Number} [outDuration=200] - Length in ms of exit transition
|
|
41
|
-
* @prop {Function} onOpenStart - Function called when sidenav starts entering
|
|
42
|
-
* @prop {Function} onOpenEnd - Function called when sidenav finishes entering
|
|
43
|
-
* @prop {Function} onCloseStart - Function called when sidenav starts exiting
|
|
44
|
-
* @prop {Function} onCloseEnd - Function called when sidenav finishes exiting
|
|
45
|
-
*/
|
|
46
|
-
this.options = $.extend({}, Sidenav.defaults, options);
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Describes open/close state of Sidenav
|
|
50
|
-
* @type {Boolean}
|
|
51
|
-
*/
|
|
47
|
+
(this.el as any).M_Sidenav = this;
|
|
48
|
+
this.id = this.el.id;
|
|
49
|
+
this.options = {...Sidenav.defaults, ...options};
|
|
52
50
|
this.isOpen = false;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Describes if Sidenav is fixed
|
|
56
|
-
* @type {Boolean}
|
|
57
|
-
*/
|
|
58
51
|
this.isFixed = this.el.classList.contains('sidenav-fixed');
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Describes if Sidenav is being draggeed
|
|
62
|
-
* @type {Boolean}
|
|
63
|
-
*/
|
|
64
52
|
this.isDragged = false;
|
|
65
|
-
|
|
66
53
|
// Window size variables for window resize checks
|
|
67
54
|
this.lastWindowWidth = window.innerWidth;
|
|
68
55
|
this.lastWindowHeight = window.innerHeight;
|
|
69
|
-
|
|
70
56
|
this._createOverlay();
|
|
71
57
|
this._createDragTarget();
|
|
72
58
|
this._setupEventHandlers();
|
|
73
59
|
this._setupClasses();
|
|
74
60
|
this._setupFixed();
|
|
75
|
-
|
|
76
61
|
Sidenav._sidenavs.push(this);
|
|
77
62
|
}
|
|
78
63
|
|
|
@@ -84,53 +69,42 @@
|
|
|
84
69
|
return super.init(this, els, options);
|
|
85
70
|
}
|
|
86
71
|
|
|
87
|
-
/**
|
|
88
|
-
* Get Instance
|
|
89
|
-
*/
|
|
90
72
|
static getInstance(el) {
|
|
91
|
-
|
|
73
|
+
const domElem = !!el.jquery ? el[0] : el;
|
|
92
74
|
return domElem.M_Sidenav;
|
|
93
75
|
}
|
|
94
76
|
|
|
95
|
-
/**
|
|
96
|
-
* Teardown component
|
|
97
|
-
*/
|
|
98
77
|
destroy() {
|
|
99
78
|
this._removeEventHandlers();
|
|
100
79
|
this._enableBodyScrolling();
|
|
101
80
|
this._overlay.parentNode.removeChild(this._overlay);
|
|
102
81
|
this.dragTarget.parentNode.removeChild(this.dragTarget);
|
|
103
|
-
this.el.M_Sidenav = undefined;
|
|
104
|
-
this.el.style.transform = '';
|
|
105
|
-
|
|
106
|
-
let index = Sidenav._sidenavs.indexOf(this);
|
|
82
|
+
(this.el as any).M_Sidenav = undefined;
|
|
83
|
+
(this.el as HTMLElement).style.transform = '';
|
|
84
|
+
const index = Sidenav._sidenavs.indexOf(this);
|
|
107
85
|
if (index >= 0) {
|
|
108
86
|
Sidenav._sidenavs.splice(index, 1);
|
|
109
87
|
}
|
|
110
88
|
}
|
|
111
89
|
|
|
112
90
|
_createOverlay() {
|
|
113
|
-
|
|
91
|
+
this._overlay = document.createElement('div');
|
|
114
92
|
this._closeBound = this.close.bind(this);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
document.body.appendChild(overlay);
|
|
120
|
-
this._overlay = overlay;
|
|
93
|
+
this._overlay.classList.add('sidenav-overlay');
|
|
94
|
+
this._overlay.addEventListener('click', this._closeBound);
|
|
95
|
+
document.body.appendChild(this._overlay);
|
|
121
96
|
}
|
|
122
97
|
|
|
123
98
|
_setupEventHandlers() {
|
|
124
99
|
if (Sidenav._sidenavs.length === 0) {
|
|
125
100
|
document.body.addEventListener('click', this._handleTriggerClick);
|
|
126
101
|
}
|
|
127
|
-
|
|
128
102
|
this._handleDragTargetDragBound = this._handleDragTargetDrag.bind(this);
|
|
129
103
|
this._handleDragTargetReleaseBound = this._handleDragTargetRelease.bind(this);
|
|
130
104
|
this._handleCloseDragBound = this._handleCloseDrag.bind(this);
|
|
131
105
|
this._handleCloseReleaseBound = this._handleCloseRelease.bind(this);
|
|
132
106
|
this._handleCloseTriggerClickBound = this._handleCloseTriggerClick.bind(this);
|
|
133
|
-
|
|
107
|
+
var passiveIfSupported: boolean = null;
|
|
134
108
|
this.dragTarget.addEventListener('touchmove', this._handleDragTargetDragBound, passiveIfSupported);
|
|
135
109
|
this.dragTarget.addEventListener('touchend', this._handleDragTargetReleaseBound);
|
|
136
110
|
this._overlay.addEventListener('touchmove', this._handleCloseDragBound, passiveIfSupported);
|
|
@@ -138,7 +112,6 @@
|
|
|
138
112
|
this.el.addEventListener('touchmove', this._handleCloseDragBound, passiveIfSupported);
|
|
139
113
|
this.el.addEventListener('touchend', this._handleCloseReleaseBound);
|
|
140
114
|
this.el.addEventListener('click', this._handleCloseTriggerClickBound);
|
|
141
|
-
|
|
142
115
|
// Add resize for side nav fixed
|
|
143
116
|
if (this.isFixed) {
|
|
144
117
|
this._handleWindowResizeBound = this._handleWindowResize.bind(this);
|
|
@@ -150,7 +123,6 @@
|
|
|
150
123
|
if (Sidenav._sidenavs.length === 1) {
|
|
151
124
|
document.body.removeEventListener('click', this._handleTriggerClick);
|
|
152
125
|
}
|
|
153
|
-
|
|
154
126
|
this.dragTarget.removeEventListener('touchmove', this._handleDragTargetDragBound);
|
|
155
127
|
this.dragTarget.removeEventListener('touchend', this._handleDragTargetReleaseBound);
|
|
156
128
|
this._overlay.removeEventListener('touchmove', this._handleCloseDragBound);
|
|
@@ -165,30 +137,21 @@
|
|
|
165
137
|
}
|
|
166
138
|
}
|
|
167
139
|
|
|
168
|
-
/**
|
|
169
|
-
* Handle Trigger Click
|
|
170
|
-
* @param {Event} e
|
|
171
|
-
*/
|
|
172
140
|
_handleTriggerClick(e) {
|
|
173
|
-
|
|
174
|
-
if (e.target &&
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
let sidenavInstance = document.getElementById(sidenavId).M_Sidenav;
|
|
141
|
+
const trigger = e.target.closest('.sidenav-trigger');
|
|
142
|
+
if (e.target && trigger) {
|
|
143
|
+
const sidenavId = M.getIdFromTrigger(trigger);
|
|
144
|
+
const sidenavInstance = (document.getElementById(sidenavId) as any).M_Sidenav;
|
|
178
145
|
if (sidenavInstance) {
|
|
179
|
-
sidenavInstance.open(
|
|
146
|
+
sidenavInstance.open(trigger);
|
|
180
147
|
}
|
|
181
148
|
e.preventDefault();
|
|
182
149
|
}
|
|
183
150
|
}
|
|
184
151
|
|
|
185
|
-
|
|
186
|
-
* Set variables needed at the beginning of drag
|
|
187
|
-
* and stop any current transition.
|
|
188
|
-
* @param {Event} e
|
|
189
|
-
*/
|
|
152
|
+
// Set variables needed at the beginning of drag and stop any current transition.
|
|
190
153
|
_startDrag(e) {
|
|
191
|
-
|
|
154
|
+
const clientX = e.targetTouches[0].clientX;
|
|
192
155
|
this.isDragged = true;
|
|
193
156
|
this._startingXpos = clientX;
|
|
194
157
|
this._xPos = this._startingXpos;
|
|
@@ -201,13 +164,10 @@
|
|
|
201
164
|
anim.remove(this._overlay);
|
|
202
165
|
}
|
|
203
166
|
|
|
204
|
-
|
|
205
|
-
* Set variables needed at each drag move update tick
|
|
206
|
-
* @param {Event} e
|
|
207
|
-
*/
|
|
167
|
+
//Set variables needed at each drag move update tick
|
|
208
168
|
_dragMoveUpdate(e) {
|
|
209
|
-
|
|
210
|
-
|
|
169
|
+
const clientX = e.targetTouches[0].clientX;
|
|
170
|
+
const currentScrollTop = this.isOpen ? this.el.scrollTop : M.getDocumentScrollTop();
|
|
211
171
|
this.deltaX = Math.abs(this._xPos - clientX);
|
|
212
172
|
this._xPos = clientX;
|
|
213
173
|
this.velocityX = this.deltaX / (Date.now() - this._time);
|
|
@@ -217,36 +177,26 @@
|
|
|
217
177
|
}
|
|
218
178
|
}
|
|
219
179
|
|
|
220
|
-
/**
|
|
221
|
-
* Handles Dragging of Sidenav
|
|
222
|
-
* @param {Event} e
|
|
223
|
-
*/
|
|
224
180
|
_handleDragTargetDrag(e) {
|
|
225
181
|
// Check if draggable
|
|
226
182
|
if (!this.options.draggable || this._isCurrentlyFixed() || this._verticallyScrolling) {
|
|
227
183
|
return;
|
|
228
184
|
}
|
|
229
|
-
|
|
230
185
|
// If not being dragged, set initial drag start variables
|
|
231
186
|
if (!this.isDragged) {
|
|
232
187
|
this._startDrag(e);
|
|
233
188
|
}
|
|
234
|
-
|
|
235
189
|
// Run touchmove updates
|
|
236
190
|
this._dragMoveUpdate(e);
|
|
237
|
-
|
|
238
191
|
// Calculate raw deltaX
|
|
239
192
|
let totalDeltaX = this._xPos - this._startingXpos;
|
|
240
|
-
|
|
241
193
|
// dragDirection is the attempted user drag direction
|
|
242
|
-
|
|
243
|
-
|
|
194
|
+
const dragDirection = totalDeltaX > 0 ? 'right' : 'left';
|
|
244
195
|
// Don't allow totalDeltaX to exceed Sidenav width or be dragged in the opposite direction
|
|
245
196
|
totalDeltaX = Math.min(this._width, Math.abs(totalDeltaX));
|
|
246
197
|
if (this.options.edge === dragDirection) {
|
|
247
198
|
totalDeltaX = 0;
|
|
248
199
|
}
|
|
249
|
-
|
|
250
200
|
/**
|
|
251
201
|
* transformX is the drag displacement
|
|
252
202
|
* transformPrefix is the initial transform placement
|
|
@@ -258,18 +208,13 @@
|
|
|
258
208
|
transformPrefix = 'translateX(100%)';
|
|
259
209
|
transformX = -transformX;
|
|
260
210
|
}
|
|
261
|
-
|
|
262
211
|
// Calculate open/close percentage of sidenav, with open = 1 and close = 0
|
|
263
212
|
this.percentOpen = Math.min(1, totalDeltaX / this._width);
|
|
264
|
-
|
|
265
213
|
// Set transform and opacity styles
|
|
266
|
-
this.el.style.transform = `${transformPrefix} translateX(${transformX}px)`;
|
|
267
|
-
this._overlay.style.opacity = this.percentOpen;
|
|
214
|
+
(this.el as HTMLElement).style.transform = `${transformPrefix} translateX(${transformX}px)`;
|
|
215
|
+
this._overlay.style.opacity = this.percentOpen.toString();
|
|
268
216
|
}
|
|
269
217
|
|
|
270
|
-
/**
|
|
271
|
-
* Handle Drag Target Release
|
|
272
|
-
*/
|
|
273
218
|
_handleDragTargetRelease() {
|
|
274
219
|
if (this.isDragged) {
|
|
275
220
|
if (this.percentOpen > 0.2) {
|
|
@@ -277,60 +222,44 @@
|
|
|
277
222
|
} else {
|
|
278
223
|
this._animateOut();
|
|
279
224
|
}
|
|
280
|
-
|
|
281
225
|
this.isDragged = false;
|
|
282
226
|
this._verticallyScrolling = false;
|
|
283
227
|
}
|
|
284
228
|
}
|
|
285
229
|
|
|
286
|
-
/**
|
|
287
|
-
* Handle Close Drag
|
|
288
|
-
* @param {Event} e
|
|
289
|
-
*/
|
|
290
230
|
_handleCloseDrag(e) {
|
|
291
231
|
if (this.isOpen) {
|
|
292
232
|
// Check if draggable
|
|
293
233
|
if (!this.options.draggable || this._isCurrentlyFixed() || this._verticallyScrolling) {
|
|
294
234
|
return;
|
|
295
235
|
}
|
|
296
|
-
|
|
297
236
|
// If not being dragged, set initial drag start variables
|
|
298
237
|
if (!this.isDragged) {
|
|
299
238
|
this._startDrag(e);
|
|
300
239
|
}
|
|
301
|
-
|
|
302
240
|
// Run touchmove updates
|
|
303
241
|
this._dragMoveUpdate(e);
|
|
304
|
-
|
|
305
242
|
// Calculate raw deltaX
|
|
306
243
|
let totalDeltaX = this._xPos - this._startingXpos;
|
|
307
|
-
|
|
308
244
|
// dragDirection is the attempted user drag direction
|
|
309
245
|
let dragDirection = totalDeltaX > 0 ? 'right' : 'left';
|
|
310
|
-
|
|
311
246
|
// Don't allow totalDeltaX to exceed Sidenav width or be dragged in the opposite direction
|
|
312
247
|
totalDeltaX = Math.min(this._width, Math.abs(totalDeltaX));
|
|
313
248
|
if (this.options.edge !== dragDirection) {
|
|
314
249
|
totalDeltaX = 0;
|
|
315
250
|
}
|
|
316
|
-
|
|
317
251
|
let transformX = -totalDeltaX;
|
|
318
252
|
if (this.options.edge === 'right') {
|
|
319
253
|
transformX = -transformX;
|
|
320
254
|
}
|
|
321
|
-
|
|
322
255
|
// Calculate open/close percentage of sidenav, with open = 1 and close = 0
|
|
323
256
|
this.percentOpen = Math.min(1, 1 - totalDeltaX / this._width);
|
|
324
|
-
|
|
325
257
|
// Set transform and opacity styles
|
|
326
|
-
this.el.style.transform = `translateX(${transformX}px)`;
|
|
327
|
-
this._overlay.style.opacity = this.percentOpen;
|
|
258
|
+
(this.el as HTMLElement).style.transform = `translateX(${transformX}px)`;
|
|
259
|
+
this._overlay.style.opacity = this.percentOpen.toString();
|
|
328
260
|
}
|
|
329
261
|
}
|
|
330
262
|
|
|
331
|
-
/**
|
|
332
|
-
* Handle Close Release
|
|
333
|
-
*/
|
|
334
263
|
_handleCloseRelease() {
|
|
335
264
|
if (this.isOpen && this.isDragged) {
|
|
336
265
|
if (this.percentOpen > 0.8) {
|
|
@@ -338,25 +267,19 @@
|
|
|
338
267
|
} else {
|
|
339
268
|
this.close();
|
|
340
269
|
}
|
|
341
|
-
|
|
342
270
|
this.isDragged = false;
|
|
343
271
|
this._verticallyScrolling = false;
|
|
344
272
|
}
|
|
345
273
|
}
|
|
346
274
|
|
|
347
|
-
|
|
348
|
-
* Handles closing of Sidenav when element with class .sidenav-close
|
|
349
|
-
*/
|
|
275
|
+
// Handles closing of Sidenav when element with class .sidenav-close
|
|
350
276
|
_handleCloseTriggerClick(e) {
|
|
351
|
-
|
|
352
|
-
if (
|
|
277
|
+
const closeTrigger = e.target.closest('.sidenav-close');
|
|
278
|
+
if (closeTrigger && !this._isCurrentlyFixed()) {
|
|
353
279
|
this.close();
|
|
354
280
|
}
|
|
355
281
|
}
|
|
356
282
|
|
|
357
|
-
/**
|
|
358
|
-
* Handle Window Resize
|
|
359
|
-
*/
|
|
360
283
|
_handleWindowResize() {
|
|
361
284
|
// Only handle horizontal resizes
|
|
362
285
|
if (this.lastWindowWidth !== window.innerWidth) {
|
|
@@ -366,7 +289,6 @@
|
|
|
366
289
|
this.close();
|
|
367
290
|
}
|
|
368
291
|
}
|
|
369
|
-
|
|
370
292
|
this.lastWindowWidth = window.innerWidth;
|
|
371
293
|
this.lastWindowHeight = window.innerHeight;
|
|
372
294
|
}
|
|
@@ -384,9 +306,7 @@
|
|
|
384
306
|
}
|
|
385
307
|
|
|
386
308
|
_setupFixed() {
|
|
387
|
-
if (this._isCurrentlyFixed())
|
|
388
|
-
this.open();
|
|
389
|
-
}
|
|
309
|
+
if (this._isCurrentlyFixed()) this.open();
|
|
390
310
|
}
|
|
391
311
|
|
|
392
312
|
_isCurrentlyFixed() {
|
|
@@ -394,7 +314,7 @@
|
|
|
394
314
|
}
|
|
395
315
|
|
|
396
316
|
_createDragTarget() {
|
|
397
|
-
|
|
317
|
+
const dragTarget = document.createElement('div');
|
|
398
318
|
dragTarget.classList.add('drag-target');
|
|
399
319
|
dragTarget.style.width = this.options.dragTargetWidth;
|
|
400
320
|
document.body.appendChild(dragTarget);
|
|
@@ -402,27 +322,20 @@
|
|
|
402
322
|
}
|
|
403
323
|
|
|
404
324
|
_preventBodyScrolling() {
|
|
405
|
-
|
|
406
|
-
body.style.overflow = 'hidden';
|
|
325
|
+
document.body.style.overflow = 'hidden';
|
|
407
326
|
}
|
|
408
327
|
|
|
409
328
|
_enableBodyScrolling() {
|
|
410
|
-
|
|
411
|
-
body.style.overflow = '';
|
|
329
|
+
document.body.style.overflow = '';
|
|
412
330
|
}
|
|
413
331
|
|
|
414
332
|
open() {
|
|
415
|
-
if (this.isOpen === true)
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
|
|
333
|
+
if (this.isOpen === true) return;
|
|
419
334
|
this.isOpen = true;
|
|
420
|
-
|
|
421
335
|
// Run onOpenStart callback
|
|
422
336
|
if (typeof this.options.onOpenStart === 'function') {
|
|
423
337
|
this.options.onOpenStart.call(this, this.el);
|
|
424
338
|
}
|
|
425
|
-
|
|
426
339
|
// Handle fixed Sidenav
|
|
427
340
|
if (this._isCurrentlyFixed()) {
|
|
428
341
|
anim.remove(this.el);
|
|
@@ -434,9 +347,9 @@
|
|
|
434
347
|
});
|
|
435
348
|
this._enableBodyScrolling();
|
|
436
349
|
this._overlay.style.display = 'none';
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
350
|
+
}
|
|
351
|
+
// Handle non-fixed Sidenav
|
|
352
|
+
else {
|
|
440
353
|
if (this.options.preventScrolling) {
|
|
441
354
|
this._preventBodyScrolling();
|
|
442
355
|
}
|
|
@@ -448,26 +361,20 @@
|
|
|
448
361
|
}
|
|
449
362
|
|
|
450
363
|
close() {
|
|
451
|
-
if (this.isOpen === false)
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
|
|
364
|
+
if (this.isOpen === false) return;
|
|
455
365
|
this.isOpen = false;
|
|
456
|
-
|
|
457
366
|
// Run onCloseStart callback
|
|
458
367
|
if (typeof this.options.onCloseStart === 'function') {
|
|
459
368
|
this.options.onCloseStart.call(this, this.el);
|
|
460
369
|
}
|
|
461
|
-
|
|
462
370
|
// Handle fixed Sidenav
|
|
463
371
|
if (this._isCurrentlyFixed()) {
|
|
464
|
-
|
|
465
|
-
this.el.style.transform = `translateX(${transformX})`;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
372
|
+
const transformX = this.options.edge === 'left' ? '-105%' : '105%';
|
|
373
|
+
(this.el as HTMLElement).style.transform = `translateX(${transformX})`;
|
|
374
|
+
}
|
|
375
|
+
// Handle non-fixed Sidenav
|
|
376
|
+
else {
|
|
469
377
|
this._enableBodyScrolling();
|
|
470
|
-
|
|
471
378
|
if (!this.isDragged || this.percentOpen != 0) {
|
|
472
379
|
this._animateOut();
|
|
473
380
|
} else {
|
|
@@ -489,7 +396,6 @@
|
|
|
489
396
|
? slideOutPercent + this.percentOpen
|
|
490
397
|
: slideOutPercent - this.percentOpen;
|
|
491
398
|
}
|
|
492
|
-
|
|
493
399
|
anim.remove(this.el);
|
|
494
400
|
anim({
|
|
495
401
|
targets: this.el,
|
|
@@ -509,12 +415,10 @@
|
|
|
509
415
|
let start = 0;
|
|
510
416
|
if (this.isDragged) {
|
|
511
417
|
start = this.percentOpen;
|
|
512
|
-
} else {
|
|
513
|
-
$(this._overlay).css({
|
|
514
|
-
display: 'block'
|
|
515
|
-
});
|
|
516
418
|
}
|
|
517
|
-
|
|
419
|
+
else {
|
|
420
|
+
this._overlay.style.display = 'block';
|
|
421
|
+
}
|
|
518
422
|
anim.remove(this._overlay);
|
|
519
423
|
anim({
|
|
520
424
|
targets: this._overlay,
|
|
@@ -530,7 +434,7 @@
|
|
|
530
434
|
}
|
|
531
435
|
|
|
532
436
|
_animateSidenavOut() {
|
|
533
|
-
|
|
437
|
+
const endPercent = this.options.edge === 'left' ? -1 : 1;
|
|
534
438
|
let slideOutPercent = 0;
|
|
535
439
|
if (this.isDragged) {
|
|
536
440
|
slideOutPercent =
|
|
@@ -562,22 +466,12 @@
|
|
|
562
466
|
duration: this.options.outDuration,
|
|
563
467
|
easing: 'easeOutQuad',
|
|
564
468
|
complete: () => {
|
|
565
|
-
|
|
469
|
+
this._overlay.style.display = 'none';
|
|
566
470
|
}
|
|
567
471
|
});
|
|
568
472
|
}
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* @static
|
|
573
|
-
* @memberof Sidenav
|
|
574
|
-
* @type {Array.<Sidenav>}
|
|
575
|
-
*/
|
|
576
|
-
Sidenav._sidenavs = [];
|
|
577
473
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
M.initializeJqueryWrapper(Sidenav, 'sidenav', 'M_Sidenav');
|
|
474
|
+
static {
|
|
475
|
+
Sidenav._sidenavs = [];
|
|
476
|
+
}
|
|
582
477
|
}
|
|
583
|
-
})(cash, M.anime);
|