@plomis/util

0.1.0 • Public • Published

util

常用方法

Install

npm i @plomis/util

API

addEventlistener

(target: Element, eventType: string, listener: Function): { remove: Function }

Usage
import util from '@plomis/util';
this.eventListener = util.addEventListener(document.body, 'click', function(e){
  console.log(e.target); // works for ie
  
  console.log(e.nativeEvent); // native dom event
});
this.eventListener.remove(); // delete event listener

getClientSize

Usage
import util from '@plomis/util';
const { clintHeight, clintWidth } = util.getClientSize();

getOffset

(target: Element)

Usage
import util from '@plomis/util';
const { offsetLeft, offsetRight } = util.getClientSize(document.body);

requestAnimationFrame

(fc: function)

Usage
import util from '@plomis/util';
this.animation = util.requestAnimationFrame(() => {
  // do someting
});

cancelAnimationFrame

(fc: function)

Usage
import util from '@plomis/util';
this.animation = util.requestAnimationFrame(() => {
  // do sometings
});
util.cancelAnimationFrame(this.animation);  // delete animation frame

Readme

Keywords

Package Sidebar

Install

npm i @plomis/util

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

33.4 kB

Total Files

13

Last publish

Collaborators

  • ganguiyang
  • gaojingran
  • xutou12