Note
Note: To learn more about this format, preview a demo, or to see build guides for other authoring tools, see About scroll reveal.
When creating a scroll reveal in a code editor, it is recommended that you start with our official template bundle.
Files within the bundle:
README.txt
Amz_ScrollReveal_1_0_1.zip
Amz_ScrollReveal_1_0_1_DCO.zip
Amz_Scroll_Reveal_1_0_1_DCO_Video.zip
Amz_Scroll_Reveal_1_0_1_Video.zip
You can also customize the dimensions according to your requirements. Everything can be personalized, including media controls of the video.
The following table describes the list of files that are included in the downloadable template.
After you finish creating your ad, proceed to setting up your ad in AAS. For more information, see Set up a scroll reveal.
If you are planning to upload multiple ads, make sure that the Ad Creation Wizard in AAS recognizes your workspace as a scroll reveal. Verify that the config.js
file contains the following JavaScript:
define({ "adFormatId": 10324 });
For more information about uploading ads in bulk, see Set up multiple ads using Ad Creation Wizard.
If you are developing ads with third-party libraries, we recommend that you call these libraries from a CDN (Content Delivery Network) when possible. This will help improve loading time and caching.
If you need to add Dynamic Creative Optimization (DCO) elements to your creative, see Add dynamic elements to your HTML ads using a code editor.
The Manifest Configuration file, (config.js
) located in the root folder of the workspace, is a metadata file that defines certain default behaviors for the ad. The following table describes the main configuration variables to customize this file.
Variable Name |
Type |
Description |
Default Value |
---|---|---|---|
Auto Snap Type ( |
Integer |
|
3 |
Bottom Bar Color ( |
String |
Any HTML color name or HTML hex color code. |
white |
Bottom Bar Height ( |
Integer |
Height of the bottom text bar in pixels. |
20 |
Bottom Bar Label ( |
String |
Text in the bottom text bar. |
SCROLL TO CONTINUE WITH CONTENT |
Bottom Bar Label Style ( |
String |
CSS style for bottom text bar. |
color:grey; font-size:10px; font-family:arial; text-align:center; |
Collapse After Scroll Away ( |
Boolean |
Determines if ad should be collapsed when scroll away or snap away. |
No |
Display Bottom Bar ( |
Boolean |
Determines if ad should display bottom text bar. |
No |
Display Top Bar ( |
Boolean |
Determines if ad should display top text bar. |
No |
Percentage For Snap In ( |
Integer |
Percentage of the browser height, which the ad must exceed, for the snap in when user scrolls the ad in. |
50 |
Percentage For Snap Out ( |
Integer |
Percentage of the browser height, which the ad must exceed, for the snap out when user scroll the ad away. |
75 |
Top Bar Color ( |
String |
Any HTML color name or HTML hex color code. |
white |
Top Bar Height ( |
Integer |
Height of the top text bar in pixels. |
20 |
Top Bar Label ( |
String |
Text in the top text bar. |
ADVERTISEMENT |
Top Bar Style ( |
String |
CSS style for top text bar. |
color:white; font-size:10px; font-family:arial; text-align:center; |
Top Bounding Selector ( |
String |
HTML selector for the object to which the ad should snap on the top. For example, a publisher site has a Header or Top Menu that the scroll reveal should not cover. Use this custom variable to declare the Header or Top menu element. If the Header is a |
null |
To change the panel elements and HTML structure, open the following files with your code editor and modify the ad structure, aspect, and behavior.
-
panels/expand/index.html
-
panels/script/script.js
-
panels/css/style.css
These JavaScropt variables, located in template files, are related to elements in the HTML.
Variable Name |
Location |
Description |
---|---|---|
|
|
Global variables that define the HTML objects. |
|
|
Global variables that define widgets. (Video template only) |
|
|
These variables store values that are necessary for the ad to run properly after the upload to AAS. ImportantImportant: Do not make changes to these variables. |
Function Name |
Description |
---|---|
|
Initializes the creative. You can add your own script if you want to run a script when the creative is initialized. |
|
Initializes the global variables for HTML objects. In the template, |
|
Initializes the video based on the serving environment and custom variable. Determines how to serve the video object and add video tracking to the video module when possible. |
|
Adds all of the event listeners. In the template, the click event for the click-through and user action counter was added. In addition, the |
|
Invoked to close the panel, and enable the page scrolling before the ad is collapsed. This function also pauses the video. |
|
Click handler for the click-through button. Calls this function for the default click-through. This function also pauses the video. |
|
Handles the browser resize event. In the template, it calls |
|
Handles the event when a video enters full screen mode. |
|
Handles the event when a video exits full screen mode. |
|
Handles the event when a video change its state regarding full screen mode. Code handles the issue of the HTML elements positioning when exiting a full screen video player. |
|
Handles the event when a user presses a key on the keyboard. |
|
Handles the event when a user scrolls the page using the mouse wheel. |
|
Handles touch start event for mobile devices. |
|
Handles touch end event for mobile devices. |
|
Handles the event when a user clicks snap to full screen button. |
|
Handles the event when a user clicks exit full screen button. |
|
Triggered when a user starts to scroll ad into view port. |
|
Triggered when a user starts to scroll ad away from view port. |
|
Triggered after ad snapped in. |
|
Triggered after ad snapped out. |
|
Triggered when a user scrolls the page. |
|
Pauses the video. This function also includes an option to rewind the video to the starting point by adding the parameter in the function call.
|
|
Triggered when ad is collapsed. |
|
Repositions the ad elements. |
scroll reveal supports widgets that will be generated on the placement level when an ad loads. The ad creator can add widgets from the creative level using the Widget function. The following syntax shows how to create a widget.
var [variable_name] = new Widget([widget_properties]);
Example:
logo = new Widget({ name: "logo", top: "10px", left: "10px", width: "118px", height: "53px", asset: "panels/expand/images/logo_white.svg" });
Property Name |
Type |
Required |
Description |
---|---|---|---|
name |
String |
Required |
Property name. |
width |
String |
Required |
Widget width in pixels. |
height |
String |
Required |
Widget height in pixels. |
top |
String |
Required |
Widget position, in pixels, from the top edge of the ad in pixels. |
left |
String |
Required |
Widget position, in pixels, from the left edge of the ad in pixels. |
bottom |
String |
Required |
Widget position, in pixels, from the bottom edge of the ad in pixels. |
right |
String |
Required |
Widget position, in pixels, from the right edge of the ad in pixels. |
html |
String |
Required |
HTML code for the widget content. |
asset |
String |
Required |
Asset from the Workspace root that acts as widget background. |
hover |
String |
Optional |
Asset from Workspace root; will act as a widget background when mousing over the widget. |
css |
String |
Optional |
Widget styles. |
callback |
String |
Optional |
Adds the function to call when widget is clicked. When an action/callback is added to the widget, it automatically switches the mouse cursor to a pointer, indicating clickable. |
inapp |
Boolean |
Optional |
Determines if the widget renders when ad is served In-app. Default is true. |
effects |
Array |
Optional |
Array of effect objects of the widget. |
A widget can be animated when a user scrolls the page or when an ad is resized. The developer can use a widget effects property to set rules for how to animate the widget.
Example:
effects: [ { on: "scroll", changeProperty: "left", changeFrom: "-20%", changeTo: "90%" } ]
Effect Property Name |
Type |
Required |
Description |
---|---|---|---|
on |
String |
Required |
Determines when effect should happen. Available options include: |
scrollFrom |
Integer |
Optional |
Percentage of the scrolling when the effect starts. Default is 0. Only valid when on is set to scroll. |
scrollTo |
Integer |
Optional |
Percentage of the scrolling when effect ends. Default is 100. Only valid when on is set to scroll. |
changeProperty |
String |
Required |
CSS property to be changed. |
changeFrom |
String |
Optional |
Value of CSS property when change started, in pixels or %. Will use changeTo value if changeFrom is not specified. |
changeTo |
String |
Required |
Value of CSS property when change ended. |
minChangeTo |
String |
Optional |
Minimum changeTo value in pixels. |
maxChangeTo |
String |
Optional |
Maximum changeTo value in pixels. |
width |
String |
Optional |
Determines what to use for the width if changeproperty set to height. |
height |
String |
Optional |
Determines what to use for the width if changeproperty set to width. |
animation |
Object |
Optional |
Overrides the animation properties. By default, the animation easing type is ease-out and animation duration is 1.25 second. The developer can use the following code to override the default properties: animation: { duration: 0.5, easing: "ease-in-out" } Animation property takes standard CSS transition properties. |
Method Name |
Description |
---|---|
show |
Show widget. Example: |
hide |
Hide widget. Example: |
remove |
Remove widget. Example: |
resizeTo |
Resize widget. Example: |
moveTo |
Move widget. Example: |
Click here to preview a demo of scroll reveal format.
Comments