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

jquery-elementquery

v2.0.0

Published

Element queries for jQuery.

Downloads

15

Readme

jQuery elementQuery

elementQuery allows you to style elements based on their parent container's changing size. You can read more about the concept in Smashing Magazine's article.

This is different from media queries in that it targets the size of a specific element, regardless of whether the window size has changed.

Usage

Basic

// pass an array of your queries
$('.element').elementQuery(['max-width: 900', 'min-width: 901']);
/* your .element must be positioned (relative, absolute), not static. */
.element {
	position: relative;
}

/* max-width, min-width, max-height, or min-height attribute selectors */
.element[max-width-900="true"] {
	/* your styles for <= 900px */
}

.element[max-width-900="false"] {
	/* your styles for > 900 */
}

.element[min-width-901="true"] {
	/* your styles for >= 901px */
}

.element[min-width-901="false"] {
	/* your styles for < 901px */
}

With a callback

$('.element').elementQuery(['min-width: 800'], function(dims) {

  //dims contains current width and height
  console.log(dims.width, dims.height);

  // 'this' references .element
  console.log($(this).width(), $(this).height());

});

Motivation

I could not find an elementquery option that:

  • Did not rely on window resize. It seemed silly to listen for window resize events when the element may or may not resize as a result of that.
  • Did not rely on introducing scrolling elements. These caused visible scrollbars and sluggish performance.

This plugin does not rely on either technique, so accurately reports resizes on the element itself, and only introduces a single empty iframe that shows no scrollbars and reports its resize the same way that window would.

Demo: http://notthatnathan.github.io/demos/jquery-elementquery/

Installation

npm install jquery-elementquery --save

Contributing

It would be cool to rewrite the underlying this plugin and the jquery-elementresize to not require jQuery (under a different name). I could also use help writing some tests.

License

MIT