


Implementing mouse wheel driven picture switching effect based on jquery_jquery
jQuery can produce animation effects comparable to Flash. There is absolutely no doubt about this. This article will demonstrate an image switching effect based on mouse wheel drive through an example.
The effect achieved in this example:
The picture switches when the mouse wheel is scrolled.
Supports keyboard arrow keys to achieve image switching effects.
Supports clicking to switch pictures and clicking on the current picture link.
The progress bar slider shows the progress of the number of pictures.
XHTML
<div class="demo"> <div id="imageflow"> <div id="Implementing mouse wheel driven picture switching effect based on jquery_jquery"><img src="/static/imghwm/default1.png" data-src="images/loader.gif" class="lazy" alt="Implementing mouse wheel driven picture switching effect based on jquery_jquery" /></div> <div id="captions"></div> <div id="images"> <img src="/static/imghwm/default1.png" data-src="images/s1.jpg" class="lazy" alt="image1" /> <img src="/static/imghwm/default1.png" data-src="images/s2.jpg" class="lazy" alt="image2" /> <img src="/static/imghwm/default1.png" data-src="images/s3.jpg" class="lazy" alt="image3" /> <img src="/static/imghwm/default1.png" data-src="images/s4.jpg" class="lazy" alt="image4" /> </div> <div id="scrollbar"> <div id="slider"></div> </div> </div> </div>
div.demo is the outermost layer and contains all the elements needed for the entire scrolling effect. #imageflow is required, and the ID name of the element contained within it cannot be modified. If you really want to modify it, you must first define or directly modify the JS code . #Implementing mouse wheel driven picture switching effect based on jquery_jquery is used to load a Implementing mouse wheel driven picture switching effect based on jquery_jquery animation image. Of course, you can also write "Implementing mouse wheel driven picture switching effect based on jquery_jquery" or other text directly. #captions is used to display the caption of the image. #imagesPlace the images you want to scroll and switch. There is no limit to the number. #scrollbar is a progress bar that displays pictures. #slider is a slider. When switching pictures, the slider will slide to the corresponding position to display the number of pictures.
CSS
.demo { width:860px; height:300px; margin:20px auto; position:relative; background:#e8f5fe; overflow:hidden } #images { margin:20px 0 0 60px; width:860px } #images img { position:absolute; margin-top:-160px } #Implementing mouse wheel driven picture switching effect based on jquery_jquery { margin:0; color:#fff; text-align:center } #Implementing mouse wheel driven picture switching effect based on jquery_jquery img { position:ralative; margin:0 } #captions { position:relative; height:24px; line-height:24px; top:100px; left:320px; background:url(images/cap_bg.png) no-repeat center center; color:#fff; font-weight:bold; text-align:center; z-index:10000 } #scrollbar { position:relative; top:-100px; height:2px; z-index:10001 background:#abcd3a url(images/scroll.gif) repeat-x; } #slider { position:absolute; width:15px; height:4px; margin:-1px 0 0 -1px; background:url(images/bar.gif) no-repeat; z-index:10002 }
CSS is the key part to achieve the entire effect. If CSS is not well controlled, you will not get the effect you want.
.demo sets the width and height, and sets position:relative and overflow:hidden in order to limit the scope of the mouse wheel scrolling to the .demo. #images sets the margin value and sets the relative positioning of the internal img. #captions sets the style used to display the picture title. Note that I use the semi-transparent picture cap_bg.png as the background picture. Transparent png pictures are not supported under IE6, so you Relevant processing is required. Next, let’s look at the settings of the scrolling progress bar and slider. They all use positioning and depth settings. Why are they set like this? Only if you test them slowly will you know the secret.
Introduce jquery library and sliding js file
<script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/imageflow.js"></script>
All js actions are completed in imageflow.js. I only made slight changes and everyone can use it directly.
Now you can see the effect. But there is still a problem:
How to obtain the picture link address?
The final effect should be that when you click on the currently displayed image, you will be connected to a page to display detailed information related to the image. So how to get this link address? There are two lines of code starting from line 252:
image.url = image.getAttribute("longdesc"); image.ondblclick = function() { document.location = this.url; }
It can be seen that the link address of the picture comes from its attribute: longdesc. When the picture is clicked, the page will jump to the corresponding address page. Well, now that we're back to the XHTML code we started with, we just need to assign the longdesc attribute to each image and set the value to the corresponding web page address. Such as:
<img src="/static/imghwm/default1.png" data-src="images/s1.jpg" class="lazy" alt="image1" longdesc="#" />
Now, the task is completed. After reading this example, you will find that you don't need any jquery code at all, because imageflow has already completed all the operation codes.
The above is the entire content of this article, I hope it will be helpful to everyone’s study.

JavaScript core data types are consistent in browsers and Node.js, but are handled differently from the extra types. 1) The global object is window in the browser and global in Node.js. 2) Node.js' unique Buffer object, used to process binary data. 3) There are also differences in performance and time processing, and the code needs to be adjusted according to the environment.

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools
