Jquery-based scroll mouse to zoom in and zoom out image effects _ jquery-js tutorial

Source: Internet
Author: User
Jquery-based scroll mouse to zoom in and zoom out the image. For more information, see. Today, I want to scroll down and zoom out the image. It seems very simple. I searched the internet and found the onmousewheel example. All of them only support the IE browser, the result shows that Firefox has the corresponding DOMMouseScroll to process this function. The Code is as follows, and the notes are added:

The Code is as follows:


$ (Function (){
$ (". Body img"). each (function (){
If ($. browser. msie ){
$ (This). bind ("mousewheel", function (e ){
Var e = e | event, v = e. wheelDelta | e. detail;
If (v> 0)
ResizeImg (this, false); // enlarge the image.
Else
ResizeImg (this, true); // scale down the image
Window. event. returnValue = false; // remove the default browser scrolling event
// E. stopPropagation ();
Return false;
})
} Else {
$ (This). bind ("DOMMouseScroll", function (event ){
If (event. detail <0)
ResizeImg (this, false );
Else
ResizeImg (this, true );
Event. preventDefault () // remove the default browser rolling event

// Event. stopPropagation ();})
}
});
Function resizeImg (node, isSmall ){
If (! IsSmall ){
$ (Node). height ($ (node). height () * 1.2 );
} Else
{
$ (Node). height ($ (node). height () * 0.8 );
}
}
});


Click here for the demo in this article: Scroll the mouse to zoom in and out the image

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.