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

metal-position

v2.1.2

Published

Metal.js position helps you to best position a DOM element into the screen. Useful to build tooltips, dropdowns an much more.

Downloads

2,256

Readme

Metal.js Position Dependency Status

Sauce Test Status

A Metal.js extension that provides static utilities for browser positioning.

Install

  1. Install NPM, if you don't have it yet.
  2. Run npm install metal-position. The code will be available at node_modules/metal-position.

Getting Started

With the code already available, you can use Metal Position by just importing the desired module on your js file and calling what you wish on it. For example:

import position from 'node_modules/metal-position/src/position';

// You can now call any function from Metal's Position module.
position.getClientHeight();

Note that Metal Position is written in ES6 (a.k.a ECMAScript 2015), so you can also use ES6 on your code like we did on the example. Since ES6 isn't fully implemented on browsers yet though, either a polyfill or a build process is necessary before using Metal on a website. See the Metal.js documentation for more details.

There are few different utilities available:

position.getClientHeight(node)

Gets the client height of the specified node. Scroll height not included:

position.getClientHeight(document);
position.getClientHeight(window); // Viewport height, scroll height not included.

position.getClientWidth(node)

Gets the client width of the specified node. Scroll width not included:

position.getClientWidth(document);
position.getClientWidth(window); // Viewport width, scroll width not included.

position.getHeight(node)

Gets the height of the specified node. Scroll height is included.

position.getHeight(node);

position.getWidth(node)

Gets the width of the specified node. Scroll width is included.

position.getWidth(node);

position.getRegion(node)

Gets the size of an element and its position relative to the viewport. The returned value is a DOMRect object which is the union of the rectangles returned by getClientRects() for the element, i.e., the CSS border-boxes associated with the element.

position.getRegion(node); // {height:6583, width:1058, left:0, bottom:5305, right:1058, top:-1278}

position.getScrollLeft(node)

Gets the scroll left position of the specified node.

position.getScrollLeft(node);

position.getScrollTop(node)

Gets the scroll top position of the specified node.

position.getScrollTop(node);

position.intersectRegion(region1, region2)

Tests if a region intersects with another.

position.intersectRegion(region1, region2);

position.insideRegion(region1, region2)

Tests if a region is inside another.

position.insideRegion(region1, region2);

position.insideViewport(region)

Tests if a region is inside viewport region.

position.insideViewport(region);

position.intersection(region1, region2)

Computes the intersection region between two regions.

position.intersection(region1, region2);

position.makeRegion(bottom, height, left, right, top, width)

Makes a region object. It's a writable version of DOMRect.

position.makeRegion(bottom, height, left, right, top, width);

Development

Install Gulp:

[sudo] npm install -g gulp

Fetch local dependencies:

npm install
bower install

Build or watch files:

gulp build
gulp watch

Run or watch tests:

gulp test
gulp test:watch

History

For detailed changelog, see Releases.

License

BSD License © Liferay, Inc.