3 Star 0 Fork 0

Gitee 极速下载 / reframe-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/dollarshaveclub/reframe.js
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

This software is maintained under a new repository located at yowainwright/reframe.js

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️


Reframe.js, reframe your content responsively

npm version 0.3.6 unpkg Build Status Share


🖼 Reframe.js

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

This is particularly awesome for making embedded stuff, like videos or playlists, scale appropriately within a content area. This can done by hand but it's difficult to maintain, especially with CMS's and multiple editors. Reframe.js solves this issue—perfectly!

Alternatively, noframe.js is provided. Noframe.js scales selected elements at a fixed ratio but does not manipulate the dom's element structure at all! This keeps things like analytic events that run on embedded content intact!

Installing

NPM

npm 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

Reframe.js works with jQuery or Zepto. As of version 2.0.0, use jquery.reframe.js for jQuery or Zepto.

$('iframe').reframe();

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

🌐 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

Noframe.js works with jQuery or Zepto. As of version 2.0.0, use jquery.noframe.js for jQuery or Zepto.

$('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.


Created and maintained by Jeff Wainwright with Dollar Shave Club Engineering.

Copyright (c) 2017 Dollar Shave Club, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
JavaScript 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/mirrors/reframe-js.git
git@gitee.com:mirrors/reframe-js.git
mirrors
reframe-js
reframe-js
master

搜索帮助