GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - SeregPie/VueResizeSensor: A Vue container that supports the resize event.

BranchesTags
Open more actions menu

Latest commit

 

History

21 Commits
21 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.eslintignore
.eslintignore
 
 
.eslintrc.json
.eslintrc.json
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package.json
package.json
 
 
rollup.config.js
rollup.config.js
 
 

Repository files navigation

VueResizeSensor

A Vue container that supports the resize event.

Works for Vue 2 & 3.

dependencies

  • Vue Demi

setup

npm

npm i @seregpie/vue-resize-sensor

import VueResizeSensor from '@seregpie/vue-resize-sensor';

browser

<!-- if using Vue 2 -->
<script src="https://unpkg.com/vue@2"></script>
<script src="https://unpkg.com/@vue/composition-api"></script>

<!-- if using Vue 3 -->
<script src="https://unpkg.com/vue@3"></script>

<script src="https://unpkg.com/vue-demi"></script>
<script src="https://unpkg.com/@seregpie/vue-resize-sensor"></script>

The component is globally available as VueResizeSensor.

usage

Register the component globally.

import {createApp} from 'vue';
import VueResizeSensor from '@seregpie/vue-resize-sensor';

let app = createApp({/*...*/});
app.component(VueResizeSensor.name, VueResizeSensor);
app.mount('body');

or

Register the component locally.

import VueResizeSensor from '@seregpie/vue-resize-sensor';

export default {
  components: {
    VueResizeSensor,
  },
  // ...
};

Wrap the content inside the default slot.

<vue-resize-sensor
  style="width: 100%; height: 100%"
  v-slot="{width, height}"
>
  <my-header v-if="height > 400"/>
  <div
    :style="{flexDirection: (width > height) ? 'row' : 'column'}"
    style="display: flex"
  >
    <my-first-item/>
    <my-second-item/>
  </div>
</vue-resize-sensor>

Capture the resize event.

<div>
  <vue-resize-sensor @resize="onResize"/>
  <my-content/>
</div>
methods: {
  onResize({width, height}) {
    // handle resize
  },
},

The component renders a <div> element by default. You can change the element that is rendered with the tag attribute.

<vue-resize-sensor tag="form"/>

About

A Vue container that supports the resize event.

Resources

Readme
MIT license
Activity

Stars

5 stars

Watchers

1 watching

Forks

0 forks
Report repository

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.