Upgrading to version 5
LayerSlider had many changes and improvements since we released the first version two years ago. We always focused on the backwards compatibility but we had to make some decisions to get more professional.
Important changes
We made a lot of changes in version 5 and - as always - we tried to keep the slider compatible with the earlier versions (and when we say 'earlier versions' we are thinking mostly of the static HTML markup / init code of your sliders built in the past).
It is important to know that your existing sliders should work 99% the same as before (except the included resource files) but there could be differences in some special cases, but even of the backwards compatibility we recommend you to make your slider 100% version 5 compatible with the following guide.
Changes in the resource files
From version 5 LayerSlider is using the powerful Greensock Animation Engine for transitons so we removed jquery transit and easing.js
<!-- LayerSlider stylesheet -->
<link rel="stylesheet" href="/layerslider/css/layerslider.css" type="text/css">
<!-- External libraries: jQuery, easing.js & jQuery Transit -->
<script src="/layerslider/jQuery/jquery.js" type="text/javascript"></script>
<script src="/layerslider/jQuery/jquery-easing-1.3.js" type="text/javascript"></script>
<script src="/layerslider/jQuery/jquery-transit-modified.js" type="text/javascript"></script>
<!-- LayerSlider script files -->
<script src="/layerslider/js/layerslider.transitions.js" type="text/javascript"></script>
<script src="/layerslider/js/layerslider.kreaturamedia.jquery.js" type="text/javascript"></script>
Including resources in earlier versions
<!-- LayerSlider stylesheet -->
<link rel="stylesheet" href="/layerslider/css/layerslider.css" type="text/css">
<!-- External libraries: jQuery & GreenSock -->
<script src="/layerslider/js/jquery.js" type="text/javascript"></script>
<script src="/layerslider/js/greensock.js" type="text/javascript"></script>
<!-- LayerSlider script files -->
<script src="/layerslider/js/layerslider.transitions.js" type="text/javascript"></script>
<script src="/layerslider/js/layerslider.kreaturamedia.jquery.js" type="text/javascript"></script>
Including resources from version 5
We made the slider more compatible and much faster with this change.
Changes in naming
From version 5 we are calling the slides to slides and the layers to layers. In earlier versions we called the slides to layers and the layers to sublayers. We know that the old naming was a little confusing (in the WordPress version of the plugin we are using the new namings for a long time ago).
Changes in the slider markup
Regarding to the name changes we changed some things in the slider markup.
<div id="layerslider" style="width: 1000px; height: 500px;">
<div class="ls-layer" style="transition2d: 2,5,23; slidedelay: 5000;">
<img class="ls-bg" src="..." />
<a class="ls-s-1" href="..." style="top: 20px; left: 100px; slidedirection: fade; durationin: 3000; easingin: linear;">some linked text</a>
<img class="ls-s-3" src="..." style="top: 50%; left: 20%; slideoutdirection: top; durationout: 1670; easingout: easeinoutquad;" />
</div>
<div class="ls-layer" style="transition3d: 33,15; slidedelay: 4000;">
<img class="ls-bg" src="..." />
<p class="ls-s-2" style="top: 40px; left: 600px; width: 200px; slideoutdirection: bottom; durationout: 500; easingout: easeinback;">some text</p>
<a class="ls-link" href="..."></a>
</div>
</div>
Slider markup in earlier versions
<div id="layerslider" style="width: 1000px; height: 500px;">
<div class="ls-slide" data-ls="transition2d: 2,5,23; slidedelay: 5000;">
<img class="ls-bg" src="..." />
<a class="ls-l" href="..." style="top: 20px; left: 100px;" data-ls="offsetxin: 0; offsetyin: 0; fadein: true; durationin: 3000; easingin: linear;">some linked text</a>
<img class="ls-l" src="..." style="top: 50%; left: 20%;" data-ls="offsetyout: top; durationout: 1670; easingout: easeinoutquad;" />
</div>
<div class="ls-slide" data-ls="transition3d: 33,15; slidedelay: 4000;">
<img class="ls-bg" src="..." />
<p class="ls-l" style="top: 40px; left: 600px; width: 200px;" data-ls="offsetxout: 0; offsetyout: bottom; fadeout: false; durationout: 500; easingout: easeinback;">some text</p>
<a class="ls-link" href="..."></a>
</div>
</div>
Slider markup from version 5
As you can see we changed the class name of the slides from 'ls-layer' to 'ls-slide' and also the class names of the layers from 'ls-s .. ' to 'ls-l'. It is important to know that you don't need to add numbers in the layer class names any more (you can set the starting / ending distance in different way), just use 'ls-l' in any cases. The class names of the slide backgrounds and the slide linking elements didn't change.
The second improvement that we moved the slide- and layer-specific properties out of the style attribute. You can use the style attribute for positioning and styling like in normal cases but you should use the new 'data-ls' attribute (both on slides and layers) for adding transition properties. We think that the slider markup became cleaner and it is easier to work with.
Changed properties in the slider init code
earlier property name |
new property name |
sublayerContainer |
layersContainer |
firstLayer |
firstSlide |
animateFirstLayer |
animateFirstSlide |
Changes in slide transitions
The slider will not animate out the layers before the slide change so layer and slide transitions can happen at the same time. Many of our users will like this feature.
Changes in layer transitions
With the new Greensock Animation Engine layers can be animating with really unlimited ways. Layers can now fade + slide at the same time and they can rotate (in 2D or 3D), skew or scale too and you can set even the transform origin of the layer transitions if you like.
You can see the earlier transition options with the version 5 compatible equivalent side by side in the following list.
earlier options |
values |
new options |
values |
defaults |
slidedirection |
left, right top, bottom fade |
offsetxin offsetyin fade |
left, right or a <num> top, bottom or a <num> true, false |
80 0 true |
slideoutdirection |
left, right top, bottom fade |
offsetxout offsetyout fadeout |
left, right or a <num> top, bottom or a <num> true, false |
-80 0 true |
durationin |
<num> |
durationin |
<num> |
1000 |
durationout |
<num> |
durationout |
<num> |
1000 |
delayin |
<num> |
delayin |
<num> |
0 |
delayout |
<num> |
removed (with showuntil you can control the out-animations of layers regarding to each other) |
showuntil |
<num> |
showuntil |
<num> |
0 |
easingin |
easing_name |
easingin |
easing_name |
|
easingout |
easing_name |
easingout |
easing_name |
|
rotatein |
<angle> |
rotatein
rotateXin
rotateYin
|
<angle>
<angle>
<angle>
|
0
0
0
|
rotateout |
<angle> |
rotateout
rotateXout
rotateYout
|
<angle>
<angle>
<angle>
|
0
0
0
|
scalein |
<num> |
scalexin
scaleyin
|
<num>
<num>
|
1
1
|
scaleout |
<num> |
scalexout
scaleyout
|
<num>
<num>
|
1
1
|
N / A |
skewxin
skewyin
|
<angle>
<angle>
|
0
0
|
N / A |
skewxout
skewyout
|
<angle>
<angle>
|
0
0
|
N / A |
transformoriginin
|
x y z
|
50% 50% 0
|
N / A |
transformoriginout
|
x y z
|
50% 50% 0
|
You have a lot more transition options in the new version. The most important thing is that you can set the starting and ending offset positions (X,Y) of layers.
<div class="ls-slide">
<img class="ls-l" src="..."
style="left: 350px; top: 230px;"
data-ls="offsetxin: 100; offsetyin: 40; offsetxout: -150; offsetyout: 100;" />
</div>
Using the offset layer transition options
Description of the transition of the layer in this example:
Transition IN
starting position X : 450px (initial left property + offsetxin)
starting position Y : 270px (initial left property + offsetyin)
ending position X : 350px (initial left property)
ending position Y : 230px (initial top property)
The layer will stay at the initial position until transition out.
Transition OUT
starting position X : 350px (initial left property)
starting position Y : 230px (initial top property)
ending position X : 200px (initial left property + offsetxout)
ending position Y : 330px (initial left property + offsetyout)
With these options you can create complete axis-free slide transitions!
Please note, that fade is enabled by true so in the example above the layer will fade + slide at the same time. If you need the layer to slide only, you can use the fadein: false; fadeout: false; options. If you want the layer to fade only, you should use only the offsetxin: 0; offsetyin: 0; options (because fading is enabled and offsetyin / out are 0 by default).
If you want to start / end the transitions from / to outside of the slider, you can use the left / right values on the offsetxin / offsetxout, and top / bottom values on the offsetyin / offsetyout properties.