Animated Customizable Image Comparison Plugin with jQuery Cross2 - Download Animated & Customizable Image Comparison Plugin with jQuery - Cross2

Download Animated & Customizable Image Comparison Plugin with jQuery – Cross2

Posted on

This time I will share jQuery Plugin and tutorial about Animated & Customizable Image Comparison Plugin with jQuery – Cross2, hope it will help you in programming stack.

Animated Customizable Image Comparison Plugin with jQuery Cross2 - Download Animated & Customizable Image Comparison Plugin with jQuery - Cross2
File Size: 172 KB
Views Total: 1869
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Just another jQuery based image diff tool for creating an animated, customizable image comparison slider to view before and after images.

Features:

  • Custom text labels for before / after images.
  • Horizontal or vertical comparison slider.
  • Supports mouse wheel and mouse drag.
  • Easing functions based on jQuery easing plugin.
  • Allows to compare before / after images programmatically.

Basic usage:

1. Add the required jQuery Cross2 plugin’s stylesheet to the head section of the web page.

1 <link href="css/jquery.cross2.css" rel="stylesheet">

2. Add the jQuery Cross2 plugin’s script and other required resources at the bottom of the web page.

1 <script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
2 <script src="/path/to/jquery.event.drag.min.js"></script>
3 <script src="js/jquery.cross2.js"></script>

3. Include the OPTIONAL jQuery mousewheel plugin for mouse wheel support.

1 <script src="/path/to/jquery.mousewheel.js"></script>

4. Include the OPTIONAL jQuery easing plugin for additional easing effects.

1 <script src="/path/to/jquery.easing.min.js"></script>

5. Insert before and after images you want to compare into a container like this:

1 <div id="demo" class="cross2">
2   <img src="1.jpg" alt="before">
3   <img src="2.jpg" alt="after">
4 </div>

6. Initialize the plugin by calling the function on the top element.

1 $('#demo').cross2();

7. There are several configuration options which can be passed to cross2() method as an object:.

01 // initial slider position
02 // 0.5 = half
03 value: 0.5,
04  
05 // vertial or horizontal slider
06 vertical: false,
07  
08 // animation duration in ms
09 animationDuration: 150,
10  
11 // easing effect
12 // requirs jQuery easing plugin
13 easing: 'swing',
14  
15 // compare images on click
16 clickEnabled: false,
17  
18 // enable mouse drag
19 mousemoveEnabled: false,
20  
21 // enable mouse wheel
22 // requirs jQuery mousewheel plugin
23 mousewheelEnabled: false,
24  
25 // show before / after text labels
26 titlesEnabled: true,
27  
28 // text label for before image
29 titleBefore: 'Before',
30  
31 // text label for after image
32 titleAfter: 'After'

8. Public methods.

01 // show before image
02 $('#demo').data('cross2').showBefore();
03  
04 // show after image
05 $('#demo').data('cross2').showAfter();
06  
07 // set value option to 0.5
08 $('#demo').data('cross2').showHalfs();
09  
10 // destroy the plugin
11 $('#demo').data('cross2').destroy();

This awesome jQuery plugin is developed by nxeed. For more Advanced Usages, please check the demo page or visit the official website.

source : jqueryscript.net