GithubHelp home page GithubHelp logo

hhy5277 / vue-chat-scroll Goto Github PK

View Code? Open in Web Editor NEW

This project forked from theomessin/vue-chat-scroll

0.0 1.0 0.0 157 KB

Automatic scroll-to-bottom directive for vue.

Home Page: https://theomessin.github.io/vue-chat-scroll/

License: MIT License

JavaScript 100.00%

vue-chat-scroll's Introduction

vue-chat-scroll

A plugin for Vue.js 2 that scrolls to the bottom of an element when new content is added within said element. Check out our lovely demo.

Installation

  • NPM / Yarn Run npm install --save vue-chat-scroll, or yarn add vue-chat-scroll

  • With Modules

// ES6
import Vue from 'vue'
import VueChatScroll from 'vue-chat-scroll'
Vue.use(VueChatScroll)

// ES5
var Vue = require('vue')
Vue.use(require('vue-chat-scroll'))
  • <script> Include

Just include ./dist/vue-chat-scroll.js after Vue itself.

Usage

There's nothing you need to do in JavaScript except for installation. To use the plugin, simply use the v-chat-scroll directive.

<ul class="messages" v-chat-scroll>
  <li class="message" v-for="n in messages">{{ n }}</li>
</ul>

Prevent scroll down when user has scrolled up & smooth scrolling

Alternatively, you can pass a config value to the directive:

<ul class="messages" v-chat-scroll="{always: false, smooth: true}">
  <li class="message" v-for="n in messages">{{ n }}</li>
</ul>

Scroll with dissapearing elements in chat window (see #30)

If you have a "loading" animation that disappears when you receive a message from an external source, use the scrollonremoved option to ensure the scroll will happen after the element has been removed

<ul class="messages" v-chat-scroll="{always: false, smooth: true, scrollonremoved:true}">
  <li class="message" v-for="n in messages">{{ n }}</li>
  <li v-if="loading">&bull;&bull;&bull;</li>
</ul>

License

MIT

vue-chat-scroll's People

Contributors

caleuanhopkins avatar dzcpy avatar kennyki avatar kylestev avatar snowyu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.