New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aofl/component-utils

Package Overview
Dependencies
Maintainers
2
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aofl/component-utils

A small collection of component utility functions

  • 3.14.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
52
increased by100%
Maintainers
2
Weekly downloads
 
Created
Source

@aofl/component-utils

A small collection of component utility functions.

Api Documentation

Installation

npm i -S @aofl/component-utils

Usage

import {findParent} from '@aofl/component-utils';

class MyElement extends AoflELement {
...
connectedCallback() {
    super.connectedCallback();
    this.targetParent = findParent(this, 'addOption'); // register this list option with a parent who supports it
    this.targetParent.addOption(this);
  }
...

Methods

traverseParents()

Finds a parent component which has all the matching attributes

Arguments
NameTypeDescription
nodeHTMLElementThe child component
...argsStringAttribute names that must be found on the parent

findParent()

Finds a parent component which matches the method signature provided

Arguments
NameTypeDescription
nodeHTMLElementThe child component
...argsStringMethod names that must be found on the parent

findParentByAttributes()

Finds a parent component which has all the matching attributes

Arguments
NameTypeDescription
nodeHTMLElementThe child component
...argsStringAttribute names that must be found on the parent

isInViewport()

Check whether or not the supplied element is within the visible area of the screen. The threshold values are multipliers of their respective dimension. 0 means the exact viewport dimensions and .5 means viewport + half of viewport.

Arguments
NameTypeDescription
nodeHTMLElementtarget node
widthThresholdStringviewport width multiplier
heightThresholdStringviewport width multiplier

isInViewportMixin()

Mixes the superClass with functions necessary to detect if the element is within the visible area of the page.

Methods
  • firstWithinViewport() is invoked when element scrolls into view for the first time.
  • withinViewportUpdated(newValue, oldValue) withinViewportUpdated() is invoked anytime the element enters or exists the viewport.
  • stopIsInViewportCheck() when invoked it removes the event listeners and stops invoking the withinViewportUpdated() function. This is useful when we want to disconnect the event listeners and keep the component attached to dom. For example, conside lazy loading images with aofl-img. Once the image is loaded it is no longer necessary to check isInViewStatus.

Keywords

FAQs

Package last updated on 18 Mar 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc