Socket
Socket
Sign inDemoInstall

quarkc-compare-image

Package Overview
Dependencies
4
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    quarkc-compare-image

Image comparison component is realized based on Quarkc, modified according to vue-compare-image.


Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

quarkc-compare-image

Image comparison component is realized based on Quarkc, modified according to vue-compare-image.

Simple web component to compare two images using slider.

img

Demo

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Hello Quark</title>
    <script type="module" src="https://unpkg.com/quarkc-compare-image"></script>
    <style>
      body {
        margin: 0;
        display: grid;
        justify-content: center;
      }
      p {
        text-align: center;
      }
      quarkc-compare-image {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
      }
    </style>
  </head>
  <body>
    <quarkc-compare-image
      leftImage="https://vue-compare-image.yuuniworks.com/cat1.jpg"
      rightImage="https://vue-compare-image.yuuniworks.com/cat2.jpg"
    />
  </body>
</html>

Features

  • Simple
  • Responsive (fit to the parent width)
  • Size difference between two images handled correctly. Element size determined by following two factors:
    • width of the parent
    • right image's aspect ratio

How to use

This component can be used whether it is a Vue, React, Angular, or Jq project.

In the shell:

npm install quarkc-compare-image

In your component file:

import QuarkcCompareImage from "quarkc-compare-image";
<QuarkcCompareImage
      leftImage="https://vue-compare-image.yuuniworks.com/cat1.jpg"
      rightImage="https://vue-compare-image.yuuniworks.com/cat2.jpg"
    />

Props

Prop (* required)typedefaultdescription
handleSizenumber (px)40diameter of slider handle (by pixel)
hoverbooleanfalseWhether to slide at hover
leftImage *stringnullleft image's url
leftImageAltstringnullleft image's alt
leftLabelstringnullLeft image text label
rightImage *stringnullright image's url
rightImageAltstringnullright image's alt
rightLabelstringnullRight image text label
sliderLineWidthnumber (px)2line width of slider (by pixel)
sliderPositionPercentagenumber (float)0.5Starting line position (from 0 to 1)

Dependencies

  • css-element-queries to detect element resize event.

Keywords

FAQs

Last updated on 11 Sep 2023

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