|
@@ -356,6 +356,8 @@
|
|
|
var viewport = root.querySelector(".screen-topic-viewport");
|
|
var viewport = root.querySelector(".screen-topic-viewport");
|
|
|
var track = root.querySelector(".screen-topic-track");
|
|
var track = root.querySelector(".screen-topic-track");
|
|
|
var dotsRoot = root.querySelector(".screen-topic-dots");
|
|
var dotsRoot = root.querySelector(".screen-topic-dots");
|
|
|
|
|
+ var prevButton = root.querySelector(".screen-topic-arrow.prev");
|
|
|
|
|
+ var nextButton = root.querySelector(".screen-topic-arrow.next");
|
|
|
if (!viewport || !track) return;
|
|
if (!viewport || !track) return;
|
|
|
|
|
|
|
|
var items = Array.prototype.slice.call(track.querySelectorAll(".screen-topic-card:not(.is-topic-clone)"));
|
|
var items = Array.prototype.slice.call(track.querySelectorAll(".screen-topic-card:not(.is-topic-clone)"));
|
|
@@ -371,7 +373,7 @@
|
|
|
var width = window.innerWidth || document.documentElement.clientWidth || 0;
|
|
var width = window.innerWidth || document.documentElement.clientWidth || 0;
|
|
|
if (width <= 640) return 1;
|
|
if (width <= 640) return 1;
|
|
|
if (width <= 1080) return Math.min(2, Math.max(1, items.length));
|
|
if (width <= 1080) return Math.min(2, Math.max(1, items.length));
|
|
|
- return items.length === 1 ? 1 : 5;
|
|
|
|
|
|
|
+ return items.length === 1 ? 1 : 4;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function clearClones() {
|
|
function clearClones() {
|
|
@@ -406,6 +408,15 @@
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function syncArrows() {
|
|
|
|
|
+ [prevButton, nextButton].forEach(function (button) {
|
|
|
|
|
+ if (!button) return;
|
|
|
|
|
+ var disabled = pageCount <= 1;
|
|
|
|
|
+ button.hidden = disabled;
|
|
|
|
|
+ button.disabled = disabled;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function setTransform(animate) {
|
|
function setTransform(animate) {
|
|
|
var step = measureStep();
|
|
var step = measureStep();
|
|
|
track.style.transition = animate ? "transform 0.58s cubic-bezier(0.22, 1, 0.36, 1)" : "none";
|
|
track.style.transition = animate ? "transform 0.58s cubic-bezier(0.22, 1, 0.36, 1)" : "none";
|
|
@@ -416,6 +427,7 @@
|
|
|
index = next;
|
|
index = next;
|
|
|
setTransform(false);
|
|
setTransform(false);
|
|
|
syncDots();
|
|
syncDots();
|
|
|
|
|
+ syncArrows();
|
|
|
window.requestAnimationFrame(function () {
|
|
window.requestAnimationFrame(function () {
|
|
|
track.style.removeProperty("transition");
|
|
track.style.removeProperty("transition");
|
|
|
});
|
|
});
|
|
@@ -423,9 +435,23 @@
|
|
|
|
|
|
|
|
function show(next) {
|
|
function show(next) {
|
|
|
if (pageCount <= 1) return;
|
|
if (pageCount <= 1) return;
|
|
|
|
|
+ if (next < 0) {
|
|
|
|
|
+ jumpTo(pageCount);
|
|
|
|
|
+ window.requestAnimationFrame(function () {
|
|
|
|
|
+ show(pageCount - 1);
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
index = next;
|
|
index = next;
|
|
|
setTransform(true);
|
|
setTransform(true);
|
|
|
syncDots();
|
|
syncDots();
|
|
|
|
|
+ syncArrows();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function move(delta) {
|
|
|
|
|
+ if (pageCount <= 1) return;
|
|
|
|
|
+ show(index + delta);
|
|
|
|
|
+ start();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function stop() {
|
|
function stop() {
|
|
@@ -446,6 +472,7 @@
|
|
|
dotsRoot.innerHTML = "";
|
|
dotsRoot.innerHTML = "";
|
|
|
if (pageCount <= 1) {
|
|
if (pageCount <= 1) {
|
|
|
dotsRoot.hidden = true;
|
|
dotsRoot.hidden = true;
|
|
|
|
|
+ syncArrows();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
dotsRoot.hidden = false;
|
|
dotsRoot.hidden = false;
|
|
@@ -462,6 +489,7 @@
|
|
|
})(i));
|
|
})(i));
|
|
|
dotsRoot.appendChild(dot);
|
|
dotsRoot.appendChild(dot);
|
|
|
}
|
|
}
|
|
|
|
|
+ syncArrows();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function rebuild() {
|
|
function rebuild() {
|
|
@@ -488,6 +516,16 @@
|
|
|
|
|
|
|
|
root.addEventListener("mouseenter", stop);
|
|
root.addEventListener("mouseenter", stop);
|
|
|
root.addEventListener("mouseleave", start);
|
|
root.addEventListener("mouseleave", start);
|
|
|
|
|
+ if (prevButton) {
|
|
|
|
|
+ prevButton.addEventListener("click", function () {
|
|
|
|
|
+ move(-1);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (nextButton) {
|
|
|
|
|
+ nextButton.addEventListener("click", function () {
|
|
|
|
|
+ move(1);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
root.addEventListener("focusin", stop);
|
|
root.addEventListener("focusin", stop);
|
|
|
root.addEventListener("focusout", function (event) {
|
|
root.addEventListener("focusout", function (event) {
|
|
|
if (event.relatedTarget instanceof Node && root.contains(event.relatedTarget)) return;
|
|
if (event.relatedTarget instanceof Node && root.contains(event.relatedTarget)) return;
|