materialize-sass 1.0.0.alpha4 → 1.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,6 +13,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
13
13
 
14
14
  var _defaults = {
15
15
  alignment: 'left',
16
+ autoFocus: true,
16
17
  constrainWidth: true,
17
18
  container: null,
18
19
  coverTrigger: true,
@@ -49,6 +50,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
49
50
  * Options for the dropdown
50
51
  * @member Dropdown#options
51
52
  * @prop {String} [alignment='left'] - Edge which the dropdown is aligned to
53
+ * @prop {Boolean} [autoFocus=true] - Automatically focus dropdown el for keyboard
52
54
  * @prop {Boolean} [constrainWidth=true] - Constrain width to width of the button
53
55
  * @prop {Element} container - Container element to attach dropdown to (optional)
54
56
  * @prop {Boolean} [coverTrigger=true] - Place dropdown over trigger
@@ -69,6 +71,18 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
69
71
  */
70
72
  _this.isOpen = false;
71
73
 
74
+ /**
75
+ * Describes if dropdown content is scrollable
76
+ * @type {Boolean}
77
+ */
78
+ _this.isScrollable = false;
79
+
80
+ /**
81
+ * Describes if touch moving on dropdown content
82
+ * @type {Boolean}
83
+ */
84
+ _this.isTouchMoving = false;
85
+
72
86
  _this.focusedIndex = -1;
73
87
  _this.filterQuery = [];
74
88
 
@@ -82,6 +96,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
82
96
  _this._makeDropdownFocusable();
83
97
  _this._resetFilterQueryBound = _this._resetFilterQuery.bind(_this);
84
98
  _this._handleDocumentClickBound = _this._handleDocumentClick.bind(_this);
99
+ _this._handleDocumentTouchmoveBound = _this._handleDocumentTouchmove.bind(_this);
85
100
  _this._handleDropdownKeydownBound = _this._handleDropdownKeydown.bind(_this);
86
101
  _this._handleTriggerKeydownBound = _this._handleTriggerKeydown.bind(_this);
87
102
  _this._setupEventHandlers();
@@ -151,6 +166,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
151
166
  // Use capture phase event handler to prevent click
152
167
  document.body.addEventListener('click', this._handleDocumentClickBound, true);
153
168
  document.body.addEventListener('touchend', this._handleDocumentClickBound);
169
+ document.body.addEventListener('touchmove', this._handleDocumentTouchmoveBound);
154
170
  this.dropdownEl.addEventListener('keydown', this._handleDropdownKeydownBound);
155
171
  }
156
172
  }, {
@@ -159,6 +175,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
159
175
  // Use capture phase event handler to prevent click
160
176
  document.body.removeEventListener('click', this._handleDocumentClickBound, true);
161
177
  document.body.removeEventListener('touchend', this._handleDocumentClickBound);
178
+ document.body.removeEventListener('touchmove', this._handleDocumentTouchmoveBound);
162
179
  this.dropdownEl.removeEventListener('keydown', this._handleDropdownKeydownBound);
163
180
  }
164
181
  }, {
@@ -195,7 +212,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
195
212
  var _this2 = this;
196
213
 
197
214
  var $target = $(e.target);
198
- if (this.options.closeOnClick && $target.closest('.dropdown-content').length) {
215
+ if (this.options.closeOnClick && $target.closest('.dropdown-content').length && !this.isTouchMoving) {
216
+ // isTouchMoving to check if scrolling on mobile.
199
217
  setTimeout(function () {
200
218
  _this2.close();
201
219
  }, 0);
@@ -204,6 +222,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
204
222
  _this2.close();
205
223
  }, 0);
206
224
  }
225
+ this.isTouchMoving = false;
207
226
  }
208
227
  }, {
209
228
  key: '_handleTriggerKeydown',
@@ -215,6 +234,20 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
215
234
  }
216
235
  }
217
236
 
237
+ /**
238
+ * Handle Document Touchmove
239
+ * @param {Event} e
240
+ */
241
+
242
+ }, {
243
+ key: '_handleDocumentTouchmove',
244
+ value: function _handleDocumentTouchmove(e) {
245
+ var $target = $(e.target);
246
+ if ($target.closest('.dropdown-content').length) {
247
+ this.isTouchMoving = true;
248
+ }
249
+ }
250
+
218
251
  /**
219
252
  * Handle Dropdown Keydown
220
253
  * @param {Event} e
@@ -231,8 +264,21 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
231
264
  } else if ((e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) && this.isOpen) {
232
265
  e.preventDefault();
233
266
  var direction = e.which === M.keys.ARROW_DOWN ? 1 : -1;
234
- this.focusedIndex = Math.max(Math.min(this.focusedIndex + direction, this.dropdownEl.children.length - 1), 0);
235
- this._focusFocusedItem();
267
+ var newFocusedIndex = this.focusedIndex;
268
+ var foundNewIndex = false;
269
+ do {
270
+ newFocusedIndex = newFocusedIndex + direction;
271
+
272
+ if (!!this.dropdownEl.children[newFocusedIndex] && this.dropdownEl.children[newFocusedIndex].tabIndex !== -1) {
273
+ foundNewIndex = true;
274
+ break;
275
+ }
276
+ } while (newFocusedIndex < this.dropdownEl.children.length && newFocusedIndex >= 0);
277
+
278
+ if (foundNewIndex) {
279
+ this.focusedIndex = newFocusedIndex;
280
+ this._focusFocusedItem();
281
+ }
236
282
 
237
283
  // ENTER selects choice on focused item
238
284
  } else if (e.which === M.keys.ENTER && this.isOpen) {
@@ -295,16 +341,20 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
295
341
  }, {
296
342
  key: '_makeDropdownFocusable',
297
343
  value: function _makeDropdownFocusable() {
298
- if (this.dropdownEl.tabIndex === -1) {
299
- this.dropdownEl.tabIndex = 0;
300
- }
344
+ // Needed for arrow key navigation
345
+ this.dropdownEl.tabIndex = 0;
301
346
 
302
- $(this.dropdownEl).children().attr('tabindex', 0);
347
+ // Only set tabindex if it hasn't been set by user
348
+ $(this.dropdownEl).children().each(function (el) {
349
+ if (!el.getAttribute('tabindex')) {
350
+ el.setAttribute('tabindex', 0);
351
+ }
352
+ });
303
353
  }
304
354
  }, {
305
355
  key: '_focusFocusedItem',
306
356
  value: function _focusFocusedItem() {
307
- if (this.focusedIndex >= 0 && this.focusedIndex < this.dropdownEl.children.length) {
357
+ if (this.focusedIndex >= 0 && this.focusedIndex < this.dropdownEl.children.length && this.options.autoFocus) {
308
358
  this.dropdownEl.children[this.focusedIndex].focus();
309
359
  }
310
360
  }
@@ -334,10 +384,16 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
334
384
  var verticalAlignment = 'top';
335
385
  var horizontalAlignment = this.options.alignment;
336
386
  idealYPos += this.options.coverTrigger ? 0 : triggerBRect.height;
387
+
388
+ // Reset isScrollable
389
+ this.isScrollable = false;
390
+
337
391
  if (!alignments.top) {
338
392
  if (alignments.bottom) {
339
393
  verticalAlignment = 'bottom';
340
394
  } else {
395
+ this.isScrollable = true;
396
+
341
397
  // Determine which side has most space and cutoff at correct height
342
398
  if (alignments.spaceOnTop > alignments.spaceOnBottom) {
343
399
  verticalAlignment = 'bottom';
@@ -389,16 +445,9 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
389
445
 
390
446
  }, {
391
447
  key: '_animateIn',
392
- value: function _animateIn(positionInfo) {
448
+ value: function _animateIn() {
393
449
  var _this3 = this;
394
450
 
395
- // Place dropdown
396
- this.dropdownEl.style.left = positionInfo.x + 'px';
397
- this.dropdownEl.style.top = positionInfo.y + 'px';
398
- this.dropdownEl.style.height = positionInfo.height + 'px';
399
- this.dropdownEl.style.width = positionInfo.width + 'px';
400
- this.dropdownEl.style.transformOrigin = (positionInfo.horizontalAlignment === 'left' ? '0' : '100%') + ' ' + (positionInfo.verticalAlignment === 'top' ? '0' : '100%');
401
-
402
451
  anim.remove(this.dropdownEl);
403
452
  anim({
404
453
  targets: this.dropdownEl,
@@ -411,7 +460,9 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
411
460
  duration: this.options.inDuration,
412
461
  easing: 'easeOutQuint',
413
462
  complete: function (anim) {
414
- _this3.dropdownEl.focus();
463
+ if (_this3.options.autoFocus) {
464
+ _this3.dropdownEl.focus();
465
+ }
415
466
 
416
467
  // onOpenEnd callback
417
468
  if (typeof _this3.options.onOpenEnd === 'function') {
@@ -454,6 +505,25 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
454
505
  });
455
506
  }
456
507
 
508
+ /**
509
+ * Place dropdown
510
+ */
511
+
512
+ }, {
513
+ key: '_placeDropdown',
514
+ value: function _placeDropdown() {
515
+ // Set width before calculating positionInfo
516
+ var idealWidth = this.options.constrainWidth ? this.el.getBoundingClientRect().width : this.dropdownEl.getBoundingClientRect().width;
517
+ this.dropdownEl.style.width = idealWidth + 'px';
518
+
519
+ var positionInfo = this._getDropdownPosition();
520
+ this.dropdownEl.style.left = positionInfo.x + 'px';
521
+ this.dropdownEl.style.top = positionInfo.y + 'px';
522
+ this.dropdownEl.style.height = positionInfo.height + 'px';
523
+ this.dropdownEl.style.width = positionInfo.width + 'px';
524
+ this.dropdownEl.style.transformOrigin = (positionInfo.horizontalAlignment === 'left' ? '0' : '100%') + ' ' + (positionInfo.verticalAlignment === 'top' ? '0' : '100%');
525
+ }
526
+
457
527
  /**
458
528
  * Open Dropdown
459
529
  */
@@ -475,12 +545,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
475
545
  this._resetDropdownStyles();
476
546
  this.dropdownEl.style.display = 'block';
477
547
 
478
- // Set width before calculating positionInfo
479
- var idealWidth = this.options.constrainWidth ? this.el.getBoundingClientRect().width : this.dropdownEl.getBoundingClientRect().width;
480
- this.dropdownEl.style.width = idealWidth + 'px';
481
-
482
- var positionInfo = this._getDropdownPosition();
483
- this._animateIn(positionInfo);
548
+ this._placeDropdown();
549
+ this._animateIn();
484
550
  this._setupTemporaryEventHandlers();
485
551
  }
486
552
 
@@ -504,7 +570,29 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
504
570
 
505
571
  this._animateOut();
506
572
  this._removeTemporaryEventHandlers();
507
- this.el.focus();
573
+
574
+ if (this.options.autoFocus) {
575
+ this.el.focus();
576
+ }
577
+ }
578
+
579
+ /**
580
+ * Recalculate dimensions
581
+ */
582
+
583
+ }, {
584
+ key: 'recalculateDimensions',
585
+ value: function recalculateDimensions() {
586
+ if (this.isOpen) {
587
+ this.$dropdownEl.css({
588
+ width: '',
589
+ height: '',
590
+ left: '',
591
+ top: '',
592
+ 'transform-origin': ''
593
+ });
594
+ this._placeDropdown();
595
+ }
508
596
  }
509
597
  }], [{
510
598
  key: 'init',
@@ -1,7 +1,7 @@
1
1
  (function ($) {
2
2
  // Function to update labels of text fields
3
3
  M.updateTextFields = function () {
4
- var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], textarea';
4
+ var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], input[type=date], input[type=time], textarea';
5
5
  $(input_selector).each(function (element, index) {
6
6
  var $this = $(this);
7
7
  if (element.value.length > 0 || $(element).is(':focus') || element.autofocus || $this.attr('placeholder') !== null) {
@@ -130,7 +130,7 @@
130
130
 
131
131
  $(document).on('ready turbolinks:load', function () {
132
132
  // Text based inputs
133
- var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], textarea';
133
+ var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], input[type=date], input[type=time], textarea';
134
134
 
135
135
  // Add active if form auto complete
136
136
  $(document).on('change', input_selector, function () {
@@ -84,6 +84,41 @@ M.initializeJqueryWrapper = function (plugin, pluginName, classRef) {
84
84
  };
85
85
  };
86
86
 
87
+ /**
88
+ * Automatically initialize components
89
+ * @param {Element} context DOM Element to search within for components
90
+ */
91
+ M.AutoInit = function (context) {
92
+ // Use document.body if no context is given
93
+ var root = !!context ? context : document.body;
94
+
95
+ var registry = {
96
+ Autocomplete: root.querySelectorAll('.autocomplete:not(.no-autoinit)'),
97
+ Carousel: root.querySelectorAll('.carousel:not(.no-autoinit)'),
98
+ Chips: root.querySelectorAll('.chips:not(.no-autoinit)'),
99
+ Collapsible: root.querySelectorAll('.collapsible:not(.no-autoinit)'),
100
+ Datepicker: root.querySelectorAll('.datepicker:not(.no-autoinit)'),
101
+ Dropdown: root.querySelectorAll('.dropdown-trigger:not(.no-autoinit)'),
102
+ Materialbox: root.querySelectorAll('.materialboxed:not(.no-autoinit)'),
103
+ Modal: root.querySelectorAll('.modal:not(.no-autoinit)'),
104
+ Parallax: root.querySelectorAll('.parallax:not(.no-autoinit)'),
105
+ Pushpin: root.querySelectorAll('.pushpin:not(.no-autoinit)'),
106
+ ScrollSpy: root.querySelectorAll('.scrollspy:not(.no-autoinit)'),
107
+ FormSelect: root.querySelectorAll('select:not(.no-autoinit)'),
108
+ Sidenav: root.querySelectorAll('.sidenav:not(.no-autoinit)'),
109
+ Tabs: root.querySelectorAll('.tabs:not(.no-autoinit)'),
110
+ TapTarget: root.querySelectorAll('.tap-target:not(.no-autoinit)'),
111
+ Timepicker: root.querySelectorAll('.timepicker:not(.no-autoinit)'),
112
+ Tooltip: root.querySelectorAll('.tooltipped:not(.no-autoinit)'),
113
+ FloatingActionButton: root.querySelectorAll('.fixed-action-btn:not(.no-autoinit)')
114
+ };
115
+
116
+ for (var pluginName in registry) {
117
+ var plugin = M[pluginName];
118
+ plugin.init(registry[pluginName]);
119
+ }
120
+ };
121
+
87
122
  /**
88
123
  * Generate approximated selector string for a jQuery object
89
124
  * @param {jQuery} obj jQuery object to be parsed
@@ -19,6 +19,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
19
19
  onOpenEnd: null,
20
20
  onCloseStart: null,
21
21
  onCloseEnd: null,
22
+ preventScrolling: true,
22
23
  dismissible: true,
23
24
  startingTop: '4%',
24
25
  endingTop: '10%'
@@ -70,6 +71,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
70
71
  _this.id = _this.$el.attr('id');
71
72
  _this._openingTrigger = undefined;
72
73
  _this.$overlay = $('<div class="modal-overlay"></div>');
74
+ _this.el.tabIndex = 0;
73
75
 
74
76
  Modal._count++;
75
77
  _this._setupEventHandlers();
@@ -181,6 +183,19 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
181
183
  }
182
184
  }
183
185
 
186
+ /**
187
+ * Handle Focus
188
+ * @param {Event} e
189
+ */
190
+
191
+ }, {
192
+ key: '_handleFocus',
193
+ value: function _handleFocus(e) {
194
+ if (!this.el.contains(e.target)) {
195
+ this.el.focus();
196
+ }
197
+ }
198
+
184
199
  /**
185
200
  * Animate in modal
186
201
  */
@@ -322,18 +337,27 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
322
337
  this.options.onOpenStart.call(this, this.el, this._openingTrigger);
323
338
  }
324
339
 
325
- document.body.style.overflow = 'hidden';
340
+ if (this.options.preventScrolling) {
341
+ document.body.style.overflow = 'hidden';
342
+ }
343
+
326
344
  this.el.classList.add('open');
327
345
  this.el.insertAdjacentElement('afterend', this.$overlay[0]);
328
346
 
329
347
  if (this.options.dismissible) {
330
348
  this._handleKeydownBound = this._handleKeydown.bind(this);
349
+ this._handleFocusBound = this._handleFocus.bind(this);
331
350
  document.addEventListener('keydown', this._handleKeydownBound);
351
+ document.addEventListener('focus', this._handleFocusBound, true);
332
352
  }
333
353
 
334
354
  anim.remove(this.el);
335
355
  anim.remove(this.$overlay[0]);
336
356
  this._animateIn();
357
+
358
+ // Focus modal
359
+ this.el.focus();
360
+
337
361
  return this;
338
362
  }
339
363
 
@@ -365,6 +389,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
365
389
 
366
390
  if (this.options.dismissible) {
367
391
  document.removeEventListener('keydown', this._handleKeydownBound);
392
+ document.removeEventListener('focus', this._handleFocusBound);
368
393
  }
369
394
 
370
395
  anim.remove(this.el);
@@ -246,6 +246,16 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
246
246
  if (!this.el.disabled) {
247
247
  var dropdownOptions = $.extend({}, this.options.dropdownOptions);
248
248
 
249
+ // Add callback for centering selected option when dropdown content is scrollable
250
+ dropdownOptions.onOpenEnd = function (el) {
251
+ var selectedOption = $(_this4.dropdownOptions).find('.selected').first();
252
+ if (_this4.dropdown.isScrollable && selectedOption.length) {
253
+ var scrollOffset = selectedOption[0].getBoundingClientRect().top - _this4.dropdownOptions.getBoundingClientRect().top; // scroll to selected option
254
+ scrollOffset -= _this4.dropdownOptions.clientHeight / 2; // center in dropdown
255
+ _this4.dropdownOptions.scrollTop = scrollOffset;
256
+ }
257
+ };
258
+
249
259
  if (this.isMultiple) {
250
260
  dropdownOptions.closeOnClick = false;
251
261
  }
@@ -19,7 +19,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
19
19
  onOpenStart: null,
20
20
  onOpenEnd: null,
21
21
  onCloseStart: null,
22
- onCloseEnd: null
22
+ onCloseEnd: null,
23
+ preventScrolling: true
23
24
  };
24
25
 
25
26
  /**
@@ -75,6 +76,10 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
75
76
  */
76
77
  _this.isDragged = false;
77
78
 
79
+ // Window size variables for window resize checks
80
+ _this.lastWindowWidth = window.innerWidth;
81
+ _this.lastWindowHeight = window.innerHeight;
82
+
78
83
  _this._createOverlay();
79
84
  _this._createDragTarget();
80
85
  _this._setupEventHandlers();
@@ -199,6 +204,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
199
204
  this._time = Date.now();
200
205
  this._width = this.el.getBoundingClientRect().width;
201
206
  this._overlay.style.display = 'block';
207
+ this._initialScrollTop = this.isOpen ? this.el.scrollTop : M.getDocumentScrollTop();
208
+ this._verticallyScrolling = false;
202
209
  anim.remove(this.el);
203
210
  anim.remove(this._overlay);
204
211
  }
@@ -212,10 +219,14 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
212
219
  key: '_dragMoveUpdate',
213
220
  value: function _dragMoveUpdate(e) {
214
221
  var clientX = e.targetTouches[0].clientX;
222
+ var currentScrollTop = this.isOpen ? this.el.scrollTop : M.getDocumentScrollTop();
215
223
  this.deltaX = Math.abs(this._xPos - clientX);
216
224
  this._xPos = clientX;
217
225
  this.velocityX = this.deltaX / (Date.now() - this._time);
218
226
  this._time = Date.now();
227
+ if (this._initialScrollTop !== currentScrollTop) {
228
+ this._verticallyScrolling = true;
229
+ }
219
230
  }
220
231
 
221
232
  /**
@@ -227,7 +238,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
227
238
  key: '_handleDragTargetDrag',
228
239
  value: function _handleDragTargetDrag(e) {
229
240
  // Check if draggable
230
- if (!this.options.draggable || this._isCurrentlyFixed()) {
241
+ if (!this.options.draggable || this._isCurrentlyFixed() || this._verticallyScrolling) {
231
242
  return;
232
243
  }
233
244
 
@@ -286,6 +297,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
286
297
  }
287
298
 
288
299
  this.isDragged = false;
300
+ this._verticallyScrolling = false;
289
301
  }
290
302
  }
291
303
 
@@ -299,7 +311,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
299
311
  value: function _handleCloseDrag(e) {
300
312
  if (this.isOpen) {
301
313
  // Check if draggable
302
- if (!this.options.draggable || this._isCurrentlyFixed()) {
314
+ if (!this.options.draggable || this._isCurrentlyFixed() || this._verticallyScrolling) {
303
315
  return;
304
316
  }
305
317
 
@@ -352,6 +364,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
352
364
  }
353
365
 
354
366
  this.isDragged = false;
367
+ this._verticallyScrolling = false;
355
368
  }
356
369
  }
357
370
 
@@ -363,7 +376,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
363
376
  key: '_handleCloseTriggerClick',
364
377
  value: function _handleCloseTriggerClick(e) {
365
378
  var $closeTrigger = $(e.target).closest('.sidenav-close');
366
- if ($closeTrigger.length) {
379
+ if ($closeTrigger.length && !this._isCurrentlyFixed()) {
367
380
  this.close();
368
381
  }
369
382
  }
@@ -375,11 +388,17 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
375
388
  }, {
376
389
  key: '_handleWindowResize',
377
390
  value: function _handleWindowResize() {
378
- if (window.innerWidth > 992) {
379
- this.open();
380
- } else {
381
- this.close();
391
+ // Only handle horizontal resizes
392
+ if (this.lastWindowWidth !== window.innerWidth) {
393
+ if (window.innerWidth > 992) {
394
+ this.open();
395
+ } else {
396
+ this.close();
397
+ }
382
398
  }
399
+
400
+ this.lastWindowWidth = window.innerWidth;
401
+ this.lastWindowHeight = window.innerHeight;
383
402
  }
384
403
  }, {
385
404
  key: '_setupClasses',
@@ -455,7 +474,9 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
455
474
 
456
475
  // Handle non-fixed Sidenav
457
476
  } else {
458
- this._preventBodyScrolling();
477
+ if (this.options.preventScrolling) {
478
+ this._preventBodyScrolling();
479
+ }
459
480
 
460
481
  if (!this.isDragged || this.percentOpen != 1) {
461
482
  this._animateIn();