jQuery/JS Common - Utils - utils

An object that serves as a namespace for utility methods that can be helpful when working with DevExtreme components.

cancelAnimationFrame(requestID)

Cancels an animation frame request scheduled with the requestAnimationFrame method.

import { cancelAnimationFrame } from "devextreme/common/core/animation"
Parameters:
requestID:

Number

The identifier returned by requestAnimationFrame method.

This method acts as a normalization of the standard cancelAnimationFrame method of the window object.

JavaScript
  • window.cancelAnimationFrame ||
  • window.webkitCancelAnimationFrame ||
  • window.mozCancelAnimationFrame ||
  • window.oCancelAnimationFrame ||
  • window.msCancelAnimationFrame

If the API in the code above is not supported, the DevExpress.utils.cancelAnimationFrame(requestID) method clears a timer set with the requestAnimationFrame method.

getTimeZones(date, timeZones)

Gets a list of time zone objects from the IANA time zone database.

import { getTimeZones } from "devextreme/common/core/environment"
Parameters:
date:

Date

| undefined

A date for which to get time zone objects. Leave undefined to use the current date.

timeZones:

Array<String>

| undefined

A list of time zones to get time zone objects. Use an array of TZ identifiers from the IANA time zone database. If not passed, the method returns all available IANA time zone objects.

Return Value:

Array<SchedulerTimeZone>

A list of IANA time zone objects.

The getTimeZones method returns time zone data that is accurate for a specific date. Implement the method to get historical daylight savings data.

If you do not pass the timeZones parameter, the method returns the entire list of IANA time zone objects, which includes almost 600 time zones. To get a list of specific time zones, pass a string array to the timeZones property with TZ identifiers. For example, ["America/Los_Angeles"] returns data for the Los Angeles time zone.

The following code illustrates how to use this method:

index.js
  • const timeZonesToday = DevExpress.utils.getTimeZones();
  • // An array of all 593 time zones on the IANA time zone database
  • const timeZonesSpecific = DevExpress.utils.getTimeZones(new Date(2025, 1, 1), ["America/Los_Angeles"]);
  • // [ {id: 'America/Los_Angeles', title: '(GMT -08:00) America - Los Angeles', offset: -8} ]
  • // ===== or when using modules =====
  • import { getTimeZones } from "devextreme/common/core/environment";
  • const timeZonesToday = getTimeZones();
  • const timeZonesSpecific = getTimeZones(new Date(2025, 1, 1), ["America/Los_Angeles"]);

View Demo

initMobileViewport(options)

Sets parameters for the viewport meta tag. Takes effect for mobile applications only.

import { initMobileViewport } from "devextreme/common/core/environment"
Parameters:
options:

Object

Gesture configuration for a mobile browser's viewport.

Object structure:
Name Type Description
allowPan

Boolean

Specifies whether to enable panning on the vertical and horizontal axes.

allowSelection

Boolean

Specifies whether to enable selection.

allowZoom

Boolean

Specifies whether to enable pinch-zooming.

requestAnimationFrame(callback)

Makes the browser call a function to update animation before the next repaint.

import { requestAnimationFrame } from "devextreme/common/core/animation"
Parameters:
callback:

Function

The function.

Return Value:

Number

The current request's ID.

This method acts as a normalization of the standard requestAnimationFrame method of the window object:

JavaScript
  • window.requestAnimationFrame ||
  • window.webkitRequestAnimationFrame ||
  • window.mozRequestAnimationFrame ||
  • window.oRequestAnimationFrame ||
  • window.msRequestAnimationFrame

If the API in the code above is not supported, the DevExpress.utils.requestAnimationFrame(callback) method calls the function passed as a parameter after an internally set timeout.