Giter Club home page Giter Club logo

angular-retina's Introduction

angular-retina

Replaces the AngularJS directive ng-src by a version which supports Retina displays.

If the browser runs on a Retina display and the referenced image is available in double resolution, then load the high resolution version of that image from the server.

Build Status

Quick start

Download

npm install angular-retina

On the client

  • Into your HTML code include the required libraries:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>
<script src="/path/to/your/javascript-files/angular-retina.min.js"></script>

Please note, that angular-retina requires angularjs-1.1.3 or later.

  • and in your main JavaScript file:
angular.module('MyAwesomeModule', [...other dependencies..., 'ngRetina']);
  • in the body of your HTML, access static referenced images using:
<img ng-src="/path/to/image.png" width="100" height="100">
  • or reference the image using a markup:
<img ng-src="{{image_url}}" width="100" height="100">

Just use it in your HTML-code as you would use the common AngularJS directive ngSrc:

On the server

Applications supporting Retina displays should include two separate files for each image resource. One file provides a standard-resolution version of a given image, and the second provides a high-resolution version of the same image. The naming conventions for each pair of image files is as follows:

  • Standard: <image_name>.<filename_extension>
  • High resolution: <image_name>@2x.<filename_extension>

If the browser runs on a high-resolution display, and if the referenced image is available in high-resolution, the corresponding <img ng-src="..."> tag is interpreted, such that the image in high-resolution is referenced.

This module can also be used to reference static image urls, to load the high resolution version on Retina displays.

Note that when using this module, adding the element attributes width="..." and/or height="..." becomes mandatory, as the displayed image otherwise gets scaled to its double size.

Release History

  • 0.1.0 - initial revision
  • 0.1.3 - fixed problems with minified JS code
  • 0.2.0 - using sessionStorage instead of $cacheFactory to boost performance

License

Copyright (c) 2013 Jacob Rief
Licensed under the MIT license.

angular-retina's People

Contributors

jrief avatar tv avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.