Skip to main content

Image SlideShow in javascript

// * Dependencies *

// this function requires the following snippets:

// JavaScript/images/switchImage

// BODY Example:

// body onLoad="mySlideShow1.play(); mySlideShow2.play();"

// img src="originalImage1.gif" name="slide1"

// img src="originalImage2.gif" name="slide2"



// SCRIPT Example:

// var mySlideList1 = ['image1.gif', 'image2.gif', 'image3.gif'];

// var mySlideShow1 = new SlideShow(mySlideList1, 'slide1', 3000, "mySlideShow1");

// var mySlideList2 = ['image4.gif', 'image5.gif', 'image6.gif'];

// var mySlideShow2 = new SlideShow(mySlideList2, 'slide2', 1000, "mySlideShow2");

function SlideShow(slideList, image, speed, name)

{

this.slideList = slideList;

this.image = image;

this.speed = speed;

this.name = name;

this.current = 0;

this.timer = 0;

}

SlideShow.prototype.play = SlideShow_play;

function SlideShow_play()

{

with(this)

{

if(current++ == slideList.length-1) current = 0;

switchImage(image, slideList[current]);

clearTimeout(timer);

timer = setTimeout(name+'.play()', speed);

}

}

Comments

Popular posts from this blog

Android ref links

  Library reference resources: MVVM Architecture :  https://developer.android.com/jetpack/guide Hilt:  https://developer.android.com/training/dependency-injection/hilt-android Coroutines:  https://developer.android.com/kotlin/coroutines Retrofit:  https://square.github.io/retrofit/ Moshi:  https://github.com/square/moshi Coil:  https://coil-kt.github.io/coil/ Leak Canary:  https://square.github.io/leakcanary/ Concept reference resources: Repository Codelab:  https://developer.android.com/codelabs/kotlin-android-training-repository Room and Coroutines Codelab:  https://developer.android.com/codelabs/kotlin-android-training-room-database Room and Flow Codelab:  https://developer.android.com/codelabs/basic-android-kotlin-training-intro-room-flow Hilt Codelab:  https://developer.android.com/codelabs/android-hilt Navigation Codelab:  https://developer.android.com/codelabs/jetpack-compose-navigation Theming Codelab:  https:...