From our sponsor: Meco is a distraction-free space for reading and discovering newsletters, separate from the inbox.
Today we’d like to share an experimental slideshow effect with you. The idea is based on a Dribble shot called GIF Exercise by Sergey Valiukh where a lot of jell-o-like movements are happening. Navigating from one item to another makes the items move in a wobbly fashion and we thought this might be great to try out on a real slideshow. To achieve this effect we used Snap.svg and animated the slide background SVGs in order to simulate the elastic effect. What happens is that we basically morph an SVG path from a rectangle to a curved shaped; either a right curve or a left curve, depending on where we are navigating to.
Please note that this is highly experimental and tested only in the latest versions of modern browsers.
The beautiful icons are from the great free Ballicons 2 icon set created by Pixel Buddha and released on Smashing Magazine.
The markup of the slideshow is a unordered list wrapped by a division:
<div id="slideshow" class="slideshow"> <ul> <li> <div class="slide"> <!-- ... --> </div> </li> <li><!-- ... --></li> <li><!-- ... --></li> <!-- ... --> </ul> </div>
What we do is to insert an SVG before the slide with a path that is a rectangle. The SVG looks as follows after being inserted:
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 80 60" preserveAspectRatio="none"> <path d="M33,0C33,0,74,0,74,0C74,0,69,9.871,69,29.871C69,49.871,74,60,74,60C74,60,32.666,60,32.666,60C32.666,60,32.541,60,32.541,60C32.541,60,6,60,6,60C6,60,1,50,1,30C1,10,6,0,6,0C6,0,33,0,33,0" /> </svg>
The three different SVG paths make up the following shapes:
You can also find the SVGs in the image folder.
Depending on where we navigate to, we will either bend the shape to the left or to the right. This animation will make it seem as if the are pulling or pushing an elastic object.
The paths are defined in the slideshow options:
SliderFx.prototype.options = { // default transition speed (ms) speed : 500, // default transition easing easing : 'ease', // path definitions paths : { rect : 'M33,0h41c0,0,0,9.871,0,29.871C74,49.871,74,60,74,60H32.666h-0.125H6c0,0,0-10,0-30S6,0,6,0H33', curve : { right : 'M33,0h41c0,0,5,9.871,5,29.871C79,49.871,74,60,74,60H32.666h-0.125H6c0,0,5-10,5-30S6,0,6,0H33', left : 'M33,0h41c0,0-5,9.871-5,29.871C69,49.871,74,60,74,60H32.666h-0.125H6c0,0-5-10-5-30S6,0,6,0H33' } } }
Tiny break: 📬 Want to stay up to date with frontend and trends in web design? Subscribe and get our Collective newsletter twice a tweek.
Here is how we actually control the morphing of the paths when navigating:
SliderFx.prototype._morphSVGs = function( callback ) { var self = this, speed = this.options.speed, pathCurvedLeft = this.options.paths.curve.left, pathCurvedRight = this.options.paths.curve.right, pathRectangle = this.options.paths.rect, dir = this.old < this.curr ? 'right' : 'left'; // morph svg path on exiting slide to "curved" this.items[ this.old ].path.stop().animate( { 'path' : dir === 'right' ? pathCurvedLeft : pathCurvedRight }, speed * .5, mina.easeout ); // the slider starts a bit later... setTimeout(function() { callback.call(); }, speed * .2 ); // change svg path on entering slide to "curved" var currItem = this.items[ this.curr ]; currItem.querySelector('path').setAttribute( 'd', dir === 'right' ? pathCurvedLeft : pathCurvedRight ); // morph svg path on entering slide to "rectangle" setTimeout(function() { currItem.path.stop().animate( { 'path' : pathRectangle }, speed * 3, mina.elastic ); }, speed * .5 ); }
The timing is the most important aspect here. For example, when morphing the SVG path to the right curve, we want to make sure that the morphing takes half as long as the movement of the slides (i.e. speed * .5
). This ensures that we still see it getting curved before the slide disappears. We also delay the start of the slider movement a tidbit. The entering slide’s path will be first set to be curved and then we morph it to the rectangle shape. You can change the direction of the curve so that you change the effect to look like the element is being pulled or pushed. Change dir === 'right'
to dir === 'left'
for the entering slide to see the difference. In the last morph where we set the entering path to become a rectangle, we can play with two durations: the speed of the morphing and the delay. We want the morphing to take longer so that we actually see the incoming shape performing its jell-o show. Play with that value and if you like, the easing, in order to achieve subtle, but impactful effects.
It’s a matter of how you want the effect to appear, so if you play with all those timings, you will see how the movement reflects almost different substances: would you like some pudding or do you prefer some jell-o? ๐
If you’d like to see another example in action, check it out here: Alternative Wobbly Slideshow Effect
The code here was changed as follows:
// morph svg path on exiting slide to "curved" this.items[ this.old ].path.stop().animate( { 'path' : dir === 'right' ? pathCurvedLeft : pathCurvedRight }, speed * .7, mina.easeout ); // the slider starts a bit later... setTimeout(function() { callback.call(); }, speed * .3 ); // change svg path on entering slide to "curved" var currItem = this.items[ this.curr ]; currItem.querySelector('path').setAttribute( 'd', dir === 'left' ? pathCurvedLeft : pathCurvedRight ); // morph svg path on entering slide to "rectangle" setTimeout(function() { currItem.path.stop().animate( { 'path' : pathRectangle }, speed * 5, mina.elastic ); }, speed * .8 );
You can read more about how to use Snap.svg on their website and especially the documentation.
We hope you enjoy this little fun effect and get inspired!
Greaaaaat !
Thanks a lot ! ๐
Muito bom, como sempre !! ๐
Man, this is awesome! ๐
Looks good, but is so slow even in chrome.
very good, thanks
Looks great on FF/mac. Very cool!
Great slideshow, but it’s looks crappy without vsync ๐
That’s great idea, thanks for sharing ๐
Looks very good, but isn’t it wobbling to the wrong side?
When you move to the slide on the right shouldn’t it wobble to the right?
meh! childish effects.
Great the way the navigation arrows move when they would otherwise be below the bottom of the screen.
Nice effect, but my procesor don’t like this.
CPU
how awesome and creative you are .love your imagination .may god give you more creativity.this is simply best.
Awesome, same as ever…
amazing !! i like this tutorial
This looks brilliant, I love what you guys are doing. Keep up the great work.
Handsome?Thanks.
amazing !! i like this tutorial
I cannot wait to see if you guys make a more stable version of this. Definitely love it.
Great post and nice blog. Awesome !
Looks great and works perfect in Chrome
Thanks Mary Lou
Really Nice Effect , Great job!
Great tutorial. Love it! thanx.
btw, it really looks like LG WebOS Menu/APP transition effect..
This is really awesome. i love it. perhaps i’ll try something similar at my next code presentation.
I like this ^^
How can I say it? I really appreciate it. Love it very much. Thanks a lots.
Awesome ! ๐
Please anyone how could I navigate between the divs with a swipe ?
very nice one but how can i move arrow from bottom to left and right?
Really Nice Effect , Great job!
Hello, this effect looks great. Is it possible to initialize it in some other slide, for instance I have 3 slides, I need it to start in Slide 2. Also I would like to make it cyclic. Is it possible?
Great great Item. Does anyone know how to automate the transitions?
Hello Great work! i would like to ask if its free to use? thank you
How can i make the svg in full width?
Thanks! Great! cyrillic no work ((( please help!!!