GithubHelp home page GithubHelp logo

rlugojr / reframe.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dollarshaveclub/reframe.js

0.0 2.0 0.0 140 KB

Reframe unresponsive elements responsively.

Home Page: https://dollarshaveclub.github.io/reframe.js/

License: MIT License

JavaScript 65.89% HTML 34.11%

reframe.js's Introduction

Reframe.js, reframe your content responsively

npm version 0.3.6 Bower version 0.3.6 Build Status Join the chat at https://gitter.im/reframe-js/Lobby Share

๐Ÿ–ผ Reframe.js

Reframe.js is a javascript plugin that makes elements scale at a fixed ratio.

Alternatively, noframe.js is provided. Noframe.js scales selected elements at a fixed ratio but does not wrap the selected elements.

Installing

NPM

npm i reframe.js --save

Bower

bower i reframe.js --save

Yarn

yarn add reframe.js 

Setup

  1. Add dist/reframe.js
  2. reframe the element you'd like to re-frame.

Examples

reframe('iframe'); // Wrap all iFrames in the page
reframe(document.getElementById('my-frame')); // Pass a DOM element
reframe(document.querySelectorAll('.my-targets')) // Pass a live node list

Elements that have been wrapped with reframe will not be wrapped twice.

How?

Reframe.js wraps a specified element in a div that is an intrinsic ratio of the original element. This plugin is great for embedded content like iframes or videos.

Why Reframe.js?

Reframe.js is inspired by FitVids and does what FitVids does but without the need for jQuery. This makes the plugin highly valuable when including it in a module that has to be very small and with minimal dependencies. Here's a basic codepen example.

This plugin is small - ~1.3kb unminified and is meant to do 1 thing - wrap elements that aren't responsive and make them responsive. ๐Ÿ’ช

Options

If you'd like to not use the classname 'js-reframe', just use your own.

reframe('iframe', 'my-classname');

jQuery

You can use Reframe.js with jQuery or Zepto as well.

$('iframe').reframe();

// While using a custom class name
$('iframe').reframe('my-classname');

New: Noframe.js

Noframe.js makes the same ratio as Reframe.js using css calc.

Noframe.js's doesn't wrap the element you'd like to be responsive. It, instead, does a calculation based on its or a parent element's max-width. Here's a basic codepen example.

Noframe.js Notes

  • The reframed element requires a parent element with a max width to scale above the selected elements intial size otherwise the reframed element will only scale below its initial size. ๐Ÿ‘

Setup

  1. Add dist/noframe.js
  2. noframe the element you'd like to re-frame.

Examples

noframe('iframe');
noframe('iframe', 'parent');

jQuery

You can use Noframe.js with jQuery as well.

$('iframe').noframe();
$('iframe').noframe('parent');

Reframe.js or Noframe.js?

Reframe.js offers the simplest solution to making elements scale at an intrinsic ratio.

Noframe.js doesn't wrap the selected element to make it scale at an intrinsic ratio. Noframe.js is the ideal solution when various events, like tracking events, could be affected when an element is wrapped. It does require a width or max-width which can involve a bit more setup awareness.

reframe.js's People

Contributors

yowainwright avatar bfred-it avatar briangonzalez avatar jakiestfu avatar pwfisher avatar

Watchers

Ray Lugo, Jr. 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.