Skip to content

Commit

Permalink
add travis yml
Browse files Browse the repository at this point in the history
  • Loading branch information
berndartmueller committed Aug 23, 2020
1 parent 3a8328d commit 58c5633
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: node_js

node_js:
- '12.16.1'

install:
- npm install

script:
- npm test
- npm run build

cache:
directories:
- node_modules
9 changes: 1 addition & 8 deletions src/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@ import { range, rewind } from './utils/utils';
* @param total Total bullets. Same as amount of slides.
*/
export function mapActiveIndex(index: number, center: number, total: number) {
return index - Math.max(index - center, 0) + Math.max(index - (total - 1 - center), 0);
return index - Math.max(index - center, 0) + Math.max(index - (-1 + total - center), 0);
}

/**
* Figure out if given bullet element index is edge.
*
* @param index Current bullet element index.
*/
export function isEdgeBullet(index: number) {}

export class Pagination {
private ref: HTMLElement;
private currentIndex: number = 0;
Expand Down
15 changes: 12 additions & 3 deletions src/virchual.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Pagination } from './pagination';
import './css/styles.css';

import { Drag } from './drag';
import { Pagination } from './pagination';
import { Slide } from './slide';
import { Sign } from './types';
import { assert } from './utils/error';
import { Event } from './utils/event';
import { slidingWindow } from './utils/sliding-window';
Expand Down Expand Up @@ -87,6 +87,9 @@ export class Virchual {
this.pagination.render();
}

/**
* Mount components.
*/
mount() {
this.event.emit('mounted');

Expand Down Expand Up @@ -116,12 +119,18 @@ export class Virchual {
this.event.off(events, elm);
}

/**
* Go to previous slide.
*/
prev() {
console.debug('[Controls] Previous');

this.go('prev');
}

/**
* Go to next slide.
*/
next() {
console.debug('[Controls] Next');

Expand All @@ -135,7 +144,7 @@ export class Virchual {
this.isBusy = false;
});

const sign = direction === 'prev' ? -1 : +1;
const sign: Sign = direction === 'prev' ? -1 : +1;

this.currentIndex = rewind(this.currentIndex + sign * 1, this.slides.length - 1);

Expand Down

0 comments on commit 58c5633

Please sign in to comment.