Native JavaScript implements picture Carousel effect Code _javascript Skill

Source: Internet
Author: User
See Bluedream on his blog on the JavaScript imitation QQ sliding menu effect, the code is elegant, compared to highlight the next time he stole the essence of his code, hey.
"principle Brief"
HTML and CSS are the same as those in jquery, which are omitted from the image carousel effect. It is mainly a few common functions, fade and fading, which are implemented with closure. As for the logical part of the subject, very general.
"program Source"
Paste a few public functions forget, fadeIn, fade, fadeout, gradually lost
Copy Code code as follows:

function ID (name) {return document.getElementById (name);}
Traversal function
function each (arr, callback) {
if (Arr.foreach) {Arr.foreach (callback);}
else {
for (var i = 0, len = arr.length i < len; i++) Callback.call (this, arr[i), I, arr);
}
function FadeIn (elem) {
SetOpacity (elem, 0)
for (var i = 0; i < i++) {
(function () {
var pos = i * 5;
settimeout (function () {
SetOpacity (Elem, POS)
}, I * 25);
}) (i);
}
}
function fadeout (elem) {
for (var i = 0; I <= i++) {
(function () {
var pos = 100-i * 5;
settimeout (function () {
SetOpacity (Elem, POS)
}, I * 25);
}) (i);
}
}
Set transparency
function setopacity (Elem, level) {
if (elem.filters) {
Elem.style.filter = "Alpha (opacity=" + level + ")";
} else {
elem.style.opacity = level/100;
}
}

"Invoke Method"
Count: Number of pictures, Wrapid: div,ulid: Button div,infoid: Information Bar
Babyzone.scroll (count,wrapid,ulid,infoid);
Babyzone.scroll (4, "banner_list", "List", "Banner_info");
"Source Download"
/201009/yuanma/scroll_babyzone.rar
Related Article

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.