pull/132/head
Cory LaViska 2020-07-21 15:23:19 -04:00
commit a91f1d15d6
2 zmienionych plików z 7 dodań i 9 usunięć

Wyświetl plik

@ -48,7 +48,7 @@ To import individual Shoelace components, use this syntax.
import { SlButton, SlDropdown } from '@shoelace-style/shoelace/dist/custom-elements';
customElements.define('sl-button', SlButton);
customElements.define('sl-dropdown', SlButton);
customElements.define('sl-dropdown', SlDropdown);
```
For convenience, the bundle also exports a `defineCustomElements()` method. When this method is called, it will automatically define all Shoelace components in the bundle.
@ -59,4 +59,4 @@ import { defineCustomElements } from '@shoelace-style/shoelace/dist/custom-eleme
defineCustomElements();
```
While convenient, importing all components like this will make your bundle larger. For best results, only import the components you're actually going to use.
While convenient, importing all components like this will make your bundle larger. For best results, only import the components you're actually going to use.

Wyświetl plik

@ -1,25 +1,23 @@
import { getOffset } from './offset';
let locks = [];
const locks = new Set();
//
// Prevents body scrolling. Keeps track of which elements requested a lock so multiple levels of locking are possible
// without premature unlocking.
//
export function lockBodyScrolling(lockingEl: HTMLElement) {
if (lockingEl && !locks.includes(lockingEl)) {
locks.push(lockingEl);
document.body.classList.add('sl-scroll-lock');
}
locks.add(lockingEl);
document.body.classList.add('sl-scroll-lock');
}
//
// Unlocks body scrolling. Scrolling will only be unlocked once all elements that requested a lock call this method.
//
export function unlockBodyScrolling(lockingEl: HTMLElement) {
locks = locks.filter(el => el !== lockingEl);
locks.delete(lockingEl);
if (locks.length === 0) {
if (locks.size === 0) {
document.body.classList.remove('sl-scroll-lock');
}
}