0.0.5 • Published 8 months ago

quarkc-compare-image v0.0.5

Weekly downloads
-
License
-
Repository
github
Last release
8 months ago

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

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago