vrembem 1.38.0 → 1.39.0

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/dev/scripts.js CHANGED
@@ -351,14 +351,6 @@ var closeTransition = function closeTransition(el, settings) {
351
351
  });
352
352
  };
353
353
 
354
- var breakpoints = {
355
- xs: '480px',
356
- sm: '620px',
357
- md: '760px',
358
- lg: '990px',
359
- xl: '1380px'
360
- };
361
-
362
354
  var index = {
363
355
  __proto__: null,
364
356
  setInert: setInert,
@@ -376,8 +368,7 @@ var index = {
376
368
  removeClass: removeClass,
377
369
  toggleClass: toggleClass,
378
370
  openTransition: openTransition,
379
- closeTransition: closeTransition,
380
- breakpoints: breakpoints
371
+ closeTransition: closeTransition
381
372
  };
382
373
 
383
374
  function _extends() {
@@ -495,7 +486,7 @@ var defaults$2 = {
495
486
  selectorInert: null,
496
487
  selectorOverflow: null,
497
488
  // Feature toggles
498
- breakpoints: breakpoints,
489
+ breakpoints: null,
499
490
  customEventPrefix: 'drawer:',
500
491
  eventListeners: true,
501
492
  stateSave: true,
@@ -557,6 +548,7 @@ var Breakpoint = /*#__PURE__*/function () {
557
548
  function Breakpoint(parent) {
558
549
  this.mediaQueryLists = [];
559
550
  this.parent = parent;
551
+ this.prefix = this.getVariablePrefix();
560
552
  this.__check = this.check.bind(this);
561
553
  }
562
554
 
@@ -569,7 +561,9 @@ var Breakpoint = /*#__PURE__*/function () {
569
561
  drawers.forEach(function (drawer) {
570
562
  var id = drawer.getAttribute("data-" + _this.parent.settings.dataDrawer);
571
563
  var key = drawer.getAttribute("data-" + _this.parent.settings.dataBreakpoint);
572
- var bp = _this.parent.settings.breakpoints[key] ? _this.parent.settings.breakpoints[key] : key;
564
+
565
+ var bp = _this.getBreakpoint(key);
566
+
573
567
  var mql = window.matchMedia('(min-width:' + bp + ')');
574
568
 
575
569
  _this.match(mql, drawer);
@@ -625,6 +619,25 @@ var Breakpoint = /*#__PURE__*/function () {
625
619
  }
626
620
  };
627
621
 
622
+ _proto.getBreakpoint = function getBreakpoint(key) {
623
+ var breakpoint = key;
624
+
625
+ if (this.parent.settings.breakpoints && this.parent.settings.breakpoints[key]) {
626
+ breakpoint = this.parent.settings.breakpoints[key];
627
+ } else if (getComputedStyle(document.body).getPropertyValue(this.prefix + key)) {
628
+ breakpoint = getComputedStyle(document.body).getPropertyValue(this.prefix + key);
629
+ }
630
+
631
+ return breakpoint;
632
+ };
633
+
634
+ _proto.getVariablePrefix = function getVariablePrefix() {
635
+ var prefix = '--';
636
+ prefix += getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix');
637
+ prefix += 'breakpoint-';
638
+ return prefix;
639
+ };
640
+
628
641
  return Breakpoint;
629
642
  }();
630
643
 
@@ -1301,7 +1314,8 @@ function getConfig(el, settings) {
1301
1314
 
1302
1315
  for (var prop in config) {
1303
1316
  // Get the CSS variable property values
1304
- var val = styles.getPropertyValue("--popover-" + prop).trim(); // If a value was found, replace the default in config obj
1317
+ var prefix = getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix');
1318
+ var val = styles.getPropertyValue("--" + prefix + "popover-" + prop).trim(); // If a value was found, replace the default in config obj
1305
1319
 
1306
1320
  if (val) {
1307
1321
  config[prop] = val;