Important

You are browsing the documentation for version 4.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Viewport Manager

Viewport manager contains a collection of available screen types that can be used on the theme. It is also responsible for triggering event viewport:change through the mediator, when the type of the screen changes. It is possible to subscribe to event viewport:change in view and create a logic based on the viewport changes (for example, DOM Relocation View).

Screen Map

By default these settings for list of screen types synchronized with scss breakpoints.

 1 // Desktop Media Breakpoint
 2 $breakpoint-desktop: 1100px;
 3
 4 // iPad mini 4 (768*1024), iPad Air 2 (768*1024), iPad Pro (1024*1366)
 5 $breakpoint-tablet: $breakpoint-desktop - 1px;
 6 $breakpoint-tablet-small: 992px;
 7
 8 // iPhone 4s (320*480), iPhone 5s (320*568), iPhone 6s (375*667), iPhone 6s Plus (414*763)
 9 $breakpoint-mobile-big: 767px;
10 $breakpoint-mobile-landscape: 640px;
11 $breakpoint-mobile: 414px;
12 $breakpoint-mobile-small: 360px;
13
14 $oro_breakpoints: (
15     'desktop': '(min-width: ' + $breakpoint-desktop + ')',
16     'tablet': '(max-width: ' +  $breakpoint-tablet + ')',
17     'strict-tablet': '(max-width: ' +  $breakpoint-tablet + ') and (min-width: ' + ($breakpoint-tablet-small + 1) + ')',
18     'tablet-small': '(max-width: ' +  $breakpoint-tablet-small + ')',
19     'strict-tablet-small': '(max-width: ' +  $breakpoint-tablet-small + ') and (min-width: ' + ($breakpoint-mobile-landscape + 1) + ')',
20     'mobile-landscape': 'screen and (max-width: ' +  $breakpoint-mobile-landscape + ')',
21     'strict-mobile-landscape': '(max-width: ' +  $breakpoint-mobile-landscape + ') and (min-width: ' + ($breakpoint-mobile + 1) + ')',
22     'mobile': '(max-width: ' + $breakpoint-mobile + ')',
23     'mobile-big': '(max-width: ' +  $breakpoint-mobile-big + ')',
24 );

Default scss breakpoints are converted to the following array:

 1 screenMap: [
 2     {
 3         name: 'desktop',
 4         min: 1100
 5     },
 6     {
 7         name: 'tablet',
 8         max: 1099
 9     },
10     {
11         name: 'strict-tablet',
12         max: 1099,
13         min: 993
14     },
15     {
16         name: 'tablet-small',
17         max: 992
18     },
19     {
20         name: 'strict-tablet-small',
21         max: 992,
22         min: 641
23     },
24     {
25         name: 'mobile-big',
26         max: 767
27     },
28     {
29         name: 'strict-mobile-big',
30         max: 767,
31         min: 641,
32     },
33     {
34         name: 'mobile-landscape',
35         max: 640
36     },
37     {
38         name: 'strict-mobile-landscape',
39         max: 640,
40         min: 415
41     },
42     {
43         name: 'mobile',
44         max: 414
45     },
46     {
47         name: 'mobile-small',
48         max: 360
49     }
50 ]

You can override these breakpoints via scss variables.

Overriding via js Module Config for a Theme

This config has the highest priority:

{% import '@OroAsset/Asset.html.twig' as Asset %}
{{ Asset.js_modules_config({
        'oroui/js/viewport-manager': {
            screenMap: [
                {
                    name: 'tablet',
                    max: 640
                },
                {
                    name: 'desktop',
                    max: 1260
                },
                {
                    name: 'desktop-hd',
                    max: 1920
                }
            ]
        }
}); }}

To delete an inherited screen type, set skip: true for a specific screen name:

{% import '@OroAsset/Asset.html.twig' as Asset %}
{{ Asset.js_modules_config({
        'oroui/js/viewport-manager': {
            screenMap: [
                {
                    name: 'tablet',
                    skip: true
                },
                {
                    name: 'desktop',
                    max: 1260
                }
            ]
        }
    }
}); }}

Screen Types

A screen type is used to describe a viewport size range; it provides an opportunity to describe the parameters like name, max size of the screen type.

For example:

1 {
2     name: 'screen-type',
3     max: 1024
4 }

name

Type: String

Set name for screen type.

max

Type: Number

Set max viewport size for screen type

min

Type: Number

Set min viewport size for screen type

Events

viewport:change

Event Data: Object

Data Structure:

  • type: Object

Current viewport screen type.

  • width: Number

Current viewport width.