Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-smooth-height

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-smooth-height

Transition a container elements height in response to data changes

  • 1.1.5
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Vue Smooth Height

A Vue mixin that answers the question, "How do I transition height auto?"

Use this mixin on container elements that have a dynamic number of children. When the container's children rerender, the container's height will transition, instead of instantly resizing.

Note that this library has no overlap with Vue's built in transition components.

Demo

https://jsfiddle.net/axfwg1L0/5/

Installation

Using npm:

$ npm install vue-smooth-height

In a browser:

<script src="vue-smooth-height.min.js"></script>

Usage

Module:

import smoothHeight from 'vue-smooth-height';

<template>

<div>
    <div class="container" ref="container">
        <!-- children created with v-for -->
    </div>
</div>

</template>

<script>
export default {
    mixins:[smoothHeight],
    mounted(){
        //use nextTick if necessary
        this.$registerElement({
            el: this.$refs.container,
        })
    },
}
</script>

Browser:

Same as above, use the global SmoothHeight

CSS

This mixin relies on css transitions, meaning you can define whatever css transitions you want for the element. If the mixin does not detect any transitions, it will apply transition: 1s to the element.

API

$registerElement(options)

options: Object | Array

Can be a single options object, or an array of options objects.

Enables smooth height transition on an element.

OptionTypesDefaultDescription
elElement,StringnullRequired. A reference to the element, or a selector string. Use a selector string if the container element is not rendered initially. If selector string is a class, the first query match will be registered
hideOverflowBooleanfalseIf the element has a scrollbar, ugly reflow flickers can occur when children create/destroy a new row (think flexbox). Set true to disable overflow during the transition.

$unregisterElement(options)

options: Object | Array

Can be a single options object, or an array of options objects.

Disables smooth height behavior on an element. Registered elements that have the same el as the passed in options will be unregistered.

Example:


mounted(){
    this.$registerElement({
        el: this.$refs.container,
    })
    this.$unregisterElement({
        el: '.container',
    })
},

Keywords

FAQs

Package last updated on 27 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc