Press "Enter" to skip to content

A vanilla JavaScript Mobile-Friendly Before/After Comparison Slider | iMatch.js

iMatch.js is a before / after comparison slider for vanilla JavaScript for mobile, to display the difference between two images using drag and touch events of the mouse.

beforeafter image slider online, before after slider, image comparison slider, before after slider codepen, image comparison slider online,, before after slider banner jquery plugin

More advantages:

  • Both desktop and mobile
  • Built-in animation
  • Touch support
  • It’s easy to customize the CSS style
  • Compatible with mobile
  • Easy to integrate
  • Both horizontal and vertical slats

How to make use of it:

1. Import the minified version of the iMatch.js JavaScript library.

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

2. Or import the iMatch.js as an element.

import  { iMatch } from '../dist/imatch.min.js'

3. Add before/after photos to the iMatch container.

<div class="example">
  <img data-caption="Before" src=" " alt="image One">
  <img data-caption="After" src=" " alt="image Two">
</div>

4. Create a hidden range input to deal with the on-input event.

<input hidden type="range" name="" id="range" min="0" max="100">

5. Initialize the picture comparability slider.

var mySlider = new iMatch('.example')
mySlider.compare({
  direction: 'horizontal',
  animation: true,
  lineClassName: 'line',
  arrowClassName: 'dot'
})

6. Customize the picture comparability slider within the CSS.

.dot{
  /* styles for drag handle */
}

.line{
  /* styles for slider */
}

.caption{
  /* styles for labels */
}

Compare Before/After Images With Drag & Touch Events, iMatch.js Plugin/Github, beforeafter image slider app

iMatch js Demo


See Demo And Download

Official Website(indaneey): Click Here

This superior jQuery/javascript plugin is developed by indaneey. For extra advanced usage, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published.