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

fa-screensizeobserver

v0.4.4

Published

Observes window size

Downloads

3

Readme

fa-screensizeobserver

Observes screen size

###Usage

####"Normal" way Script needs jquery to work (for now). Before your closing <body> tag add:

<script src="path/to/jquery/jquery.js"></script>
<script src="path/to/fa-screensizeobserver/fa-screensizeobserver.js"></script>

where path/to/jquery is location of your jquery script and path/to/fa-screensizeobserver is location of your fa-screensizeobserver script.

####NPM Install

npm install fa-screensizeobserver --save

####Browserify

var ScreenSizeObserver = require('fa-screensizeobserver'); //returns class

Settings

Option | Type | Default | Description ------ | ---- | ------- | ----------- sizes | array of objects | [{ maxWidth : 767 , className : 'size-xs' }, { maxWidth : 991 , className : 'size-sm' }, { maxWidth : 1199, className : 'size-md' }, { className : 'size-lg' }] | Define possible sizes. Each size must have maxWidth and className. Last size requires only className. You can also define onSizeEnter and onSizeLeave events for each size. $element | jquery element | $(document.documentElement) | Current className is going to be added to $element class attribute.

####Example:

var settings = {
	$element: $(document.body),
	sizes: [
		{ 
			className:'size-sm', 
			maxWidth:1000, 
		}, { 
			className:'size-lg', 
		},
	]
};

var SSO = new ScreenSizeObserver(settings);

Events

Event | Params | Description ----- | ------ | ----------- onInit | data | Fires after object was initialized onSizeChanged | data | Fires after size was changed

####Example:

var settings = {
	onSizeChanged : function(e) {
		console.log('Current class: ' + e.className);
	},
	onInit : function(){
		console.log('Initialized');
	}, 
};

var SSO = new ScreenSizeObserver(settings);

//you can also do this
SSO.onSizeChanged(function(e){
	console.log("Data: " + e);
});

SSO.onInit(function(e){
	console.log("Initialized");
});

Specific Size Related Events

Event | Params | Description ----- | ------ | ----------- onSizeEnter | data | Fires when specific size is entered. onSizeLeave | data | Fires when specific size is left.

Example:

var settings = {
	sizes: [
		{ 
			className:'size-sm', 
			maxWidth:1000, 
			onSizeEnter: function(e) {
				console.log("Entering: " + e.className);
			}, 
			onSizeLeave: function(e) {
				console.log("Leaving: " + e.oldClassName);
			}
		}, { 
			className:'size-lg'
		},
	]
};

var SSO = new ScreenSizeObserver(settings);

Methods

Method | Args | Returns | Description ------ | ---- | ------- | ----------- getSize | size: int or string | object | Gets size by index (int) or class name (string) getSizeIndexByWidth | width: int | int | Get size index by width (should be in px)

Example:

var size0 = SSO.getSize(0); //gets size by index
var sizesm = SSO.getSize('size-sm'); //gets size by class name
var sizeIndex = SSO.getSizeIndexByWidth(780); //gets size index by width (in pixels)

###Dependencies

jQuery

###License

Copyright (c) 2016 Aleksander Fras
Licensed under the MIT license.