🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

vue-keep-ratio

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-keep-ratio

A vue directive to keep dom ratio

latest
Source
npmnpm
Version
2.0.5
Version published
Maintainers
1
Created
Source

vue-keep-ratio


[中文项目介绍]

As there comes a new css attribute: aspect-ratio, I picked up my old work vue-keep-ratio, use a more adaptive (but hack) way to achieve keep dom ratio 🍺

What

It's a vue component to keep dom ratio. (just in CSS)

Demo: Try it!

Install

# npm
npm -i vue-keep-ratio
# yarn
yarn add vue-keep-ratio

Global install

// main.js
import VueKeepRatio from "vue-keep-ratio";
Vue.use(VueKeepRatio);
// page.vue
<template>
  <VueKeepRatio :ratio="16 / 9">
    this box is keep ratio as default 16 / 9
  </VueKeepRatio>
</template>

Just in component

// page.vue
<template>
  <VueKeepRatio :ratio="16 / 9">
    this box is keep ratio as default 16 / 9
  </VueKeepRatio>
</template>

<script>
import VueKeepRatio from "vue-keep-ratio";

export default {
  components: {
    VueKeepRatio
  }
}
</script>

Demo

use vue cli start demo

vue serve examples/base/main.js

API

Props

  • ratio: {Number} [ratio=1/1] The ratio you wanna keep, default: 1 / 1.
  • width: {String} Keep width value when dom resized, default.
  • height: {String} Keep width value when dom resized.
  • innerClassName: {String} [innerClassName=''] As the name, it specify inner div wrapper additional class name

Bugs

  • [ ]: Can't apply css transition animation on VueKeepRatio, because transition require affirmatory start and end value.

Keywords

ratio

FAQs

Package last updated on 08 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts