[Vuejs]-Vue JS transition toggle based of class binded โ€“ ease down and up

0๐Ÿ‘

I have made one sample example. Check this once. This may help.(you mention 100% in max-height and in starting max-height you mentioned 51px thats might be the problem for not transitioning. Maintain both in px or %)

<template>
<div id="app">
    <div class="paragraph" :class="{showmore:checkStatus}">
       <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.             Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

  </p>
</div>
<button @click="changeData">{{ readStatus }}</button>
  </div>
  </template>

<script>
  export default {
  name: 'App',
  data:function(){
return {
  readStatus:'readmore',
  checkStatus:false
}
},
methods:{
changeData:function(){

  if(this.readStatus=='readmore'){
    this.readStatus='readless';
    this.checkStatus=true;
  }else{
    this.readStatus='readmore';
    this.checkStatus=false;
  }
  }
  }
 }
  </script>

<style scoped>
  .paragraph {
max-height: 100px;
overflow: hidden;
transition: max-height 2s;

 }
 .paragraph p{
  color: black;
 }
 .showmore{
max-height: 500px;
overflow: auto;
 }
</style>
๐Ÿ‘คPallamolla Sai

Leave a comment