https://github.com/timwright12/barebones-utilities
https://github.com/timwright12/barebones-utilities
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/timwright12/barebones-utilities
- Owner: timwright12
- License: mit
- Created: 2020-07-09T18:56:01.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2022-12-06T13:19:28.000Z (over 3 years ago)
- Last Synced: 2023-03-22T16:54:04.050Z (over 3 years ago)
- Language: JavaScript
- Size: 1.04 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Barebones Utilities Collection
## Barebones.getUrlParams
API to get parameters from a URL;
### Usage
```
// http://example.com/?q=help
const params = Barebones.getUrlParams( window.location.search );
console.log(params.q); // returns "help"
```
## Barebones.Focus.trap;
Set focus trapping on a DOM element (good for modals and areas where focus needs to be trapped)
### Usage
```
const el = document.getElementById('trapper');
const obj = new Barebones.Focus( el, {
setFocus: true
} );
obj.trap();
```
## Barebones.Focus.untrap;
Remove focus trapping on a DOM element
### Usage
```
// Use the same object and vars as you used when trapping
const el = document.getElementById('trapper');
const obj = new Barebones.Focus( el, {
setFocus: true
} );
obj.untrap();
```