A Versatile Automatic Any Image Comparison Slider In jQuery

Any Image Comparison Slider is a versatile yet extremely slim slider for image comparison. You have a lot of options to configure the slider and it works almost everywhere.

An easy but totally configurable jQuery plugin to create a horizontal or vertical slider that robotically slides left/proper/up/all the way down to examine the distinction between earlier than/after photographs.

More Features:

  • Configurable computerized animation.
  • Fully responsive and cellular-pleasant.
  • Custom cursor.
  • Custom background coloration.
  • Custom earlier than/after the label.
  • Also permits you to examine two photographs with mouse drag and/or motion.

Must Read: Perfect Image Comparison Slider In vanilla javascript | sliderBeforeAfter

How to make use of it

1. Install:

NPM
npm install jquery-anyimagecomparisonslider-plugin --save
                        
YARN
yarn add jquery-anyimagecomparisonslider-plugin

2. After you download the file and put it in your project, you just have to include it on your page:

<script src='./path/jquery.anyimagecomparisonslider.min.js'></script>

3. Please note that if you want to use a scrollbar with jQuery, implement the scrollbar script behind jQuery:

<script src='./path/jquery-3.4.1.min.js'></script>
<script src='./path/jquery.anyimagecomparisonslider.min.js'></script>

4. First, we insert our scrollbar HTML code back into the desired position on our page.

<div id="aics-2" data-orientation="vertical" data-background-color="#ffffff" data-cursor="ns-resize" data-follow-easing-factor="10" data-group="g2">
    <div class="images">
        <div class="image-btm" data-src="./path/image-btm.jpg"></div>
        <div class="image-top" data-src="./path/image-top.jpg"></div>
    </div>
    <div class="ui">
        <a class="button-btm" alt="full image btm" target="_blank">2020</a>
        <a class="button-top" alt="full image top" target="_blank">2019</a>
    </div>
</div>

5. These are all available data attributes with their default values:

data-orientation="horizontal"
data-initial-position="0"
data-width="100%"
data-background-color="none"
data-on-pointer-down="false"
data-cursor="ew-resize"
data-dividing-line="solid 1px rgba(255, 255, 255, .5)"
data-follow-easing-factor="0"
data-interactive="true"
data-auto-animation="true"
data-auto-animation-speed="8"
data-auto-animation-pause="1"
data-auto-animation-easing="inOutCubic"
data-control-others="false"
data-controlled-by-others="false"
data-controlled-reverse="false"
data-group=""
data-group-sync="false"
data-loading="lazy"
data-viewport-offset="100px"
data-sleep-mode="true"

Let’s take a closer look at the data attributes and how they work:

Must Read: Before-After Image Comparison Slider Plugin In Pure JavaScript

data-orientationSpecify either horizontal or vertical. With this, you can control whether your slider slides horizontally or vertically.
data-initial-positionAt this point, you define the starting position of the slider’s dividing line. The value must be a percentage and must be between 0 and 1.
data-widthEnter either a percentage value such as 100% or 75%, or a fixed pixel value such as 500px or 728px. It depends on whether your slider should behave responsively. In addition, the following length dimensions are permitted: pt, em, and VW.
data-background-colorHere you set the background color of the slider. You can see this color until the images are loaded. You can enter none (if you don’t want a background), or hex (#ffffff), RGB (RGB (255, 255, 255)), or rgba (rgba(255, 255, 255, 1.0)) values. The default value is none.
data-on-pointer-downSpecify true or false here. If you select true here, your slider will only be active when you hold down the mouse button.
data-cursorHere you define which mouse cursor should be displayed when you move the mouse over the slider. You have the following options: ew-resize, ns-resize, grab, w-resize, s-resize, e-resize, n-resize, row-resize, col-resize, all-scroll, move, crosshair, pointer, default, auto, inherit, initial and unset. But wait, there is more. With the following snipped you can load any cursor: url(“http://yourcursor.cur”) 0 0, auto
data-dividing-lineHere you specify how the dividing line of the slider should look. If you do not want a dividing line, then none will be specified. Otherwise you can use the default value: solid 1px rgba(255, 255, 255, .5)
data-follow-easing-factorIf you want the slider to follow you without easing, then enter the value 0 here. Otherwise, you can enter values from 0 to 100 to control the easing.
data-interactiveIf you want your slider to be non-interactive then enter false here. So the slider can not be controlled and runs only automatically.
data-auto-animationWith true or false you can determine whether your slider should automatically play an animation in case there is no user interaction.
data-auto-animation-speedHere you define the speed of the automatic animation in seconds.
data-auto-animation-pauseHere you define the time in seconds for the pause between the animations and the time that should pass after a user interaction until the automatic animation starts again.
data-auto-animation-easingHere you determine which easing function should be used for the automatic animation. The following functions are available: linear, inQuad, outQuad, inOutQuad, inCubic, outCubic, inOutCubic, inQuart, outQuart, inOutQuart, inQuint, outQuint, inOutQuint, inSine, outSine, inOutSine
data-control-othersIf you want this slider to control other sliders on the page, then enter true at this point. Otherwise, take the default value false.
data-controlled-by-othersIf you want this slider to be controlled by other sliders on the page, then enter true here. Otherwise, take the default value false.
data-controlled-reverseIf you want this slider to be controlled in reverse by other sliders on this page, then enter true here. Otherwise, take the default value false. Please note that this property only works in conjunction with data-controlled-by-others.
data-groupYou can group your sliders. If you use more than one slider on your site, you can group them by entering a group name. This is especially important if you only want to control certain other sliders on your site with your active slider.
data-group-syncYou can also synchronize your sliders. If you want your slider to start only after the other sliders of its group are loaded and initialized, then enter true here. The default value is false.
data-loadingHere you can choose either lazy or eager loading. If you take the default value of lazy, the slider will not be loaded until it is visible in the viewport. If you choose eager, the slider will be loaded and initialized immediately.
data-viewport-offsetIf lazy loading has been activated, then you can use this value to determine how much px earlier before entering the viewport the loading should start. The default value is 100px. If sleepMode is activated, you can also use viewportOffset it to define how much px earlier before entering the viewport the rendering should start.
data-sleep-modeHere you can determine whether your slider should only be active/rendered if it is in the viewport of the browser considering the viewportOffset parameter. The default value is true.
This feature actually always makes sense. But especially if you want to include many sliders on one page you should make sure that true is selected here.

See Also –

Compare Before and After Images Comparison Slider | image-compare-viewer
Pure JavaScript Slider Image Carousel With Or Without Thumbnails
A vanilla JavaScript Mobile-Friendly Before/After Comparison Slider | iMatch.js


See Demo And Download

Official Website(NiklasKnaack): Click Here

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

Related Posts

Confetti-Falling-Animation-Effect-party

Confetti Falling Animation Effect In JavaScript | party.js

Party.js is a JavaScript library to brighten user site experience with visual effects! Celebrate success with dom confetti! The library is written in TypeScript and compiled into…

jquery-cookie-consent

Simple jQuery Cookie Consent Plugin

jquery.cookie-consent is a simple jQuery plugin to request consent to use cookies. An easy-to-use and highly customizable cookie consent bar that informs your visitors of the use…

Timepicker-Plugin-for-jQuery

Timepicker JavaScript Plugin for jQuery Inspired by Google Calendar

jquery.timepicker is a lightweight jQuery timer plugin inspired by Google Calendar. It supports both mouse and keyboard navigation and weighs 5.5KB minified and compact. Features: Highly customizable…

angular-ngx-carousel-slider

A Lightweight, Touchable, and Responsive Angular Universal Carousel Library

ngxCarousel is a lightweight, tactile, and responsive library for creating an angular carousel. No dependencies, no more hammer. Must Read: Angular Responsive Image Slider With Lightbox Popup…

random-number-picker

Generate a Random Number Picker In Vanilla JavaScript

Random Number Picker is a Vanilla JS-based number picker that allows you to generate a random number within a specified range. Must Read: Generating Lottery Numbers Using…

Nepali-Date-Picker-jQuery-Plugin

Nepali Date Picker jQuery Plugin | nepaliDatePicker

Nepali Date Picker is a customizable, easy-to-use, and input-based date picker plugin mostly based on the Nepali calendar. Users can choose a Nepali date in the navigable…