npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@deot/helper-dom

v1.1.3

Published

考虑到`tree-shaking`, 不支持链式调用

Downloads

8

Readme

@deot/helper-dom

考虑到tree-shaking, 不支持链式调用

DOM/$

import * as $ from "@deot/helper-dom";

// or
import { $, DOM } from "@deot/helper";

prefixStyle

prefixStyle(key: string)

样式兼容前缀

  • key: 样式的名字

示例

prefixStyle('transform');

composedPath

$.composedPath(event: object)

e.taget父层相关path兼容

  • event: 当前触发的事件

示例

composedPath(event);

on

on(el: string | object, eventName: string, handler: Function)

注册当前事件

  • event: 当前触发的事件

示例

let off = on(el, 'click', handler);
off();

off

off(el: string | object, eventName: string, handler: Function)

卸载当前事件

  • event: 当前触发的事件

示例

off(el, 'click', handler);

once

once(el: string | object, eventName: string, handler: Function)

一次执行当前事件

  • event: 当前触发的事件

示例

once(el, 'click', handler);

addClass

addClass(el: string | object, className: string)

添加样式

  • className: 样式名

示例

addClass(el, 'g-fs-12');

removeClass

removeClass(el: string | object, className: string)

移除样式

  • className: 样式名

示例

removeClass(el, 'g-fs-12');

hasClass

hasClass(el: string | object, className: string)

是否包含当前样式

  • className: 样式名

示例

hasClass(el, 'g-fs-12');

getStyle

getStyle(el: string | object, key: string)

计算当前元素的样式对应的值(计算属性,css/style)

  • key: 样式的名字

示例

getStyle(el, 'height');

setStyle

setStyle(el: string | object, key: string)

设置样式

  • key: 样式的名字

示例

setStyle(el, 'height', '100px');

isScroll

isScroll(el: string | object, vertical: boolean)

是否含有滚动条

  • vertical: 是否垂直方向

示例

isScroll(el);

getScroller

getScroller(el: string | object, vertical: boolean)

获取最近的滚动条元素

示例

getScroller(el);

contains

contains(el: string | object, children: object)

父层是否包含子层(计算的是x,y,w,h)

  • children: 子元素

示例

contains(el, children);

scrollIntoView

scrollIntoView(el: string | object, options: object)

父层是否包含子层(计算的是x,y,w,h)

  • options: 可配置参数

options: 规则:

  • from: number 开始
  • to: number 结束
  • duration: number 持续时间
  • scroller: object 滚动条

示例

scrollIntoView(el, { });