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

pos-view

v0.2.12

Published

Pos-view is an HTML custom element that displays a set of values related to an element's positioning. There are two floating windows in which the information is output: + position (pos) + offset hierachy (offset) ### Window position (pos) ### The fol

Downloads

5

Readme

pos-view

Description

Pos-view is an HTML custom element that displays a set of values related to an element's positioning. There are two floating windows in which the information is output:

  • position (pos)
  • offset hierachy (offset)

Window position (pos)

The following values of an element are displayed:

  • the "client" values of the element:
    • clientLeft
    • clientTop
    • clientWidth
    • clientHeight
  • the "offset" values of the element:
    • offsetLeft
    • offsetTop
    • offsetWidth
    • offsetHeight
  • the "scroll" values of the element:
    • scrollLeft
    • scrollTop
    • scrollWidth
    • scrollHeight
  • the result of element.getBoundingClientRect:
    • x
    • y
    • top
    • right
    • bottom
    • left
    • width
    • height

Window offset hierachy (off)

This window shows the hierarchy of the offset values. Starting from the observed element (see parameter "sourceID"), the hierarchy is determined recursively via "offsetParent". The following values are returned for each level:

  • offsetLeft
  • offsetTop
  • offsetWidth
  • offsetHeight

Window to start the other windows

There is also (optionally) another floating window (win-start) from which the other two windows can be toggled on and off.

Parameter

sourceID (string)

Id of the element whose position information is to be output.

Which window is display

noWinStart - no parameter value

By default, a small window is displayed with which you can hide and show the other two windows. If the "noWinStart" parameter is passed, then this window is not displayed. In this case at least one of the following parameters must be set "posWin" or "offsetWin" see below.

winPos

If the "winPos" parameter is passed, the position window is displayed. If the "noWinStart" parameter was not passed, the window with the position information, can be called from the start window. Then the "winPos" parameter does not necessarily have to be passed. However, if it is passed, the window is also displayed immediately.

winOffset

If the "winOffset" parameter is passed, the window with the offset hierarchy is displayed. If the "noStartWin" parameter was not passed, then the window with the offset hierarchy can be called from the start window. then the "winOffset" parameter does not necessarily have to be passed. However, if it is passed, the window is also displayed immediately.

Parameter related to position window

Parameters to position the windows for the first time. If no positioning parameter is passed, the windows are automatically placed:

  • winStart: above the observed element

  • winPos:

    • if winStart exists: To the right of winStart and so that the bottom line is level with winStart
    • if winStart does not exist: above the observed element
  • winOffset:

    • if winPos exists: To the right of winPos and so that the bottom line is level with winPos
    • if winPos does not exist:
      • if winStart exists: To the right of winStart and so that the bottom line is level with winStart
      • if winStart does not exist: above the observed element
  • winStartLeft

  • winStartTop

  • winPosLeft

  • winPosTop

  • winOffsetLeft

  • winOffsetTop The value of the attribute must be a unitless number. The number is interpreted as pixels. If you put a plus or minus sign in front of the number (without spaces) , then the value is used to add or subtract it from the automatically calculated value.

You can also specify only one of the values (left or top), the other will then be assigned automatically (see above). You can also set the position for just one window. The other windows then also use the automatic positioning. For example, if you specify winStartLeft and winStartPos, then the positioning of winPos and winOffset orients itself to the position of winStart.

Attributes that determine which rows are displayed in the position window

If you don't use any of the following attributes, then all rows are displayed.

posAllOn - no parameter value

If this attribute is passed, the meaning of the following attributes "posClient", "posOffset", "posScroll", "posBoudrect" is reversed.

posClient - no parameter value

The effect of this parameter depends on whether the "posAllOn" parameter was passed. If only "posClient" is passed, then the line with the client values is displayed. If "posAllOn" was also passed, then the row with these values will be hidden.

posOffset - no parameter value

The effect of this parameter depends on whether the "posAllOn" parameter was passed. If only "posOffset" is passed, then the line with the offset values is displayed. If "posAllOn" was also passed, then the row with these values will be hidden.

posScroll - no parameter value

The effect of this parameter depends on whether the "posAllOn" parameter was passed. If only "posScroll" is passed, then the line with the scroll values is displayed. If "posAllOn" was also passed, then the row with these values will be hidden.

posBoudrect - no parameter value

The effect of this parameter depends on whether the "posAllOn" parameter was passed. If only "posBoudrect" is passed, then the line with the client values is displayed. If "posAllOn" was also passed, then the row with these values will be hidden. This values are generated by "getBoundingClientRect" call by the "sourceID" element.

Styling

posWin

In order to be able to highlight individual values, a "part" attribute was assigned to all elements. The following is a list of all values relating to the position window:

Line offset

  • offsetLabel
  • offsetLeft
  • offsetTop
  • offsetWidth
  • offsetHeight

Line client

  • clientLabel
  • clientLeft
  • clientTop
  • clientWidth
  • clientHeight

Line scroll

  • scrollLabel
  • scrollLeft
  • scrollTop
  • scrollWidth
  • scrollHeight

Line boundRect

  • rectLabel
  • rectLeft
  • rectTop
  • rectWidth
  • rectHeight
  • rectX
  • rectY
  • rectRight

header

  • posLabelHead
  • posLeftHead
  • posTopHead
  • posWidthHead
  • posHeightHead
  • posXHead
  • posYHead
  • posRightHead
  • posBottomHead

Offset

In order to be able to highlight individual values, a "part" attribute was assigned to all elements. The following is a list of all values relating to the offset window: The last entry in the offset hierarchy is the offset value of the observed element (sourceId). This line has the number 0 in the part name.Then comes the parent, this has the number 1 in the part name. And if there is another parent, then this has the number 2 and so on.

header

  • offsetHLabelHead
  • offsetHLeftHead
  • offsetHTopHead
  • offsetHWidthHead
  • offsetHHeightHead

Last row with offset of the observed element

  • offsetH-0Label
  • offsetH-0Left
  • offsetH-0Top
  • offsetH-0Width
  • offsetH-0Height
first (offset) parent of the observed element
  • offsetH-1Label
  • offsetH-1Left
  • offsetH-1Top
  • offsetH-1Width
  • offsetH-1Height

The window in general

More information about the display of the window itself can be found in the "floating-window" package, which is used as a frame for the content. Here is the list of part attribut values:

  • floating-win
  • floating-win-main-frame
  • floating-win-head
  • floating-win-head-title
  • floating-win-head-closer
  • floating-win-body

Example

The following CSS directive highlights the value for "clientLeft".

::part(clientLeft) {
    background-color: darkred;
    color: white;    
}

If is installed several times on the page and you want to style the custom elements differently, you could, for example, combine the part selector with an id selector.

<pos-view id="view-1" sourceId="test-1" posAllOn></pos-view>
pos-view[id="view-1"]::part(clientLeft) {   
    background-color: darkred;
    color: white;
}