MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / slideDirection

Function slideDirection

website/static/js/component/carousel.js:133–142  ·  view source on GitHub ↗

* @param {Carousel} carousel * @param {"prev" | "next"} direction * @param {boolean} smooth

(carousel, direction, smooth, clamped = false)

Source from the content-addressed store, hash-verified

131 * @param {boolean} smooth
132 */
133function slideDirection(carousel, direction, smooth, clamped = false) {
134 const directionIndexOffset = { prev: -1, next: 1 }[direction];
135 const offsetDotIndex = currentClosestImageIndex(carousel) + directionIndexOffset;
136
137 const nextDotIndex = (offsetDotIndex + carousel.dots.length) % carousel.dots.length;
138 const unwrappedNextDotIndex = clamp(offsetDotIndex, 0, carousel.dots.length - 1);
139
140 if (clamped) slideTo(carousel, unwrappedNextDotIndex, smooth);
141 else slideTo(carousel, nextDotIndex, smooth);
142}
143
144/**
145 * @param {Carousel} carousel

Callers 2

initializeCarouselFunction · 0.85
dragEndFunction · 0.85

Calls 3

currentClosestImageIndexFunction · 0.85
slideToFunction · 0.85
clampFunction · 0.70

Tested by

no test coverage detected