Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
svelte-scaled-view
Advanced tools
[![NPM](https://img.shields.io/npm/v/svelte-scaled-view)](https://www.npmjs.com/package/svelte-scaled-view) ![License](https://img.shields.io/npm/l/svelte-scaled-view)
Svelte Scaled View provides a component called "ScaledView" that allows you to scale the content within it to fit its parent element using one of three strategies (contain, cover, and fill). It also allows you to clamp the scale ratio using an optional min and max prop.
First, install the library in your Svelte project from npm:
npm install svelte-scaled-view
Then, add it to your project:
import ScaledView from 'svelte-scaled-view';
Once included, you can now use the ScaledView component in your project:
<div class="container_with_a_non_zero_size">
<ScaledView fit="contain">
<div>My content to be scaled</div>
</ScaledView>
</div>
In the above example, the fit
prop is set to contain
, which will scale the content to fit the parent element while maintaining its aspect ratio.
You can also choose to use other scaling methods like cover
and fill
:
<ScaledView fit="cover">
<div>My content to be scaled</div>
</ScaledView>
In this case, the content will be scaled to cover its parent element while maintaining of aspect ratio.
Or you can use fill
to scale the content to fill its parent element, regardless of aspect ratio:
<ScaledView fit="fill">
<div>My content to be scaled</div>
</ScaledView>
You may also pass in a min
and max
value to set a minimum and maximum scale ratio.
<ScaledView fit="contain" min={0.5} max={2}>
<div>My content to be scaled</div>
</ScaledView>
Retrieve the scale factors.
<div class="container_with_a_non_zero_size">
<ScaledView fit="contain" let:scaleX let:scaleY>
<div>this element is scaled by x:{scaleX} and y:{scaleY}</div>
</ScaledView>
</div>
FAQs
[![NPM](https://img.shields.io/npm/v/svelte-scaled-view)](https://www.npmjs.com/package/svelte-scaled-view) ![License](https://img.shields.io/npm/l/svelte-scaled-view)
We found that svelte-scaled-view 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.