Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-scaled-view

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-scaled-view

[![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)

  • 2.0.0
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Svelte Scaled View Library

NPM License

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.

Usage

Install

First, install the library in your Svelte project from npm:

npm install svelte-scaled-view

Include

Then, add it to your project:

import ScaledView from 'svelte-scaled-view

Basic

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>

Advanced

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>

FAQs

Package last updated on 18 Oct 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc