目录

Window

has.onWindowResize

has.onWindowResize(function callback)

Listens for window size change events.

Since: 1.0.14

Parameters

Parameter Type Mandatory Description
callback function Yes Listener function for window size change events.

Return value of callback

An object containing the following window size information fields.

Parameter Type Description
size Object Window size.

Fields in size

Parameter Type Description
windowWidth number Updated window width, in pixels.
windowHeight number Updated window height, in pixels.

Example:

has.onWindowResize((res) => {
  console.info('onWindowResize', res);
});

has.offWindowResize

has.offWindowResize(function callback)

Removes the listener for window size change events.

Since: 1.0.14

Parameters

Parameter Type Mandatory Description
callback function No Listener function passed by onWindowResize. If this parameter is not passed, all listener functions will be removed.

Example:

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