ArtSlices = (images, align) => {
const height = 450,
xSteps = d3.range(0, width, width / images.length);
const regularScale = d3.scaleIdentity().range(0, width).domain(xSteps);
const svg = d3
.select(DOM.svg(width, height))
.attr("viewBox", `0 ${height / 2} ${width} ${height}`)
.attr("width", "100%")
.attr("height", height * 2);
const g = svg
.append("g")
.attr("transform", `translate(${margin.left},${margin.top})`);
var imageSlides = g
.selectAll("image")
.data(images)
.join("image")
.attr("xlink:href", (d) => d)
.attr("preserveAspectRatio", `${align} ${meetOrSlice}`);
defaultScale();
function defaultScale() {
imageSlides
.attr("x", (d, i) => regularScale(xSteps[i]))
.attr("y", 0)
.attr("width", (d, i) => width / images.length)
.attr("height", height / 2);
}
svg.on("pointermove click", function (e, d, i) {
return handleMove([e.x, e.y]);
});
function handleMove(mouse) {
xFisheye.focus(mouse[0]);
imageSlides
.attr("x", (d, i) => xFisheye(xSteps[i]))
.attr("height", height * 2)
.attr("width", (d, i) => {
let x1 = xFisheye(xSteps[i + 1]);
if (!x1) x1 = width;
return x1 - xFisheye(xSteps[i]);
});
}
return svg.node();
}