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

angular-fixed-aspect-img

v2.0.2

Published

AngularJS component for a fixed aspect ratio container for an image

Downloads

139

Readme

AngularJS fixed-aspect-img Component

AngularJS component for a fixed aspect ratio image container.

This component can be using in responsive layouts where the image container size is variable (e.g. depends on display width).

Demonstration

Features

  • Fills the parent element, which can have dynamic width/height
  • Keeps a fixed aspect ratio, that can be set/changed dynamically
  • Holds an image, which is centered within the container, stretched to either full width or full height depending on the aspect ratio of the image and the container; if the image aspect ratio does not exactly match the container aspect ratio, black (or any user-set color) bars fill the remaining space on the top/bottom or left/right.

Usage

Installation

npm install angular-fixed-aspect-img

Include dependency

ES Module

import fixedAspectImg from 'fixed-aspect-img';

const app = angular.module('app', [fixedAspectImg]);

In <script>

Include node_modules/angular-fixed-aspect-img/dist/angular-fixed-aspect-img.umd.js in src attribute of <script> tag. Or, pull in the dependencies from a unpkg.

<script src="https://unpkg.com/angular-fixed-aspect-img/dist/angular-fixed-aspect-img.umd.js"></script>

Inject dependency into your app

const app = angular.module('app', ['fixedAspectImg']);

Using the component

<fixed-aspect-img
  aspect-ratio="'4:3'"
  img-src="my-image.jpg"
  bg-color="'red'"
></fixed-aspect-img>

Examples

See example/, which pulls in all dependencies through a CDN, so all you have to do it open example/example.html in your browser.

API

  • imageSrc: the image URL
  • aspectRatio optional: a string representing an aspect ratio using : notation (e.g. '4:3', '16:9'). Default: 4:3
  • bgColor optional: a string representing a CSS color value, used as the background of the image container (top or side bars). Default: black
  • altMsg optional: string to fill

Note: each binding is one-way component binding (<), thus if you are passing a string directly rather than a variable containing a string, you must enclose the string in quotes.

License

This package is licensed under The MIT License.

Todo

  • [x] Add example
  • [x] Enhanced README
  • [ ] Add minified library to dist/
  • [ ] Written tests