Socket
Socket
Sign inDemoInstall

oj-dom-utils

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    oj-dom-utils

various dom utility functions


Version published
Maintainers
1
Created

Readme

Source

dom utils

Various dom utilities

Usage

import

import { getTransitionDuration } from "oj-dom-utils"

getTransitionDuration

const duration = getTransitionDuration(element, deep)

getOuterHeight

const height = getOuterHeight(element)

getOuterWidth

const width = getOuterWidth(element)

getOffsetsOnPage

const offset = getOffsetsOnPage(element)

withinViewport

const visible = withinViewport(element, completely)

childOf

const childExistsInContainerElement = childOf(container, child)

getEventProps

const handle = e => {
  const { clientX, clientY } = getEventProps(e) // normalized
}
window.addEventListener("mousemove", handle)
window.addEventListener("touchmove", handle)

getOffsetX

window.addEventListener("mousemove", e => {
  const elementOffsetX = getOffsetX(e)
})

getOffsetY

window.addEventListener("mousemove", e => {
  const elementOffsetY = getOffsetY(e)
})

appendDivTo

const newChildDiv = appendDivTo(element)

sanitizeHTML

const text = sanitizeHTML(text)

jsonToB64

const b64 = jsonToB64(obj)

jsonFromB64

const obj = jsonFromB64(b64)

loadScript

await loadScript(url) // appends script tag to body

getRootElements

data-loaded="true" will be set on all returned elements. elements with this attribute wont be selected the next time.

const elements = getRootElements(selector)

getRootData

selects the first input field within the element and returns the value as json

const data = getRootData(element)

mounter

uses getRootElements and getRootData

mounter("[data-dialog]", (root, data) => {
  new Dialog(root, data)
})

FAQs

Last updated on 06 Jan 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc