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.
- 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.
How to make use of it
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:
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:
|data-orientation||Specify either horizontal or vertical. With this, you can control whether your slider slides horizontally or vertically.|
|data-initial-position||At 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-width||Enter 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-color||Here 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-down||Specify true or false here. If you select true here, your slider will only be active when you hold down the mouse button.|
|data-cursor||Here 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-line||Here 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-factor||If 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-interactive||If 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-animation||With true or false you can determine whether your slider should automatically play an animation in case there is no user interaction.|
|data-auto-animation-speed||Here you define the speed of the automatic animation in seconds.|
|data-auto-animation-pause||Here 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-easing||Here you determine which easing function should be used for the automatic animation. The following functions are available: linear, |
|data-control-others||If 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-others||If 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-reverse||If 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-group||You 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-sync||You 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-loading||Here 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-offset||If 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 |
|data-sleep-mode||Here 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
See Demo And Download
Official Website(NiklasKnaack): Click Here