Horizontal Parallax

Horizontal Parallax

Asset Version: 1.0.0
  • Version 1.0.0
Last Published: Apr 11, 2017 By: Kony Team
102 0 0 18
Parallax scrolling uses multiple objects at different speeds to give the impression of a 3d effect where nearby objects have a larger parallax than more distant objects when observed from different positions. If you're looking for a popular scrolling effect used by native mobile apps and amazing websites, download the horizontal parallax.

Requirements

  • Visualizer Enterprise
 

Devices

 

Platforms

Features

  • Parallax scrolling effect in horizontal manner
  • Ability to animate background and foreground at different speeds
  • Facility to customize the UI elements.

Platforms Supported

  • Android Phone Native
  • iPhone Native

Prerequisites

  • Kony account
  • Kony Visualizer Enterprise
  • A Kony Reference Architecture app created in Kony Visualizer

The Horizontal Parallax Animation component is a three-flex animated UI with background images and a foreground flex. The component helps you create a parallax animation effect in an application that enhances the user experience.

Here is a use case that describes the use of the Horizontal Parallax Animation component.

Use Case

Consider a case that you are developing an app that provides information about heritage sites. You can use the Horizontal Parallax Animation component in the app and configure the component in such a manner that the app displays the images of a heritage site in the background and related information in the foreground.

The Horizontal Parallax Animation component is a ready-to-use component. You can import the Horizontal Parallax Animation component into your app (created in Kony Visualizer) and achieve the features of parallax animation in horizontal manner. The Horizontal Parallax Animation component also facilitates a set of properties that helps you customize the background images and the foreground as you require.

The following sections help you use the Horizontal Parallax Animation component in your app:

Prerequisites

Before you start using the Horizontal Parallax Animation component, ensure you have the following:

  1. Kony account
  2. Kony Visualizer Enterprise 7.3
  3. A Kony Reference Architecture app in Visualizer. You can create a Kony Reference Architecture app in Visualizer using the following procedure:
    1. Open Kony Visualizer.
    2. On the File Menu, click New Project. The New Project dialog appears.
    3. In the Project Name box, type a name for your project.
    4. Select Kony Reference Architecture, and click Create.

Importing the Horizontal Parallax Animation Component

Before you start importing the component to Kony Visualizer, you must download the component from the Kony Marketplace website. You can import the marketplace components only into the apps that are of the Kony Reference Architecture type.

To import the Horizontal Parallax Animation component, do the following:

  1. Open your app project in Kony Visualizer.
  2. On the File menu, point to Import, and click Component. The Open dialog appears.
  3. Navigate to the location where you downloaded the component (zip file) on your computer, select the component, and click Open. The Import Marketplace Item dialog appears.
    parallaxh_import.png
  4. In the Library Name box, type a name if you want to create a new library. Otherwise, you can select the existing library name.
  5. In the Collection Name box, type a name if you want to create a new collection. Otherwise, you can select the existing collection name.
  6. In the Component Name box, the com.konymp.horizontalparallax name is displayed by default. If you want, you can rename it.

When you import a component, the component is imported to Visualizer's workspace, but not directly into your app. Thus, after you import a component, you must add the component to your app.

Adding a Horizontal Parallax Animation Component into your App

You can add a Horizontal Parallax Animation component to the FlexForms, FlexContainer, and FlexScrollContainer widgets.

To add a Horizontal Parallax Animation component:

  1. Open your app, and then open the form to which you want to add the component.
  2. From the Collections tab, drag the component onto the form on the Visualizer canvas. The component is added to the form. You can also see a new element, com.konymp.horizontalparallax in the Components section on the Templates tab.

After adding a component to a form, you can configure the component the way you want it using the Look, Skin, and Action tabs on the Properties pane. Configuring the properties on the Properties pane is similar to configuring the properties of any widget in Kony Visualizer. For more information, refer Button Widget.

You can also see that a new tab, Component, is added on the Properties pane. The Component tab contains assorted properties relevant to the component that allow you to customize the component as required. The properties on the Component tab are categorized as Pass Through and Custom properties. The Pass Through properties are the default properties of individual widgets in the component. The Custom properties are user-defined properties based on the use case of the component.

Note:

Changes made to the Custom properties are reflected only at the run time, but not at the design time (Visualizer Canvas).

You can also add a Horizontal Parallax Animation Component dynamically. To do so,

  1. In the Project Explorer, on the Projects tab, click the context menu arrow of Modules, and then click New JS module. A new JavaScript file opens in the Code Editor.
  2. Copy and paste the following code snippet in the JavaScript file.
    /* creating a component's Object */
    var component = new com.konymp.horizontalparallax({
    	"id":"horpar",
      	"top":"0%",
      	"width":"100%",
      	"height":"100%",
      	"left":"0%"
    	},{},{});
          component.foregroundTop="20%";
          component.foregroundLeft="0%";
          component.isPagingEnabled=true;
          component.foregroundWidth="100%";
          component.foregroundHeight="30%";
          component.bgImageTwoSrc="imagedrag.png";
          component.bgImageOneSrc="imagedrag.png";
          component.bgImageThreeSrc="imagedrag.png";
          this.view.add(component);       
    

    In the code snippet, you can edit the properties of the component as per your requirement. For more information, see Properties.

  3. Save the file.

Setting Properties

The properties provided on the Component tab allow you to customize the UI elements in the Horizontal Parallax Animation component. You can set the properties directly on the Component tab or by writing a JavaScript. This section provides information about how to set the properties by writing a JavaScript.

Background Image One Source
Category Pass Through
Description: Specifies the file name of the image to be set as the background for the first page.
Syntax: bgImageOneSrc
Type: String
Read/Write: Read + Write
Remarks Before setting the property, do the following:
  • Ensure that the image file exists in the workspace\resources\common directory.
  • Do not add any uppercase characters in the file name of the image.
  • Ensure that the image is in PNG format.
  • Specify the file name of the image along with the extension.
Example:
this.view.Component_Name.bgImageOneSrc = “imagedrag.png”;
Background Image Two Source
Category: Pass Through
Description: Specifies the file name of the image to be set as the background for the second page.
Syntax: bgImageTwoSrc
Type: String
Read/Write: Read + Write
Remarks Before setting the property, do the following:
  • Ensure that the image file exists in the workspace\resources\common directory.
  • Do not add any uppercase characters in the file name of the image.
  • Ensure that the image is in PNG format.
  • Specify the file name of the image along with the extension.
Example:
this.view.Component_Name.bgImageTwoSrc = “imagedrag.png”;
Background Image Three Source
Category: Pass Through
Description: Specifies the file name of the image to be set as the background for the third page.
Syntax: bgImageThreeSrc
Type: String
Read/Write: Read + Write
Remarks Before setting the property, do the following:
  • Ensure that the image file exists in the workspace\resources\common directory.
  • Do not add any uppercase characters in the file name of the image.
  • Ensure that the image is in PNG format.
  • Specify the file name of the image along with the extension.
Example:
this.view.Component_Name.bgImageThreeSrc = “imagedrag.png”;
Paging
Category: Pass Through
Description: Controls whether or not to enable the paging of the scroll container.
Syntax: isPagingEnabled
Type: Boolean
Read/Write: Read + Write
Remarks: If the property is set to true, the scroll view stops on multiples of the scroll view's bounds when the user scrolls.
Example:
this.view.Component_Name.isPagingEnabled = true;
Foreground Top
Category: Pass Through
Description: Determines the top edge of the foreground flex. You can specify the value in Dp, Px, or percentage. The top edge is measured from the top of the background image.
Syntax: foregroundTop
Type: String
Read/Write: Read + Write
Remarks: The default value of the property is “0%”
Example:
this.view.Component_Name.foregroundTop = “0%”;
Foreground Left
Category: Pass Through
Description: Determines the left edge of the foreground flex. You can specify the value in Dp, Px, or percentage. The lower left edge is measured from the left of the background image.
Syntax: foregroundLeft
Type: String
Read/Write: Read + Write
Remarks: The default value of the property is “0%”
Example:
this.view.Component_Name.foregroundLeft = “0%”;
Foreground Width
Category: Pass Through
Description: Specifies the width of the foreground flex. You can specify the value in Dp, Px, or percentage. The width is measured along the x-axis.
Syntax: foregroundWidth
Type: String
Read/Write: Read + Write
Remarks:
Example:
this.view.Component_Name.foregroundWidth = “100%”;
Foreground Height
Category: Pass Through
Description: Specifies the height of the foreground flex. The height is measured along the y-axis.
Syntax: foregroundHeight
Type: String
Read/Write: Read + Write
Remarks:
Example:
this.view.Component_Name.foregroundHeight = “50%”;