I am trying to execute a transition for an image gallery. When the gallery transitions to the next slide, I will put it just to the left of the current slide, and slide it over the current slide by transitioning on its left
style.
My current markup:
<section id="nd-gallery">
<div class="nd-slide nd-slide-current">
slide 1
</div>
<div class="nd-slide nd-slide-next">
slide 2
</div>
</section>
Relevant CSS:
#nd-gallery{
position:relative;
height:100px;
width:100px;
}
#nd-gallery > .nd-slide{
position:absolute;
height:100px;
height:100px;
outline:1px solid red;
left:-40px;
}
#nd-gallery > .nd-slide.nd-slide-current{
z-index:5;
left:0;
}
So, by default, I offset slides by moving them left by 40px (obviously I will hide them better outside of this demo with a larger offset)
Now, with some script, I want to:
Apply a new
left
value to the next slide to offset it (for the purpose of this demo, 50px which offset the next slide over the current slide by half)Assign the appropriate transition properties
Assign a new
left
value so that the next slide will slide over the current slide
SCRIPT:
var next = document.querySelector('.nd-slide-next');
next.style.left = '-50px';
next.style.transitionProperty = 'left';
next.style.transitionDuration = '5s';
next.style.left = '0';
However, when I run this, the next slide appears on top of the current slide without a transition:
Note: Apparently Firefox performs the transition properly. In Chrome v.32 on Windows 7, the transition is not performed. Can anyone point out if I've done something incorrect, or perhaps I'm dealing with a bug in Chrome?