Code Monkey home page Code Monkey logo

retinfyjs's Introduction

retinfy.js

A javascript plugin to detect the users screen pixel screen density(for retina devices) and replace the image with a retina friendly equivalent image.

Usage

Package Managers

# Bower
bower install --save retinfyjs

Basic Usage

<!-- Include Retinfy Library -->
<script type="text/javascript" src="./retinfy.js"></script>
<!-- Initialize -->
<script type="text/javascript">
    retinfy.init();
</script>


<!-- Set my class for any img element you want retinfyed remember to specify data-x1, data-x2, data-x3 so i know which images to replace with -->
<img class="retinfy" src="Default Image src" data-x1="src image for device pixel ratio up to 1" data-x2="src image for device pixel ratio up to 2" data-x3="src image for device pixel ratio up to 3" />
<!-- I also work with inline styling -->
<div class="retinfy" style="background: url('Default Image src')" data-x1="src image for device pixel ratio up to 1" data-x2="src image for device pixel ratio up to 2" data-x3="src image for device pixel ratio up to 3"> </div>

Configuration Options

You can also configure customized classes and callbacks

var settings = {
               		'@1': 'data-x1', //attribute for src image for device pixel ratio up to 1
               		'@2': 'data-x2', //attribute for src image for device pixel ratio up to 2
               		'@3': 'data-x3', //attribute for src image for device pixel ratio up to 3
               		activeClass: 'retinfy', // Class to initialize retinfy 
               		initClass: 'retinfy-loaded', // Class retinfy uses to indicate it is loaded 
               		callbackBefore: function () {}, //Callback Before it changes images
               		callbackAfter: function () {} //Callback After it changes images
               	};
retinfy.init(settings); 

Contributing

Just Fork and commit changes, then send a pull request.

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.