Skip to content

Commit

Permalink
Every slide except the previous and the next one have display:none. T…
Browse files Browse the repository at this point in the history
…his allows for interesting transitions without the performance overhead
  • Loading branch information
Lea Verou committed Oct 1, 2011
1 parent 17c3c43 commit acbd503
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions slideshow.css
Expand Up @@ -14,6 +14,7 @@
}

.slide {
display: none;
position:absolute;
top:0;
right:0;
Expand All @@ -37,6 +38,13 @@
transition:1s opacity, 1s transform;
}

.slide.previous,
.slide:target,
.slide:target + .slide, /* just in case, not really needed */
.slide.next {
display: block;
}

.slide:target {
z-index:100;
opacity:1;
Expand Down
12 changes: 12 additions & 0 deletions slideshow.js
Expand Up @@ -361,6 +361,18 @@ self.prototype = {
if(window.opener && opener.slideshow && opener.slideshow.slide != this.slide) {
opener.slideshow.goto(this.slide);
}

// Update next/previous
for (var i=this.slides.length; i--;) {
this.slides[i].classList.remove('previous');
this.slides[i].classList.remove('next');
}

this.slides.previous = this.slides[this.slide-1];
this.slides.next = this.slides[this.slide+1];

this.slides.previous && this.slides.previous.classList.add('previous');
this.slides.next && this.slides.next.classList.add('next');
}

// If you attach the listener immediately again then it will catch the event
Expand Down

2 comments on commit acbd503

@BenoitZugmeyer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, the counter-increment won't work on display:none elements, so the slide counter stays at 2 for the slides >= 2. http://www.w3.org/TR/css3-content/#counters0

@LeaVerou
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've just fixed it. :)

Please sign in to comment.