npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@indaneey/imatch

v1.0.1

Published

A vanilla JavaScript mobile-friendly before/after comparison slider.

Downloads

4

Readme

iMatch.js

A vanilla JavaScript mobile-friendly before/after comparison slider, to view the difference between two images with mouse drag and touch swipe events.

Some Fetaures

  • Both Desktop & Mobile
  • Built-in Animation
  • Touch Support
  • Easy to Customise CSS Style
  • Mobile-friendly
  • Easy to intergrate
  • Both Horizontal & Vertical Slide
  • Pure JavaScript

PREVIEW

check index.html in samplePage folder for live Preview.

Installation

# Basic Node.JS installation
npm install @indaneey/imatch --save

Syntax

Import imatch() from imatch

import { imatch } from '@indaneey/imatch';

Examples

Calling iMatch using require()

var iMatch = require('imatch');
var slider = new iMatch();

Calling iMatch using script tag

<head>
<script src="imatch.min.js"></script>
</head>

and then in script tag create iMatch() instance

var slider = new iMatch();

Create Container With HTML Elements


First step, you have to create a container where you want your comparison slider to be. And add two different images inside with <img> tags.

NOTE: Don't add three HTML Elements inside your container, because it will not works on three images, only two images are allowed. Also single one image will not work. JUST TWO(2) IMAGES!!

Example

<div class="container">
    <img src="./assets/match1_1.jpg" alt="image One">
    <img src="./assets/match1_2.jpg" alt="image Two">
</div>

Set Data Attribute To Container

To create a caption for your slider you have to set data attribute to your image tags.

Example

<div class="container">
    <img data-caption="Before" src="./assets/match1_1.jpg" alt="image One">
    <img data-caption="After" src="./assets/match1_2.jpg" alt="image Two">
</div>

The data attribute must be data-caption then follow by your caption text.

Set Container Size

Here is most important part. Set your container width and height using CSS. And then iMatch.js will use these properties to create your slider.

NOTE: If not set width and height properties, the iMatch will not generate comparison slider for us.

Example

.container{
    width: 300px;
    height: 600px;
}

Attach Container To iMatch.js


After creating a container, you have to also create an iMatch instance too. And then attach them together. Write your container class attribute or id attribute name as iMatch() parameter in string format

Example

  var slider = new iMatch('.container')

compare()

iMatch.js has a method called compare() that will use to configure slider properties and display slider to screen.

Example

  var slider = new iMatch('.container')
      slider.compare()

NOTE: If not write this method, the iMatch.js will not generate comparison slider for us.

This method has different properties

  • direction
  • animation
  • lineClassName
  • arrowClassName

Example

  var slider = new iMatch('.container')
      slider.compare({
          direction: 'HORIZONTAL', // horizontal or vertical value required in string
          animation: true,         // Boolean
          lineClassName: 'line',   // slider line class name for CSS style in string
          arrowClassName: 'dot'    // center rectangle class name for CSS style in string
      })

direction property [ string ] This property is used to set your slider movement direction between horizontal or vertical in string format.


animation property [ boolean ] This property is used to enable or unable the build-in animation.


lineClassName property [ string ] This property is a class name of slider line, it will be use to styling using CSS.

Example

  var slider = new iMatch('.container')
      slider.compare({
          lineClassName: 'line',   // slider line class name for CSS style in string
      })

CSS

  .line{
    background-color: red
  }

arrowClassName property [ string] This property is a class name of center rectangle of line, it will be use to styling using CSS.

Example

  var slider = new iMatch('.container')
      slider.compare({
          arrowClassName: 'dot',   // slider line class name for CSS style in string
      })

CSS

  .dot{
    background-color: red;
    border-radius: 50%
  }

iMatch.js

Developed by Indaneey_design. for any support contact me here