www.webdeveloper.com
Results 1 to 5 of 5

Thread: Fading Image Slideshow?

  1. #1
    Join Date
    Jul 2010
    Posts
    9

    Fading Image Slideshow?

    Hi, Does anybody know how to create an Image Slideshow like the one on the main page of http://www.game.co.uk?? I want it simple, don't want loads of script that half of it can be taken out.

  2. #2
    Join Date
    Jul 2008
    Location
    Europe
    Posts
    13

    Fading image slideshow

    Hi Fleewood,

    This is the code you would use if you choose Magic Slideshow:

    1. Add the JS and CSS to the <head>:

    Code:
    <link rel="stylesheet" type="text/css" href="magicslideshow.css"/>
    <script src="magicslideshow.js" type="text/javascript">
    2. Add a div with your images in it. e.g:

    Code:
    <div class="MagicSlideshow">
    <img src="example1.jpg"/>
    <img src="example2.jpg"/>
    <img src="example3.jpg"/>
    </div>
    3. Customize your slideshow by using over 30 parameters. e.g.:

    Code:
    <script type="text/javascript">
    MagicSlideshow.options = {
    'speed':'10',
    'pause':'hover',
    'arrows':'no'
    }
    </script>
    The code above will fade images every 10 seconds, pause it on mouse hover and hide the arrows.

    That's it.

    Now if you want to link each image to a URL, add an href to each image like do:

    Code:
    <div class="MagicSlideshow">
    <a href="example1.htm"><img src="example1.jpg"/></a>
    <a href="example2.htm"><img src="example2.jpg"/></a>
    <a href="example3.htm"><img src="example3.jpg"/></a>
    </div>
    More fading image options are here:

    http://www.magictoolbox.com/magicslideshow_integration/

  3. #3
    Join Date
    Jul 2010
    Posts
    9
    thats not what I wanted, but thanks anyway.
    Last edited by Fleewood; 07-21-2010 at 03:22 PM.

  4. #4
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,709
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <style type="text/css">
    /*<![CDATA[*/
    #tst {
      position:relative;width:260px;height:200px;border:solid black 1px;
    }
    #tst IMG {
     width:100%;height:100%;
    
    }
    
    #tst1 {
      position:relative;width:260px;height:200px;border:solid black 1px;
    }
    #tst1 IMG {
     width:100%;height:100%;
    
    }
    
    /*]]>*/
    </style>
    
    </head>
    
    <body>
    <div id="tst">
     <img src="http://www.dynamicdrive.com/dynamicindex14/stadium.jpg" />
     <img src="http://www.dynamicdrive.com/dynamicindex14/winter.jpg" />
     <img src="http://www.dynamicdrive.com/dynamicindex14/duck.jpg" />
    </div>
    <input type="button" name="" value="Next" onclick="S1.Next(1);" />
    <input type="button" name="" value="Prev" onclick="S1.Next(-1);" />
    <input type="button" name="" value="Auto" onclick="S1.Auto();"/>
    <input type="button" name="" value="Pause" onclick="S1.Pause();"/>
    <input type="button" name="" value="GoTo 0" onclick="S1.GoTo(0);"/>
    <input type="button" name="" value="GoTo 1" onclick="S1.GoTo(1);"/>
    <input type="button" name="" value="GoTo 2" onclick="S1.GoTo(2);"/>
    <div id="tst1">
     <img src="http://www.dynamicdrive.com/dynamicindex14/stadium.jpg" />
     <img src="http://www.dynamicdrive.com/dynamicindex14/winter.jpg" />
     <img src="http://www.dynamicdrive.com/dynamicindex14/duck.jpg" />
    </div>
    <script type="text/javascript">
    /*<![CDATA[*/
    function zxcSS(o){
     var parent=document.getElementById(o.ID)                // the parent node of the images
     var imgs=parent.getElementsByTagName('IMG');            // the images in the parent node, the parent must be position 'relative' in the CSS
     this.ary=[];                                            // create a script instance array to store fade animator instances
     for (var z0=0;z0<imgs.length;z0++){                     // rotate through the images
      imgs[z0].style.position='absolute';                    // to allow the images to be placed on top of each other
      imgs[z0].style.zIndex=z0>0?'0':'1';                    // the first image is on top
      imgs[z0].style.left='0px';                             // all images have a position left of 0px
      imgs[z0].style.top='0px';                              // all images have a position top of 0px
      this.ary[z0]=new zxcFadeAnimator(imgs[z0],z0>0?0:100); // each field of this.ary contains a new instance for the fade animator with an image as its object
      this.ary[z0].opacity(z0>0?0:100);                      // set the opacity of the top image to 100 and the balance to 0
     }
     this.cnt=0;                                             // create a script instance counter this.cnt to 0
     this.lst=this.ary[0];                                   // create a script instance object referencing the top image
     this.ms=o.Duration||1000;                               // create a script instance recording the fade duration
     this.hold=o.Hold||this.ms*2;                            // create a script instance recording the automatic image change duration
    }
    
    zxcSS.prototype={
    
    // the instance 'GoTO' function
    // pass a number of the instance ary field to fade in that image
     GoTo:function(nu){
      clearTimeout(this.to);  // clear the timeout of the instance 'Auto' function
      if (this.ary[nu]){      // make sure the instance ary field exists
       this.cnt=nu;           // set the instance count to the number
       this.Next(0);          // call the instance 'NEXT' function passing 0 which will not increment the count
      }
     },
    
    // the instance 'Next' function
    // pass 1 or -1 to increment or decrement the intance count
     Next:function(ud){
      clearTimeout(this.to);                       // clear the timeout of the instance 'Auto' function
      this.lst.obj.style.zIndex='0';               // move the last image to the bottom
      this.lst.fade(this.lst.data[0],0,this.ms);   // fade out the last image
      this.cnt+=ud;                                // increment or decrement the intance count
      this.cnt=this.cnt<0?this.ary.length-1:this.cnt>=this.ary.length?0:this.cnt; // if the count is less than 0 set it to the maximum, if grater then the maximum set it to 0
      this.lst=this.ary[this.cnt];                 // change the instance lst to the new image
      this.lst.obj.style.zIndex='1';               // move the last image to the top
      this.lst.fade(this.lst.data[0],100,this.ms); // fade in the last image
     },
    
    // the instance 'Auto' function
    // to automatically change the images
     Auto:function(){
      clearTimeout(this.to); // clear the timeout of the instance 'Auto' function
      var oop=this;          // assign the instance to a local vaiable  to allow the setTimeout to function
      this.Next(1);          // call the instance 'Next' function  passing 1 to increment the count
      this.to=setTimeout(function(){ oop.Auto(); },this.hold+this.ms); // recall 'Auto' after the 'hold' plus 'fade' duration
     },
    
     Pause:function(){
      clearTimeout(this.to);
     }
    
    }
    
    
    // Opacity Fade Animator
    function zxcFadeAnimator(obj,srt){
     this.obj=obj;            // the instance object
     this.data=[srt];         // and array the current, start and finish value of opacity
     this.to=null;
    }
    
    zxcFadeAnimator.prototype={
    
    // instace function 'fade'
    // to start a fade in or fade out
    // parameter 0 = the fade start value.  (digits)
    // parameter 1 = the fade finish value. (digits)
    // parameter 0 = the fade duration.     (digits)
     fade:function(srt,fin,ms){
      clearTimeout(this.to);         // stop the instance setTimeout
      this.data=[srt,srt,fin];       // assign the current, start and finish value of opacity
      this.ms=ms*1;                  // the duration of the effect
      this.srt=new Date().getTime(); // the start time of the change
      this.change();                 // start the change
     },
    
    // instance function 'change'
    // to control the change of fade in or fade out
     change:function(){
      var oop=this;                                                      // assign the instance to a local vaiable  to allow the setTimeout to function
      var ms=new Date().getTime()-this.srt;                              // the current time minus the start time
      this.data[0]=(this.data[2]-this.data[1])/this.ms*ms+this.data[1];  // increment the current value dependent on the start and finish values and elapsed time
      this.opacity(this.data[0]);                                        // set the opacity to the current value
      if (ms<this.ms){                                                   // if the elapsed time is less than the 'fade duration' recall function opac
       this.to=setTimeout(function(){oop.change()},10);
      }
      else {
       this.data[0]=this.data[2];                                        // set the current value to the finish value
       this.opacity(this.data[0]);                                       // set the opacity to the current value(finish value)
      }
     },
    
    // instance function 'opacacity'
    // to control the change of fade in or fade out
     opacity:function(opc){
      opc=opc<0?0:opc>100?100:opc;
      var obj=this.obj;
      obj.style.filter='alpha(opacity='+opc+')';
      obj.style.opacity=obj.style.MozOpacity=obj.style.WebkitOpacity=obj.style.KhtmlOpacity=opc/100-.001;
     }
    
    
    }
    
    
    /*]]>*/
    </script>
    <script type="text/javascript">
    /*<![CDATA[*/
    
    // generatate a new instance of the script.
    var S1=new zxcSS({
     ID:'tst',      // the unique ID name of the images parent node.                 (string)
     Duration:1000, // (optional) the duration of the fade effect in milliseconds.   (digits, default = 1000)
     Hold:2000      // (optional) the hold duration of automatic changing of images. (digits, default = Duration*2)
    });
    
    var S2=new zxcSS({
     ID:'tst1',      // the unique ID name of the images parent node.                 (string)
     Duration:500, // (optional) the duration of the fade effect in milliseconds.   (digits, default = 1000)
     Hold:2000      // (optional) the hold duration of automatic changing of images. (digits, default = Duration*2)
    });
    
    S2.Auto();
    
    /*]]>*/
    </script>
    </body>
    
    </html>
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  5. #5
    Join Date
    Jul 2010
    Posts
    9
    thanks vwphillips.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12510 seconds
  • Memory Usage 2,900KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (5)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates