Skip to content

Commit

Permalink
Add selected and drag classes to elements
Browse files Browse the repository at this point in the history
  • Loading branch information
David Cetinkaya committed Apr 10, 2019
1 parent 2f1eba4 commit 607b2a9
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 40 deletions.
2 changes: 1 addition & 1 deletion docs/assets/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,6 @@ <h4 class="feature__heading">Startindex</h4>

var onInit = function() {
var index = embla.getSelectedIndex()
if (options.draggable !== false) {
view.classList.add('draggable')
}
dots[index].classList.add('embla__dot--selected')
}
var onSelect = function() {
Expand All @@ -514,17 +511,9 @@ <h4 class="feature__heading">Startindex</h4>
.classList.remove('embla__dot--selected')
dots[index].classList.add('embla__dot--selected')
}
var onDragStart = function() {
view.classList.add('is-dragging')
}
var onDragEnd = function() {
view.classList.remove('is-dragging')
}

embla.on('init', onInit)
embla.on('select', onSelect)
embla.on('dragStart', onDragStart)
embla.on('dragEnd', onDragEnd)
nextBtn.addEventListener('click', embla.next, false)
prevBtn.addEventListener('click', embla.previous, false)

Expand Down
2 changes: 1 addition & 1 deletion docs/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/scss/_embla.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
overflow: hidden;
position: relative;

&.draggable {
&.is-draggable {
cursor: move;
cursor: grab;
}
Expand Down
15 changes: 12 additions & 3 deletions src/components/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,36 @@ export type Alignments = 'start' | 'center' | 'end'

export type Options = {
align: Alignments
container: string
containerSelector: string
draggable: boolean
draggableClass: string
draggingClass: string
loop: boolean
selectedClass: string
speed: number
startIndex: number
}

export type UserOptions = {
align?: Alignments
container?: string
containerSelector?: string
draggable?: boolean
draggableClass?: string
draggingClass?: string
loop?: boolean
selectedClass?: string
speed?: number
startIndex?: number
}

export const defaultOptions = Object.freeze({
align: 'center',
container: '*',
containerSelector: '*',
draggable: true,
draggableClass: 'is-draggable',
draggingClass: 'is-dragging',
loop: false,
selectedClass: 'is-selected',
speed: 10,
startIndex: 0,
})
Loading

0 comments on commit 607b2a9

Please sign in to comment.