---
name: "offWindowResize"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.6.0" }
title: "ty.offWindowResize - Supported from base library 2.6.0, compatibility handling required for earlier versions"
---

## offWindowResize

> [VERSION] Base Library >= 2.6.0

### Description

Stop listening for window resize events

### Parameters

`(callback: Function)`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `callback` | `(res: OnWindowResizeCallbackResult) => void` | Yes | Callback for window resize events |

### Return Value

None


### Referenced Types

##### `interface` OnWindowResizeCallbackResult

| Property | Type | Description |
| --- | --- | --- |
| `type` | `"portrait" \| "landscape"` | Change type |
| `size` | `OnWindowResizeCallbackResultSize` | Updated window size |

##### `interface` OnWindowResizeCallbackResultSize

| Property | Type | Description |
| --- | --- | --- |
| `windowWidth` | `number` | Screen width in px |
| `windowHeight` | `number` | Screen height in px |


### Examples

#### Stop listening for window size changes

```js
Page({
  data: {
    handler: null,
  },
  onLoad() {
    this.data.handler = (res) => {
      console.log('Window size changed', res.size.windowWidth);
    };
    ty.onWindowResize(this.data.handler);
  },
  onUnload() {
    ty.offWindowResize(this.data.handler);
  },
});
```
