All Projects → phegman → V Show Slide

phegman / V Show Slide

Licence: gpl-3.0
A Vue.js directive for animating an element from height: auto; to height: 0px; and vice-versa.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to V Show Slide

Vue Standalone Component
Vuejs template to build components with livecoding, tests, documentation and demos
Stars: ✭ 75 (-16.67%)
Mutual labels:  vuejs2
Paascloud Master
spring cloud + vue + oAuth2.0全家桶实战,前后端分离模拟商城,完整的购物流程、后端运营平台,可以实现快速搭建企业级微服务项目。支持微信登录等三方登录。
Stars: ✭ 9,194 (+10115.56%)
Mutual labels:  vuejs2
Mydailylearn
🚀 Important commands, Code Snippets, Basics on different topics learning daily 🎉!
Stars: ✭ 87 (-3.33%)
Mutual labels:  vuejs2
Vue2 Multi Uploader
Drag and drop multiple file uploader with Vue.js v2 and Axios
Stars: ✭ 77 (-14.44%)
Mutual labels:  vuejs2
Phoenix Vue Demo
Basic app developed with Phoenix and Vue 2.0, including authentication.
Stars: ✭ 80 (-11.11%)
Mutual labels:  vuejs2
Vue Nuggets
E-commerce UI Nuggets based on Vue
Stars: ✭ 84 (-6.67%)
Mutual labels:  vuejs2
Vue Flask
Quick web Dasboard / REST API with Prometheus exporter
Stars: ✭ 73 (-18.89%)
Mutual labels:  vuejs2
Nextcloud Vue
🍱 Vue.js components for Nextcloud app development ✌
Stars: ✭ 89 (-1.11%)
Mutual labels:  vuejs2
Express Vue
Vue rendering engine for Express.js. Use .Vue files as templates using streams
Stars: ✭ 1,226 (+1262.22%)
Mutual labels:  vuejs2
Vuex Simple Structure
📈 A repository showcasing a simple Vuex store inside a Vue.js application based on Large-scale Vuex application structures @3yourmind
Stars: ✭ 87 (-3.33%)
Mutual labels:  vuejs2
Vue Cytoscape
cytoscape.js now inside vue.js
Stars: ✭ 78 (-13.33%)
Mutual labels:  vuejs2
Vue Cloudfront
vue-cloudfront - PWA for cloud storage with focus on design and performance. Made especially for self-hosting purposes. Build with vuejs2 and vuex. Always Open Source, MIT license.
Stars: ✭ 80 (-11.11%)
Mutual labels:  vuejs2
Sequelize Bookmarks
Sequelize ORM application with Express 4 server, Webpack and Vue.js
Stars: ✭ 85 (-5.56%)
Mutual labels:  vuejs2
Vue Scroll Progress Bar
Vue.js plugin for page scroll progress bar
Stars: ✭ 76 (-15.56%)
Mutual labels:  vuejs2
Xcui
🍴 A Vue.js 2.x desktop components colletion
Stars: ✭ 88 (-2.22%)
Mutual labels:  vuejs2
Developmint.de
Open source company page built with Nuxt.js and TailwindCSS
Stars: ✭ 74 (-17.78%)
Mutual labels:  vuejs2
Bottle Vue Kickstart
🍕 Very basic Bottle kickstart kit with Vue.js and Webpack. Included Axios, Autoprefixer, Babel, Webpack config, demo app with Bulma and Web font loader.
Stars: ✭ 83 (-7.78%)
Mutual labels:  vuejs2
Snapaper
📰 Past Papers Sharing Platform Based On Vue.js & GCE Guide | CAIE 试卷分享与下载平台
Stars: ✭ 90 (+0%)
Mutual labels:  vuejs2
Vue Memo
Using Vue.js for memo web App. webpack, vuex, vue-router, Firebase.
Stars: ✭ 88 (-2.22%)
Mutual labels:  vuejs2
D3vue
A D3 Plugin for VueJS
Stars: ✭ 87 (-3.33%)
Mutual labels:  vuejs2

Travis

v-show-slide

A Vue.js directive for animating an element from height: auto to height: 0px and vice-versa.

  • 👻 3kb (1kb gzipped)
  • 📦 No dependencies
  • 🌚 TypeScript support
  • Uses CSS transitions
  • 🕺 Support for custom easings

Table of Contents

Overview

There is no pure CSS way to animate an element to or from height: auto, this Vue.js directive solves this. It works the same way as v-show but will show the element with a sliding animation.

Demo

Demo can be viewed here: http://v-show-slide.peterhegman.com/
Source code for demo can be viewed in src/Demo.vue

Installation

Yarn

yarn add v-show-slide

NPM

npm install v-show-slide --save

Install the Vue plugin

In your main JS file first import this plugin

import VShowSlide from 'v-show-slide'

Install the plugin

Vue.use(VShowSlide)

Usage

Once the plugin is installed the v-show-slide directive can be used in any of your components. This directive works the same way as v-show. If the value is true the element will slide open, if the value is false the element will slide closed.

Example:

<template>
  <div id="app" class="app">
    <ul id="features" v-show-slide="featuresOpen" class="features">
      <li>Aliquam lorem</li>
      <li>Praesent porttitor nulla vitae posuere</li>
      <li>Suspendisse nisl elit rhoncus</li>
      <li>Donec mi odio faucibus</li>
      <li>Curabitur suscipit suscipit</li>
    </ul>
    <button
      @click="toggleFeatures"
      class="toggle-features"
      aria-controls="features"
      :aria-expanded="featuresOpen ? 'true' : 'false'"
    >
      {{ featuresOpen ? 'Hide Features' : 'View Features' }}
    </button>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      featuresOpen: false,
    }
  },
  methods: {
    toggleFeatures() {
      this.featuresOpen = !this.featuresOpen
    },
  },
}
</script>

Defining duration and easing

By default duration is set to 300ms and easing is set to ease.

To override this, duration and easing can be passed as arguments to the directive. Duration should be defined in milliseconds. Built in easing options are: linear, ease, ease-in, ease-out, ease-in-out

Duration and easing can be set in this format v-show-slide:duration:easing

Example:

<ul v-show-slide:400:ease-in="featuresOpen" class="features">
  <li>Aliquam lorem</li>
  <li>Praesent porttitor nulla vitae posuere</li>
  <li>Suspendisse nisl elit rhoncus</li>
  <li>Donec mi odio faucibus</li>
  <li>Curabitur suscipit suscipit</li>
</ul>

Custom easing

If you want to define custom easing using cubic-bezier this can be done when installing the plugin. Pass an options object as the second parameter in Vue.use.

Example:

Vue.use(VShowSlide, {
  customEasing: {
    exampleEasing: 'cubic-bezier(0.68, -0.55, 0.265, 1.55)',
  },
})

Your custom easing can then be used like so (make sure to convert easing name to kebab-case):

v-show-slide:400:example-easing

Events

Events are fired on the same element the directive was defined on. Below are the available events:

Event Description
@slide-open-start Fired when the element starts sliding open
@slide-open-end Fired when the element finishes sliding open
@slide-close-start Fired when the element starts sliding closed
@slide-close-end Fired when the element finishes sliding closed

Example:

<template>
  <div id="app" class="app">
    <ul
      id="features"
      v-show-slide="featuresOpen"
      class="features"
      @slide-open-start="slideOpenStart"
      @slide-open-end="slideOpenEnd"
      @slide-close-start="slideCloseStart"
      @slide-close-end="slideCloseEnd"
    >
      <li>Aliquam lorem</li>
      <li>Praesent porttitor nulla vitae posuere</li>
      <li>Suspendisse nisl elit rhoncus</li>
      <li>Donec mi odio faucibus</li>
      <li>Curabitur suscipit suscipit</li>
    </ul>
    <button
      @click="toggleFeatures"
      class="toggle-features"
      aria-controls="features"
      :aria-expanded="featuresOpen ? 'true' : 'false'"
    >
      {{ featuresOpen ? 'Hide Features' : 'View Features' }}
    </button>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      featuresOpen: false,
    }
  },
  methods: {
    toggleFeatures() {
      this.featuresOpen = !this.featuresOpen
    },
    slideOpenStart() {
      console.log('Slide Open Start')
    },
    slideOpenEnd() {
      console.log('Slide Open End')
    },
    slideCloseStart() {
      console.log('Slide Close Start')
    },
    slideCloseEnd() {
      console.log('Slide Close End')
    },
  },
}
</script>

Accessibility (A11y)

This directive will prevent child elements of the sliding element from being focusable when closed. Other than that it does not handle any other aspects of a11y such as adding or removing of aria attributes. Check out the WAI-ARIA Authoring Practices for more information. The most basic setup is to use aria-expanded and aria-controls as shown in the above example.

Browser Support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
IE11, Edge > iOS 9

Support

Please open an issue for support.

Contributing

Please contribute using Github Flow. Create a branch, add commits, and open a pull request.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].