目录

Window

has.onWindowResize

has.onWindowResize(function callback)

Listens for window size change events.

Since: 1.0.14

Parameters

Name

Type

Mandatory

Description

callback

function

Yes

Callback for window size change events.

Return value of callback

An object containing the following window size information fields.

Name

Type

Description

size

Object

Window size.

Fields in size

Name

Type

Description

windowWidth

number

Updated window width, in pixels.

windowHeight

number

Updated window height, in pixels.

Example

has.onWindowResize((res) => {
  console.log('onWindowResize res = ', JSON.stringify(res));
});

has.offWindowResize

has.offWindowResize(function listener)

Removes the listener for window size change events.

Since: 1.0.14

Parameters

Name

Type

Mandatory

Description

callback

function

No

Callback passed by onWindowResize. If this parameter is not passed, all listener functions will be removed.

Example

const callback = (res) => {
  console.log('onWindowResize res = ', JSON.stringify(res));
};
has.onWindowResize(callback);
has.offWindowResize(callback);