jquery implementation of the original artwork contrast curtain effect _jquery

Source: Internet
Author: User
Effect:

HTML code:
Copy Code code as follows:

<div class= "Vfx-image-wrap Special" >
<div class= "Before-image" style= "width:50%; Transition:all 0.3s ease 0s; " >

</div>
<div class= "After-image" >

</div>
<div class= "Divider-bar" style= "left:50%; Transition:all 0.3s ease 0s; " ></div>
</div>

JS Code:
Copy Code code as follows:

$ (function () {
Outside Div
var imagewrap = $ ('. Vfx-image-wrap '),
Foreground chart
Topimage = $ (this). Find ('. Before-image '),
Split Line
Divider = $ (this). Find ('. Divider-bar '),
Staybounce = $ ('. Toggle-function ');

Imagewrap.on ("MouseMove", function (e) {
Gotta localize top image and divider I only applies to this
var offsets = $ (this). Offset (),
Fullwidth = $ (this). Width (),
MouseX = E.pagex-offsets.left,
Topimage = $ (this). Find ('. Before-image '),
Divider = $ (this). Find ('. Divider-bar ');

if (MouseX < 0) {
MouseX = 0;
else if (MouseX > Fullwidth) {
MouseX = Fullwidth
}
$ (this). addclass (' special ');
Divider.css ({left:mousex, Transition: ' None '});
Topimage.css ({width:mousex, Transition: ' None '});
});
Staybounce.click (function () {
$ (this). Toggleclass (' Stay ');
});

Imagewrap.on ("MouseLeave", function () {
if (!staybounce.hasclass (' Stay ')) {
Divider.css ({left: ' 50% ', transition: ' All 3s '});
Topimage.css ({width: ' 50% ', transition: ' All 3s '});
}
});
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.