Giter VIP home page Giter VIP logo

jquery.keep-ratio's Introduction

Keep Ratio

Build Status

A jQuery plugin for keeping the aspect ratio

Example usage: http://loonkwil.github.io/jquery.keep-ratio/

Install

Requirements Bower

bower install keep-ratio --save
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
  <div></div>

  <script src="bower_components/jquery/dist/jquery.min.js"></script>
  <!-- For older browsers (http://caniuse.com/#feat=requestanimationframe) -->
  <script src="bower_components/request-animation-frame/rAF.js"></script>
  <script src="bower_components/keep-ratio/dist/jquery.keep-ratio.min.js"></script>
  <script type="text/javascript">
    $(function() {
      $('div').keepRatio({ ratio: 4/3, calculate: 'width' });
    });
  </script>
</body>

How to make your own build

Requirements: NodeJs, Bower, Gulp

  1. bower install
  2. npm install
  3. npm test
  4. gulp dist or just gulp

jquery.keep-ratio's People

Contributors

loonkwil avatar

Stargazers

Philipp avatar  avatar  avatar Jeff Mayfield avatar  avatar Filippo Sacchini avatar Krittanon Wisedchart avatar Stephen D. Malloy avatar Adam Fairholm avatar cpoul avatar Tushar  Borole avatar Tsolid avatar Faridul Hassan avatar Mohi Tavas avatar Leo Bartoloni avatar Antonello Pasella avatar Will Sahatdjian avatar Kid Equinox avatar Wattana Ruengmucha avatar John Laswell avatar Steffen Bär avatar Benoit Alix avatar Rob Easthope avatar John Ellis avatar Jean Pierre Kolb avatar Spencer Thayer avatar Mike Sozanski avatar Jiri Melcak avatar Vanessa Depraute avatar Hu Yanan avatar Carabineiro avatar Srdjan avatar wsm or swim I don't mind avatar Jakub Straka avatar Satoshi Homura avatar Syougo Hamada avatar maitokuwahara avatar

Watchers

Mike Sozanski avatar James Cloos avatar  avatar Simon Berdal avatar

jquery.keep-ratio's Issues

Event handlers are bound only to the currently selected elements ?!

First of all: Great job @loonkwil ! This is a nimble and elegant piece of work.
However, if I understand your code correctly, the functionality of this plugin could be extended to be even more valuable. This is because (from my understanding - correct me if I am wrong), the event handlers will not be automatically bound to new elements introduced to the DOM tree, which match original jQuery selectors used for keepRatio .

$(function() {

  $('<div>').addClass('foo').text('foo 1')
        .css('top', '100px').appendTo($('body'));

  $('.foo').keepRatio({
      ratio: 3/2,
      calculate: 'height'
  });

  // Apspect ratio will not be calculated for this one:
  $('<div>').addClass('foo').text('foo 2')
        .css('top', '300px').appendTo($('body'));
)}

What would be really neat, is if you could do something like this...

$('body').keepRatio('.foo',{
     ratio: 3/1.2,
     calculate: 'width'
});

...and / or simply...

$.keepRatio('.foo',{
     ratio: 3/1.2,
     calculate: 'width'
});

What do you think?

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.