Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rsuite/dom-lib
DOM helper library
https://github.com/rsuite/dom-lib
dom dom-library typescript
Last synced: about 11 hours ago
JSON representation
DOM helper library
- Host: GitHub
- URL: https://github.com/rsuite/dom-lib
- Owner: rsuite
- License: mit
- Created: 2016-06-28T16:04:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-09-22T01:30:11.000Z (5 months ago)
- Last Synced: 2024-10-30T00:00:12.112Z (3 months ago)
- Topics: dom, dom-library, typescript
- Language: TypeScript
- Homepage: https://dom-lib.vercel.app/
- Size: 4.03 MB
- Stars: 28
- Watchers: 7
- Forks: 15
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# DOM helper library
[![CI](https://github.com/rsuite/dom-lib/workflows/Node.js%20CI/badge.svg)](https://github.com/rsuite/dom-lib/actions)
[![NPM Version](https://img.shields.io/npm/v/dom-lib?color=33cd56&logo=npm)](https://www.npmjs.com/package/dom-lib)Click the "Exports" link in the sidebar to see a complete list of everything in the package.
## Install
```
npm install dom-lib --save
```## Usage
```js
import addClass from 'dom-lib/addClass';addClass(element, 'foo');
// output:
```## API
Class
```typescript
hasClass: (node: Element, className: string) => boolean;
addClass: (node: Element, className: string) => Element;
removeClass: (node: Element, className: string) => Element;
toggleClass: (node: Element, className: string) => Element;
```Style
```typescript
getStyle: (node: Element, property: string) => string;
getStyle: (node: Element) => Object;removeStyle: (node: Element, property: string) => void;
removeStyle: (node: Element, propertys: Array) => void;addStyle: (node: Element, property: string, value: string) => void;
addStyle: (node: Element, style: Object) => void;
```Events
```typescript
on: (target: Element, eventName: string, listener: Function, capture: boolean = false) => {
off: Function;
};
off: (target: Element, eventName: string, listener: Function, capture: boolean = false) =>
void;
```Query
```typescript
activeElement: () => Element;
getHeight: (node: Element, client: Element) => number;
getWidth: (node: Element, client: Element) => number;
getOffset: (node: Element) => Object;
getOffsetParent: (node: Element) => Object;
getPosition: (node: Element, offsetParent) => Object;
getWindow: (node: Element) => String;
nodeName: (node: Element) => String;
ownerDocument: (node: Element) => Object;
ownerWindow: (node: Element) => Object;
contains: (context: Element, node: Element) => boolean;
scrollLeft: (node: Element) => number;
scrollTop: (node: Element) => number;
isFocusable: (node: Element) => boolean;
```Utils
```typescript
scrollLeft: (node: Element)=> number;
scrollLeft: (node: Element, val: number)=> void;scrollTop: (node: Element)=> number;
scrollTop: (node: Element, val: number) => void;
```