|
@@ -709,8 +709,8 @@ const Elements = (Splide, Components, options, event) => {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
function init() {
|
|
function init() {
|
|
|
|
+ const { role = "region" } = options;
|
|
const id = root.id || uniqueId(PROJECT_CODE);
|
|
const id = root.id || uniqueId(PROJECT_CODE);
|
|
- const role = options.role;
|
|
|
|
root.id = id;
|
|
root.id = id;
|
|
track.id = track.id || `${id}-track`;
|
|
track.id = track.id || `${id}-track`;
|
|
list.id = list.id || `${id}-list`;
|
|
list.id = list.id || `${id}-list`;
|
|
@@ -838,7 +838,8 @@ const Slide$1 = (Splide2, index, slideIndex, slide) => {
|
|
}
|
|
}
|
|
function isActive() {
|
|
function isActive() {
|
|
const { index: curr } = Splide2;
|
|
const { index: curr } = Splide2;
|
|
- return curr === index || options.cloneStatus && curr === slideIndex;
|
|
|
|
|
|
+ const { cloneStatus = true } = options;
|
|
|
|
+ return curr === index || cloneStatus && curr === slideIndex;
|
|
}
|
|
}
|
|
function isVisible() {
|
|
function isVisible() {
|
|
if (Splide2.is(FADE)) {
|
|
if (Splide2.is(FADE)) {
|
|
@@ -1511,7 +1512,7 @@ const Arrows = (Splide, Components, options, event) => {
|
|
mount();
|
|
mount();
|
|
}
|
|
}
|
|
function init() {
|
|
function init() {
|
|
- const enabled = options.arrows;
|
|
|
|
|
|
+ const { arrows: enabled = true } = options;
|
|
if (enabled && !(prev && next)) {
|
|
if (enabled && !(prev && next)) {
|
|
createArrows();
|
|
createArrows();
|
|
}
|
|
}
|
|
@@ -1583,7 +1584,8 @@ const INTERVAL_DATA_ATTRIBUTE = `${DATA_ATTRIBUTE}-interval`;
|
|
|
|
|
|
const Autoplay = (Splide, Components, options, event) => {
|
|
const Autoplay = (Splide, Components, options, event) => {
|
|
const { on, bind, emit } = event;
|
|
const { on, bind, emit } = event;
|
|
- const interval = RequestInterval(options.interval, Splide.go.bind(Splide, ">"), onAnimationFrame);
|
|
|
|
|
|
+ const { interval: duration = 5e3, pauseOnHover = true, pauseOnFocus = true, resetProgress = true } = options;
|
|
|
|
+ const interval = RequestInterval(duration, Splide.go.bind(Splide, ">"), onAnimationFrame);
|
|
const { isPaused } = interval;
|
|
const { isPaused } = interval;
|
|
const { Elements, Elements: { root, toggle } } = Components;
|
|
const { Elements, Elements: { root, toggle } } = Components;
|
|
const { autoplay } = options;
|
|
const { autoplay } = options;
|
|
@@ -1599,13 +1601,13 @@ const Autoplay = (Splide, Components, options, event) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function listen() {
|
|
function listen() {
|
|
- if (options.pauseOnHover) {
|
|
|
|
|
|
+ if (pauseOnHover) {
|
|
bind(root, "mouseenter mouseleave", (e) => {
|
|
bind(root, "mouseenter mouseleave", (e) => {
|
|
hovered = e.type === "mouseenter";
|
|
hovered = e.type === "mouseenter";
|
|
autoToggle();
|
|
autoToggle();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- if (options.pauseOnFocus) {
|
|
|
|
|
|
+ if (pauseOnFocus) {
|
|
bind(root, "focusin focusout", (e) => {
|
|
bind(root, "focusin focusout", (e) => {
|
|
focused = e.type === "focusin";
|
|
focused = e.type === "focusin";
|
|
autoToggle();
|
|
autoToggle();
|
|
@@ -1621,7 +1623,7 @@ const Autoplay = (Splide, Components, options, event) => {
|
|
}
|
|
}
|
|
function play() {
|
|
function play() {
|
|
if (isPaused() && Components.Slides.isEnough()) {
|
|
if (isPaused() && Components.Slides.isEnough()) {
|
|
- interval.start(!options.resetProgress);
|
|
|
|
|
|
+ interval.start(!resetProgress);
|
|
focused = hovered = stopped = false;
|
|
focused = hovered = stopped = false;
|
|
update();
|
|
update();
|
|
emit(EVENT_AUTOPLAY_PLAY);
|
|
emit(EVENT_AUTOPLAY_PLAY);
|
|
@@ -1804,7 +1806,9 @@ const Drag = (Splide, Components, options, event) => {
|
|
Move.translate(basePosition + constrain(diffCoord(e)));
|
|
Move.translate(basePosition + constrain(diffCoord(e)));
|
|
const expired = diffTime(e) > LOG_INTERVAL;
|
|
const expired = diffTime(e) > LOG_INTERVAL;
|
|
const hasExceeded = exceeded !== (exceeded = exceededLimit());
|
|
const hasExceeded = exceeded !== (exceeded = exceededLimit());
|
|
- expired || hasExceeded && save(e);
|
|
|
|
|
|
+ if (expired || hasExceeded) {
|
|
|
|
+ save(e);
|
|
|
|
+ }
|
|
clickPrevented = true;
|
|
clickPrevented = true;
|
|
emit(EVENT_DRAGGING);
|
|
emit(EVENT_DRAGGING);
|
|
prevent(e);
|
|
prevent(e);
|
|
@@ -1838,12 +1842,14 @@ const Drag = (Splide, Components, options, event) => {
|
|
basePosition = getPosition();
|
|
basePosition = getPosition();
|
|
}
|
|
}
|
|
function move(e) {
|
|
function move(e) {
|
|
|
|
+ const { updateOnDragged = true } = options;
|
|
const velocity = computeVelocity(e);
|
|
const velocity = computeVelocity(e);
|
|
const destination = computeDestination(velocity);
|
|
const destination = computeDestination(velocity);
|
|
const rewind = options.rewind && options.rewindByDrag;
|
|
const rewind = options.rewind && options.rewindByDrag;
|
|
|
|
+ const scroll = updateOnDragged ? Controller.scroll : Scroll.scroll;
|
|
reduce(false);
|
|
reduce(false);
|
|
if (isFree) {
|
|
if (isFree) {
|
|
- Controller.scroll(destination, void 0, options.snap);
|
|
|
|
|
|
+ scroll(destination, void 0, options.snap);
|
|
} else if (Splide.is(FADE)) {
|
|
} else if (Splide.is(FADE)) {
|
|
Controller.go(orient(sign(velocity)) < 0 ? rewind ? "<" : "-" : rewind ? ">" : "+");
|
|
Controller.go(orient(sign(velocity)) < 0 ? rewind ? "<" : "-" : rewind ? ">" : "+");
|
|
} else if (Splide.is(SLIDE) && exceeded && rewind) {
|
|
} else if (Splide.is(SLIDE) && exceeded && rewind) {
|
|
@@ -2061,7 +2067,7 @@ const Pagination = (Splide, Components, options, event) => {
|
|
function mount() {
|
|
function mount() {
|
|
destroy();
|
|
destroy();
|
|
on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], mount);
|
|
on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], mount);
|
|
- const enabled = options.pagination;
|
|
|
|
|
|
+ const { pagination: enabled = true } = options;
|
|
placeholder && display(placeholder, enabled ? "" : "none");
|
|
placeholder && display(placeholder, enabled ? "" : "none");
|
|
if (enabled) {
|
|
if (enabled) {
|
|
on([EVENT_MOVE, EVENT_SCROLL, EVENT_SCROLLED], update);
|
|
on([EVENT_MOVE, EVENT_SCROLL, EVENT_SCROLLED], update);
|
|
@@ -2081,7 +2087,7 @@ const Pagination = (Splide, Components, options, event) => {
|
|
}
|
|
}
|
|
function createPagination() {
|
|
function createPagination() {
|
|
const { length } = Splide;
|
|
const { length } = Splide;
|
|
- const { classes, i18n, perPage } = options;
|
|
|
|
|
|
+ const { classes, i18n, perPage, paginationKeyboard = true } = options;
|
|
const max = hasFocus() ? Controller.getEnd() + 1 : ceil(length / perPage);
|
|
const max = hasFocus() ? Controller.getEnd() + 1 : ceil(length / perPage);
|
|
list = placeholder || create("ul", classes.pagination, Elements.track.parentElement);
|
|
list = placeholder || create("ul", classes.pagination, Elements.track.parentElement);
|
|
addClass(list, paginationClasses = `${CLASS_PAGINATION}--${getDirection()}`);
|
|
addClass(list, paginationClasses = `${CLASS_PAGINATION}--${getDirection()}`);
|
|
@@ -2094,7 +2100,7 @@ const Pagination = (Splide, Components, options, event) => {
|
|
const controls = Slides.getIn(i).map((Slide) => Slide.slide.id);
|
|
const controls = Slides.getIn(i).map((Slide) => Slide.slide.id);
|
|
const text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX;
|
|
const text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX;
|
|
bind(button, "click", apply(onClick, i));
|
|
bind(button, "click", apply(onClick, i));
|
|
- if (options.paginationKeyboard) {
|
|
|
|
|
|
+ if (paginationKeyboard) {
|
|
bind(button, "keydown", apply(onKeydown, i));
|
|
bind(button, "keydown", apply(onKeydown, i));
|
|
}
|
|
}
|
|
setAttribute(li, ROLE, "presentation");
|
|
setAttribute(li, ROLE, "presentation");
|
|
@@ -2274,7 +2280,8 @@ const SR_REMOVAL_DELAY = 90;
|
|
const Live = (Splide, Components, options, event) => {
|
|
const Live = (Splide, Components, options, event) => {
|
|
const { on } = event;
|
|
const { on } = event;
|
|
const { track } = Components.Elements;
|
|
const { track } = Components.Elements;
|
|
- const enabled = options.live && !options.isNavigation;
|
|
|
|
|
|
+ const { live = true } = options;
|
|
|
|
+ const enabled = live && !options.isNavigation;
|
|
const sr = create("span", CLASS_SR);
|
|
const sr = create("span", CLASS_SR);
|
|
const interval = RequestInterval(SR_REMOVAL_DELAY, apply(toggle, false));
|
|
const interval = RequestInterval(SR_REMOVAL_DELAY, apply(toggle, false));
|
|
function mount() {
|
|
function mount() {
|
|
@@ -2352,23 +2359,13 @@ const I18N = {
|
|
|
|
|
|
const DEFAULTS = {
|
|
const DEFAULTS = {
|
|
type: "slide",
|
|
type: "slide",
|
|
- role: "region",
|
|
|
|
speed: 400,
|
|
speed: 400,
|
|
perPage: 1,
|
|
perPage: 1,
|
|
- cloneStatus: true,
|
|
|
|
- arrows: true,
|
|
|
|
- pagination: true,
|
|
|
|
- paginationKeyboard: true,
|
|
|
|
- interval: 5e3,
|
|
|
|
- pauseOnHover: true,
|
|
|
|
- pauseOnFocus: true,
|
|
|
|
- resetProgress: true,
|
|
|
|
easing: "cubic-bezier(0.25, 1, 0.5, 1)",
|
|
easing: "cubic-bezier(0.25, 1, 0.5, 1)",
|
|
drag: true,
|
|
drag: true,
|
|
direction: "ltr",
|
|
direction: "ltr",
|
|
trimSpace: true,
|
|
trimSpace: true,
|
|
focusableNodes: "a, button, textarea, input, select, iframe",
|
|
focusableNodes: "a, button, textarea, input, select, iframe",
|
|
- live: true,
|
|
|
|
classes: CLASSES,
|
|
classes: CLASSES,
|
|
i18n: I18N,
|
|
i18n: I18N,
|
|
reducedMotion: {
|
|
reducedMotion: {
|