Giter Club home page Giter Club logo

slideshow's Introduction

SlideShow

SlideShow

Extensible mid-level class that manages transitions of elements that share the same space, typically for slideshows, tabs, and galleries.

View the demo site for real world examples.

View the Docs for all methods and details.

Features:

  • Custom transitions
  • Autoplay
  • Reverse
  • Show next slide
  • Show previous slide
  • Show arbitrary slide
  • Transitions by slide
  • Durations by slide
  • Default transitions
  • Default durations
  • On-the-fly transitions

19 Transitions Out-of-the-Box

  • fade
  • crossFade
  • fadeThroughBackground
  • pushLeft, pushRight, pushUp, pushDown
  • blindLeft, blindRight, blindUp, blindDown
  • slideLeft, slideRight, slideUp, slideDown
  • blindLeftFade, blindRightFade, blindUpFade, blindDownFade

Events

  • onShow
  • onShowComplete
  • onPlay
  • onPause
  • onReverse

CSS Transitions!

New in 2.0, SlideShow.CSS has a method to override JS animations with CSS3 animations. Still experimental.

How to use

Simple Example

HTML

SlideShow naturally grabs all children elements of a parent as the slides.

#HTML
<div id=slideshow>
  <div>Slide 1</div>
  <img src=image.jpg>
  <div>Slide 3</div>
</div>

CSS

Most transitions require absolutely positioned slides with top and left set to 0. SlideShow doesn't do this for you, keeping it more flexible for all types of transitions:

#CSS
#slideshow {
  width: 500px;
  height: 300px;
  overflow: hidden;
  position: relative; /* not required, slideshow will set this for you */
}

#slideshow > * {
  position: absolute; /* required for most transitions */
  top: 0;             /* ditto */
  left: 0;            /* ditto */
  width: 100%;        /* usually required */
  height: 100%;       /* same */
}

JavaScript

#JS
var slideshow = new SlideShow('slideshow', {
  transition: 'fadeThroughBackground',
  delay: 5000,
  duration: 400,
  autoplay: true
});

Declarative Example

HTML

SlideShow can get all of the information it needs from the data-slideshow attribute in your HTML, and allows you to have different transitions for each slide.

#HTML
<div id=slideshow data-slideshow="transition:fade delay:4000 duration:750">
  <div data-slideshow="transition:pushUp">Slide 1</div>
  <img data-slideshow="transition:slideRight" src=image.jpg>
  <div data-slideshow="transition:blindDown duration:1000">Slide 3</div>
</div>

JavaScript

#JS
var slideshow = new SlideShow('slideshow');

CSS Transitions

First include the SlideShow.CSS.js file. You'll then want to verify if the browser supports CSS transitions and transforms, I typically use Modernizr:

#JS
if (Modernizr.csstransitions && Modernizr.csstransforms){
    SlideShow.useCSS();
}

Browsers that support transitions and transforms will use the new CSS transitions instead of JavaScript.

Controlling a SlideShow

slideshow.show('next');
slideshow.show('previous');
slideshow.show(2); // shows the third slide
slideshow.play();

Creating a navigation interface

$$('.some-elements-in-the-order-of-the-slides').each(function(item, index){
  item.addEvent('click', function(){
    slideshow.show(index);
  });
});

Extending SlideShow with your own transitions

You can create whatever transitions you need with the SlideShow defineTransition function.

SlideShow.defineTransition('flash', function(data){
  data.previous.setStyle('display', 'none');
  data.next.setStyle('opacity', 0);
  new Fx.Tween(data.next, {
    duration: data.duration,
    property: 'opacity'
  }).start(1);
});

slideshow's People

Contributors

adamnbowen avatar rolfnl avatar ryanflorence avatar thisconnect avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slideshow's Issues

Slides not displaying after form post.

Hi.

I am using SlideShow to 'page' through a form.

If the POSTed data does not validate, and I get redirected back to the form, the browser seems to "remember" the style="display: none;" for each slide but the first. So they appear blank. (FF3.5 FF4.0 IE7/8 Chrome)

I "fixed" this by adding a check in setupSlides() as below;

if (slide.get('style') != 'display: none;') {
    slide.store('slideshow-index', index).store('slideshow:oldStyles', slide.get('style'));
}

But I'm sure there's a better way, or some magical fix :)

multiple slideshows on a single page?

Hi Ryan,
I have just 'dropped in' slideshow2 and noticed that my second slideshow on the page has stopped working. Is this a bug or something I have done/not done.
It work perfectly when i revert to slideshow1.

thanks, pSouper

fireEvent('show') suggestion

This is not a bug, merely a suggestion. (very nice class by the way)
In the SlideShow.js 'show' method the 'show' event is fired before the 'current' slide is set. I have a case where it would help if this fireEvent call is done at the end of this method. This is very helpful when you want to add slide buttons which would call the 'show' method onclick and call an arbitrary slide to show. (one which would not be the next) I just followed your suggestions in the documentation on how to add these buttons. When you would use the onShow event to add and remove classes to and from the buttons to indicate the current slide being shown you can't use this.current or this.nextSlide() to retrieve the slide which is being shown from the click event. (current is still the previous one and nextSlide() just returns the next in the regular order). Also the show event doesn't send the slide as an argument. This can all very easily be fixed by just firing the 'show' event after the new current is set in the show method. Then you can use the this.current property in the onShow event to retrieve the related button and change its appearance to indicate which slide is 'active' after the click. The same code will then automatically do this while the slideshow is playing and progressing to the next slide.
I hope you will consider this suggestion, gr, Vic

problem since mootools 1.4.4 update

Hello
Does anyone also experience problems when trying to run the slideshow with mootools core 1.4.4? In special the "pushLeft" and pushRight" effect does not work properly. It slides only the current image away. The second image transition does not play...

I tested it with mootools 1.4.3: Here it is working again. So the problem has to be in one of the last mootools core changes?

http://mootools.net/blog/

regards, tom

CSS Transitions not working anymore in chrome (with solution)

Hi

Are you still maintaining this slideshow? However, I like it very much.

Just found out that on new versions of chrome the CSS Transitions don´t work anymore. I found out that there is a fixed "translate" property implemented in webkit (see: http://www.winktoolkit.org/discussion/topic/blog-wink-2012-roadmap )

There is a solution renaming the method in CSSAnimation.js (line 30) to:

mootranslate: function(axis, value) {

According to this I also changed the Line 49 in CSSAnimation.Mootools.js:

['mootranslate', 'rotate', 'scale', 'skew', 'matrix'].each(function(method){

and all functions calls from translate to mootranlate in SlideShowCSS.js:

function go(type, axis, data){
        var transition = {
            duration: data.duration + 'ms',
            'timing-function': 'ease',
            property: 'transform'
        };

        if (type == 'blind')
            data.next.setStyle('z-index', 2);


        if (type != 'slide')
            data.next.mootranslate(axis.property, 100 * axis.inverted);

        setTimeout(function(){
            if (type != 'slide')
                data.next.setTransition(transition).mootranslate(axis.property, 0);
            if (type != 'blind')
                data.previous.setTransition(transition).mootranslate(axis.property, -(100 * axis.inverted));
        }, 0);

    }

// ....

If youre still maintaining I can send you a pull request...
regards...

Slideshow img tag pops up through first loop

Great work !

SlideShow v. 2.1.0

I do have a question though. When I have a slide show div containing img tags, the first loop through all images behaves strange. After each transition the last pic pops up for a sec, just to fade after next transition. When first loop is finished everything looks as it should.

I can hide the slide show for a few seconds, but how to reinitialize slideshow div with new settings in mootools way: $('slideshow').reinitialize(options) ???.

There is a JS methods for this 'setup', but it displays only the first transition.

HTML:

    <img data-slideshow="transition:crossFade" style="display: none;" src="pics/tlumaczenia_small.jpg" width="450px" height="250px"></img>

    <img data-slideshow="transition:crossFade" style="display: none;" src="pics/tlumaczenia_3_small.jpg" width="450px" height="250px"></img>

    <img data-slideshow="transition:crossFade" style="display: none;" src="pics/DeadSpace_-_SiteBG.jpg" width="450px" height="250px"></img>

    <img data-slideshow="transition:crossFade" style="display: none;" src="pics/wl2S-screen.jpg" width="450px" height="250px"></img>

    <img data-slideshow="transition:crossFade" style="display: none;" src="pics/DeadSpace_-_SiteBG.jpg" width="450px" height="250px"></img>

    <img data-slideshow="transition:crossFade" style="display: none;" src="pics/deadspace.jpg" width="450px" height="250px"></img>

JS:

window.addEvent('domready', function() {
$('slideshow').playSlideShow();
...

Regards, Luke.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.