Socket
Socket
Sign inDemoInstall

adjustable-slider

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    adjustable-slider

Web component for a before-and-after slider


Version published
Weekly downloads
3
Maintainers
1
Install size
10.1 kB
Created
Weekly downloads
 

Readme

Source

Adjustable Slider

A web component to display a before-and-after slider

Parameters

  • from: edge to start the slide from (left - default, right, top, bottom)
  • covered: percentage of slider to cover (0-1)

Slots

  • top: top layer (the "after" picture)
  • bottom: bottom layer (the "before" picture)
  • cover: overlaid over the edge between the top and bottom layer

Example

<script type="module" src="AdjustableSlider.js"></script>
	
<adjustable-slider from="bottom" covered="0.3" style="width: 75vw; height: 40vh; position: absolute; top: 20vh; left: 5vw;">
    <img style="width: 50px; height: 50px; margin: 0;" slot="cover" src="images/grabber.png" />
    <img style="width: 100%; height: 100%; margin: 0;" slot="top" src="images/toplayer.png" />
    <img style="width: 100%; height: 100%; margin: 0;" slot="bottom" src="images/bottomlayer.png" />
</adjustable-slider>
<div id="number" style="position: absolute; top: 45vh; left: 82vw;"></div>
<script>

    const slider = document.querySelector('adjustable-slider');
    const numberContainer = document.querySelector('#number');

    slider.addEventListener('cover', (event) => {
        const percentageX = event.detail.covered;
        numberContainer.innerHTML = `${Math.round(percentageX * 100)}%`;
    });
</script>

FAQs

Last updated on 25 Feb 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc