Sha256: 29c97ca8820718dd5b44c5b08c5a26f75cb1805078069bd32950da22f62b5f11

Contents?: true

Size: 943 Bytes

Versions: 64

Compression:

Stored size: 943 Bytes

Contents

import {
	isInViewport
} from "../utils/dom";

export default class Loop {
	constructor(slider) {
		this.slider = slider;
	}

	init() {
		return this;
	}

	apply() {
		if (this.slider.options.loop) {
			if (this.slider.state.next > 0) {
				if (this.slider.state.next < this.slider.state.length) {
					if (this.slider.state.next > this.slider.state.length - this.slider.slidesToShow && isInViewport(this.slider._slides[this.slider.state.length - 1], this.slider.wrapper)) {
						this.slider.state.next = 0;
					} else {
						this.slider.state.next = Math.min(Math.max(this.slider.state.next, 0), this.slider.state.length - this.slider.slidesToShow);
					}
				} else {
					this.slider.state.next = 0;
				}
			} else {
				if (this.slider.state.next <= 0 - (this.slider.slidesToScroll)) {
					this.slider.state.next = this.slider.state.length - this.slider.slidesToShow;
				} else {
					this.slider.state.next = 0;
				}
			}
		}
	}
}

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
intia-theme-0.1.4 node_modules/bulma-carousel/src/js/components/loop.js
intia-theme-0.1.3 node_modules/bulma-carousel/src/js/components/loop.js
intia-theme-0.1.2 node_modules/bulma-carousel/src/js/components/loop.js
intia-theme-0.1.1 node_modules/bulma-carousel/src/js/components/loop.js