Skip to content

Commit

Permalink
feat(glider.js): add aria-disabled attribute (#149)
Browse files Browse the repository at this point in the history
* feat(glider.js): add aria-disabled attribute

better usability with screen reader

* fix(glider.js): use ternary instead of if/else
  • Loading branch information
tomasvn authored Feb 8, 2021
1 parent a7662e0 commit f6818fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/assets/js/glider.min.js

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

6 changes: 6 additions & 0 deletions glider.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,19 @@
'disabled',
_.ele.scrollLeft <= 0 || disableArrows
)
_.arrows.prev.classList.contains('disabled')
? _.arrows.prev.setAttribute('aria-disabled', true)
: _.arrows.prev.setAttribute('aria-disabled', false)
}
if (_.arrows.next) {
_.arrows.next.classList.toggle(
'disabled',
Math.ceil(_.scrollLeft + _.containerWidth) >=
Math.floor(_.trackWidth) || disableArrows
)
_.arrows.next.classList.contains('disabled')
? _.arrows.next.setAttribute('aria-disabled', true)
: _.arrows.next.setAttribute('aria-disabled', false)
}
}

Expand Down
Loading

0 comments on commit f6818fc

Please sign in to comment.