
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
hy-proportional
Advanced tools
一个轻量级的 **自适应缩放插件**,可以根据父元素大小按比例缩放子元素,同时保持居中。 支持 **Vue 3 指令** 和 **原生 JS / TypeScript 函数** 两种使用方式。
一个轻量级的 自适应缩放插件,可以根据父元素大小按比例缩放子元素,同时保持居中。
支持 Vue 3 指令 和 原生 JS / TypeScript 函数 两种使用方式。
npm install hy-proportional
# or
yarn add hy-proportional
// main.ts
import { createApp } from 'vue'
import App from './App.vue'
import ScaleDirective from 'hy-proportional'
const app = createApp(App)
app.use(ScaleDirective)
app.mount('#app')
<template>
<div class="container" style="width: 100%; height: 500px; position: relative;">
<div v-hyscale="{ designWidth: 400, designHeight: 300 }">
我会自动缩放
</div>
</div>
</template>
designWidth 和 designHeight 可选,不传则自动使用元素初始宽高。import { Proportional } from 'hy-proportional'
const el = document.getElementById('my-element')
const scaler = Proportional(el, { designWidth: 400, designHeight: 300 })
// 卸载时释放资源
scaler.destroy()
Proportional 返回一个 Scaler 对象,包含 destroy() 方法。v-hyscale (Vue 3 指令)| 参数 | 类型 | 默认 | 描述 |
|---|---|---|---|
designWidth | number | 元素初始宽度 | 缩放基准宽度 |
designHeight | number | 元素初始高度 | 缩放基准高度 |
Proportional(el, options) (原生函数)| 参数 | 类型 | 描述 |
|---|---|---|
el | HTMLElement | 要缩放的元素,必须有父元素 |
options | ScaleOptions | 可选参数,指定设计宽高 |
返回值 Scaler:
interface Scaler {
destroy: () => void
}
destroy() 可以移除监听,释放内存。position 设置为 absolute,请确保父元素有 position: relative/absolute/fixed。FAQs
一个轻量级的 **自适应缩放插件**,可以根据父元素大小按比例缩放子元素,同时保持居中。 支持 **Vue 3 指令** 和 **原生 JS / TypeScript 函数** 两种使用方式。
The npm package hy-proportional receives a total of 6 weekly downloads. As such, hy-proportional popularity was classified as not popular.
We found that hy-proportional demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.