|
@@ -13,6 +13,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
Object.defineProperty(exports, '__esModule', {
|
|
Object.defineProperty(exports, '__esModule', {
|
|
value: true
|
|
value: true
|
|
});
|
|
});
|
|
|
|
+var MEDIA_PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)";
|
|
var CREATED = 1;
|
|
var CREATED = 1;
|
|
var MOUNTED = 2;
|
|
var MOUNTED = 2;
|
|
var IDLE = 3;
|
|
var IDLE = 3;
|
|
@@ -582,7 +583,6 @@ function Throttle(func, duration) {
|
|
function Media(Splide2, Components2, options) {
|
|
function Media(Splide2, Components2, options) {
|
|
var binder = EventBinder();
|
|
var binder = EventBinder();
|
|
var breakpoints = options.breakpoints || {};
|
|
var breakpoints = options.breakpoints || {};
|
|
- var initialOptions = Splide2._io;
|
|
|
|
var queries = [];
|
|
var queries = [];
|
|
|
|
|
|
function setup() {
|
|
function setup() {
|
|
@@ -590,9 +590,9 @@ function Media(Splide2, Components2, options) {
|
|
ownKeys(breakpoints).sort(function (n, m) {
|
|
ownKeys(breakpoints).sort(function (n, m) {
|
|
return isMin ? +n - +m : +m - +n;
|
|
return isMin ? +n - +m : +m - +n;
|
|
}).forEach(function (key) {
|
|
}).forEach(function (key) {
|
|
- register(key, breakpoints[key], "(" + (isMin ? "min" : "max") + "-width:" + key + "px)");
|
|
|
|
|
|
+ register(breakpoints[key], "(" + (isMin ? "min" : "max") + "-width:" + key + "px)");
|
|
});
|
|
});
|
|
- register("motion", options.reducedMotion || {}, "(prefers-reduced-motion: reduce)");
|
|
|
|
|
|
+ register(options.reducedMotion || {}, MEDIA_PREFERS_REDUCED_MOTION);
|
|
update();
|
|
update();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -602,40 +602,36 @@ function Media(Splide2, Components2, options) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- function register(key, options2, query) {
|
|
|
|
|
|
+ function register(options2, query) {
|
|
var queryList = matchMedia(query);
|
|
var queryList = matchMedia(query);
|
|
binder.bind(queryList, "change", update);
|
|
binder.bind(queryList, "change", update);
|
|
- queries.push([key, options2, queryList]);
|
|
|
|
|
|
+ queries.push([options2, queryList]);
|
|
}
|
|
}
|
|
|
|
|
|
function update() {
|
|
function update() {
|
|
- var merged = accumulate();
|
|
|
|
var direction = options.direction;
|
|
var direction = options.direction;
|
|
- var destruction = merged.destroy;
|
|
|
|
|
|
+ var merged = queries.reduce(function (merged2, entry) {
|
|
|
|
+ return merge(merged2, entry[1].matches ? entry[0] : {});
|
|
|
|
+ }, {});
|
|
forOwn(options, function (value, key) {
|
|
forOwn(options, function (value, key) {
|
|
- !(key in initialOptions) && delete options[key];
|
|
|
|
|
|
+ delete options[key];
|
|
});
|
|
});
|
|
|
|
+ merge(options, merged);
|
|
|
|
|
|
- if (destruction) {
|
|
|
|
- Splide2.destroy(destruction === "completely");
|
|
|
|
|
|
+ if (options.destroy) {
|
|
|
|
+ Splide2.destroy(options.destroy === "completely");
|
|
} else if (Splide2.state.is(DESTROYED)) {
|
|
} else if (Splide2.state.is(DESTROYED)) {
|
|
destroy(true);
|
|
destroy(true);
|
|
Splide2.mount();
|
|
Splide2.mount();
|
|
} else {
|
|
} else {
|
|
Splide2.options = merged;
|
|
Splide2.options = merged;
|
|
- direction !== merged.direction && Splide2.refresh();
|
|
|
|
|
|
+ direction !== options.direction && Splide2.refresh();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- function accumulate() {
|
|
|
|
- return queries.reduce(function (merged, entry) {
|
|
|
|
- return merge(merged, entry[2].matches ? entry[1] : {});
|
|
|
|
- }, merge({}, initialOptions));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function matches(key) {
|
|
|
|
|
|
+ function matches(media) {
|
|
return queries.some(function (entry) {
|
|
return queries.some(function (entry) {
|
|
- return entry[0] === key && entry[2].matches;
|
|
|
|
|
|
+ return entry[1].media === media && entry[1].matches;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2214,11 +2210,11 @@ function Drag(Splide2, Components2, options) {
|
|
var velocity = computeVelocity(e);
|
|
var velocity = computeVelocity(e);
|
|
var destination = computeDestination(velocity);
|
|
var destination = computeDestination(velocity);
|
|
var rewind = options.rewind && options.rewindByDrag;
|
|
var rewind = options.rewind && options.rewindByDrag;
|
|
- var reduced = Components2.Media.matches("motion");
|
|
|
|
|
|
+ var reduced = Components2.Media.matches(MEDIA_PREFERS_REDUCED_MOTION);
|
|
var go = Controller.go;
|
|
var go = Controller.go;
|
|
|
|
|
|
if (reduced) {
|
|
if (reduced) {
|
|
- options.speed = Splide2._io.speed;
|
|
|
|
|
|
+ delete options.speed;
|
|
}
|
|
}
|
|
|
|
|
|
if (isFree) {
|
|
if (isFree) {
|
|
@@ -2974,8 +2970,7 @@ var _Splide = /*#__PURE__*/function () {
|
|
assert(false, "Invalid JSON");
|
|
assert(false, "Invalid JSON");
|
|
}
|
|
}
|
|
|
|
|
|
- this._io = merge({}, options);
|
|
|
|
- this._options = options;
|
|
|
|
|
|
+ this._options = Object.create(merge({}, options));
|
|
}
|
|
}
|
|
|
|
|
|
var _proto = _Splide.prototype;
|
|
var _proto = _Splide.prototype;
|