Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

dom-lib

1.2.1 • Public • Published

dom-lib Travis npm

DOM helper library

安装

npm install dom-lib --save

示例

import { addClass } from 'dom-lib';

API

Class

hasClass: (node: HTMLElement, className: string) => boolean;
addClass: (node: HTMLElement, className: string) => HTMLElement;
removeClass: (node: HTMLElement, className: string) => HTMLElement;
toggleClass: (node: HTMLElement, className: string) => HTMLElement;

Style

getStyle: (node: HTMLElement, property: string) => string;
getStyle: (node: HTMLElement) => Object;
 
removeStyle: (node: HTMLElement, property: string) => void;
removeStyle: (node: HTMLElement, propertys: Array<string>) => void;
 
addStyle: (node: HTMLElement, property: string, value: string) => void;
addStyle: (node: HTMLElement, style: Object) => void;

Events

on: (target: HTMLElement, eventName: string, listener: Function, capture: boolean = false) => {
  offFunction;
};
off: (target: HTMLElement, eventName: string, listener: Function, capture: boolean = false) =>
  void;

Query

activeElement: () => HTMLElement;
getHeight: (node: HTMLElement, client: HTMLElement) => number;
getWidth: (node: HTMLElement, client: HTMLElement) => number;
getOffset: (node: HTMLElement) => Object;
getOffsetParent: (node: HTMLElement) => Object;
getPosition: (node: HTMLElement, offsetParent) => Object;
getWindow: (node: HTMLElement) => String;
nodeName: (node: HTMLElement) => String;
ownerDocument: (node: HTMLElement) => Object;
ownerWindow: (node: HTMLElement) => Object;
contains: (context: HTMLElement, node: HTMLElement) => boolean;
scrollLeft: (node: HTMLElement) => number;
scrollTop: (node: HTMLElement) => number;

Utils

scrollLeft: (node: HTMLElement, val: number) => void;
scrollTop: (node: HTMLElement, val: number) => void;

Keywords

none

Install

npm i dom-lib

DownloadsWeekly Downloads

6,092

Version

1.2.1

License

MIT

Unpacked Size

107 kB

Total Files

112

Last publish

Collaborators

  • avatar