{"title":"Adding Overlay Layer","id":51958,"link":"https:\/\/env.averta.net\/en\/step\/adding-overlay-layer\/","parent":[51827],"content":"<p>Overlay layers let you add layer over the slider. These type of layers remain on top of all other slides and layers while user moves between slides. You can show or hide them by <a href=\"https:\/\/env.averta.net\/en\/step\/adding-layer-actions\/?b=51974,51974\" title=\"Adding Layer Actions\">Layer actions<\/a> or set each layer to appear only when specific slide(s) is selected. Additionally, overlay layers support a new type of animation that animates the layer to a new state, based on the selected slide.<\/p>\n<h2>Defining overlay layers<\/h2>\n<p>To define layers as overlay ones, you need to add them inside a container with <code>ms-overlay-layers<\/code> class name. This container should be added as the direct child of the slider element and it is recommended to add it before slides. The following example adds a text layer as an overlay layer to the slider.<\/p>\n<pre class=\"lang:xhtml decode:true \">\t&lt;div id=\"masterslider\" class=\"master-slider\"&gt;\r\n\t\t&lt;div class=\"ms-overlay-layers\"&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t\t&lt;div class=\"ms-layer\" data-type=\"text\"&gt;\r\n\t\t\t\tOverlay text layer content here...\r\n\t\t\t&lt;\/div&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;div class=\"ms-slide\"&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t\t&lt;div class=\"ms-layer\" data-type=\"text\"&gt;\r\n\t\t\t\tText layer content here...\r\n\t\t\t&lt;\/div&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;!-- .... --&gt;\r\n\t&lt;\/div&gt;<\/pre>\n<h2>Layer attributes<\/h2>\n<p>Overlay layers have some additional attributes to let you control them over the slider like showing or hiding them relative to the selected slide in the slider. Here you can find the list of these attributes:<\/p>\n<ul>\n<li><code>data-show-on<\/code> &#8211; The list of <strong><a href=\"https:\/\/env.averta.net\/en\/step\/adding-overlay-layer\/?b=,\" title=\"Adding Overlay Layer\">slide ids<\/a><\/strong> which the layer shows over them.<\/li>\n<li><code>data-hide-on<\/code> &#8211; The list of <strong><a href=\"https:\/\/env.averta.net\/en\/step\/adding-overlay-layer\/?b=,\" title=\"Adding Overlay Layer\">slide ids<\/a><\/strong> which the layer hides over them.<\/li>\n<\/ul>\n<p class=\"aswi-text-box box-note\"><strong>Note: <\/strong>Adding both <code>data-show-on<\/code> and <code>data-hide-on<\/code> attributes to one single layer is not recommended.[\/textlayer]\n<p>You can customize showing and hiding layer animations by <code>data-animation-in<\/code> and <code>data-animation-out<\/code> attributes. You can find detailed information about creating animations in <a href=\"https:\/\/env.averta.net\/en\/step\/defining-animation-for-the-layers\/?b=51959,51959\" title=\"Defining Animation for the Layers\">this article<\/a>.<\/p>\n<p>In the following example, the overlay layer only shows over second slide.<\/p>\n<pre class=\"lang:xhtml decode:true \">\t&lt;div id=\"masterslider\" class=\"master-slider\"&gt;\r\n\t\t&lt;div class=\"ms-overlay-layers\"&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t\t&lt;div class=\"ms-layer\" data-type=\"text\" data-show-on=\"slide-2\"&gt;\r\n\t\t\t\tOverlay text layer content here...\r\n\t\t\t&lt;\/div&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;div class=\"ms-slide\"&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t\t&lt;div class=\"ms-layer\" data-type=\"text\"&gt;\r\n\t\t\t\tText layer content here...\r\n\t\t\t&lt;\/div&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t&lt;\/div&gt;\t\t\r\n\t\t&lt;div class=\"ms-slide\" data-id=\"slide-2\"&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;!-- .... --&gt;\r\n\t&lt;\/div&gt;<\/pre>\n<h2>Animation<\/h2>\n<p>Overlay layer supports a different type of animating, you can set multiple animation relative to active slide&#8217;s number. For example, the layer can first appear over the first slide, then animates to a new state upon sliding to the second slide. To define these animations you need to add the slide relevant animation by the slide number as a data attribute to the layer element. For example,?<code>data-animation-slide-1<\/code> defines the initial animation over the first slide. The following example creates an overlay layer with two animation states over slide one and slide two.<\/p>\n<pre class=\"lang:xhtml decode:true \">\t&lt;div id=\"masterslider\" class=\"master-slider\"&gt;\r\n\t\t&lt;div class=\"ms-overlay-layers\"&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t\t&lt;div \r\n\t\t\t\tclass=\"ms-layer\" \r\n\t\t\t\tdata-type=\"text\"\r\n\t\t\t\tdata-animation-slide-1 = \"{ from:true; duration:2; opacity:0; x:-100 }\"\r\n\t\t\t\tdata-animation-slide-2 = \"{ duration:1.5; x:200 }\"\r\n\t\t\t&gt;\r\n\t\t\t\tOverlay text layer content here...\r\n\t\t\t&lt;\/div&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;div class=\"ms-slide\"&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t\t&lt;div class=\"ms-layer\" data-type=\"text\"&gt;\r\n\t\t\t\tText layer content here...\r\n\t\t\t&lt;\/div&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t&lt;\/div&gt;\t\t\r\n\t\t&lt;div class=\"ms-slide\" data-id=\"slide-2\"&gt;\r\n\t\t\t&lt;!-- .... --&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;!-- .... --&gt;\r\n\t&lt;\/div&gt;<\/pre>\n<p class=\"aswi-text-box box-recommend\"><strong>Recommended: <\/strong><\/p>It is recommended to set <code>from:true<\/code> for the first slide.<\/p>\n<p>Defining overlay layer animation is the same as layer animation in\/out. To find more information, check out <a href=\"https:\/\/env.averta.net\/en\/step\/defining-animation-for-the-layers\/?b=51959,51959\" title=\"Defining Animation for the Layers\">this article<\/a>.<\/p>\n","type":"solution"}