2.0.0 • Published 1 year ago

vue-window-size v2.0.0

Weekly downloads
2,994
License
MIT
Repository
-
Last release
1 year ago

vue-window-size

npm version License: MIT CI Status

Provides reactivity window size properties for Vue.js.

Install

$ yarn add vue-window-size

Usage

Plugin or Mixin.

Plugin all components have window sizes.

Components with mixin have window sizes. Other components don't have window sizes.

Plugin

Install plugin

import Vue from 'vue';
import VueWindowSize from 'vue-window-size';

Vue.use(VueWindowSize);

Use with component

<template>
  <div>
    <p>window width: {{ windowWidth }}</p>
    <p>window height: {{ windowHeight }}</p>
  </div>
</template>

Mixin

Use with component

<template>
  <div>
    <p>window width: {{ windowWidth }}</p>
    <p>window height: {{ windowHeight }}</p>
  </div>
</template>

<script>
import { vueWindowSizeMixin } from 'vue-window-size';

export default {
  mixins: [vueWindowSizeMixin],
};
</script>

Options

delay (option)

  • type: Number
  • default: 50

Change delay time of resize event.

e.g.

import Vue from 'vue';
import VueWindowSize from 'vue-window-size';

Vue.use(VueWindowSize, {
  delay: 100,
});

Public API

setDelay(delay: number)

Same as delay option.

import { vueWindowSize } from 'vue-window-size';

vueWindowSize.setDelay(1000);

init()

Initialize the plugin. Usually called automatically. Please call it if you want to use it again after destroy.

import { vueWindowSize } from 'vue-window-size';

vueWindowSize.init();

destroy()

Remove the resize event.

import { vueWindowSize } from 'vue-window-size';

vueWindowSize.destroy();

FAQ

When is removeEventListener called?

This library add addEventListener only once, even if it is used in mixin. So basically you do not need to call removeEventListener. If you want to call removeEventListener please call destroy method.

Contribution

If you find a bug or want to contribute to the code or documentation, you can help by submitting an issue or a pull request.

License

MIT

2.0.0-next

1 year ago

2.0.0

1 year ago

2.0.0-beta.8

1 year ago

2.0.0-beta.7

1 year ago

2.0.0-beta.2

1 year ago

2.0.0-beta.1

1 year ago

2.0.0-beta.0

1 year ago

2.0.0-beta.6

1 year ago

2.0.0-beta.5

1 year ago

2.0.0-beta.4

1 year ago

2.0.0-beta.3

1 year ago

1.2.0

1 year ago

1.2.1

1 year ago

1.2.1-next

1 year ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.4

3 years ago

1.0.4-0

3 years ago

1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0-6

4 years ago

1.0.0-5

4 years ago

0.6.2

4 years ago

1.0.0-4

4 years ago

1.0.0-3

4 years ago

1.0.0-2

4 years ago

1.0.0-1

4 years ago

1.0.0-0

4 years ago

0.6.1-0

4 years ago

0.6.1

4 years ago

0.5.1-0

4 years ago

0.6.0-1

4 years ago

0.6.0-0

4 years ago

0.6.0

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.5.0-0

4 years ago

0.4.0-0

4 years ago

0.4.0

4 years ago

0.3.0-3

4 years ago

0.3.0-2

4 years ago

0.3.0

4 years ago

0.3.0-1

4 years ago

0.3.0-0

4 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago