0.5.3 • Published 5 years ago

simulate-chatting v0.5.3

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Simulate Chatting

NPM version David deps devDependencies Status npm license

license-image: https://img.shields.io/npm/l/simulate-chatting.svg?style=flat-square

(Releases | Demo)

This package has been migrated to @cycjimmy/simulate-chatting for scoped NPM package. Please switch to @cycjimmy/simulate-chatting to stay up to date.

Install

# via npm
$ npm install simulate-chatting --save

# or via yarn
$ yarn add simulate-chatting

Use

Simulate chatting based on Swiper 4+. Add Script of swiper in your project first

import SimulateChat from 'simulate-chatting';

# OR
const SimulateChat = require('simulate-chatting');
let simulateChat = new SimulateChat(wrapper, options);
  • wrapper: Element|String Context Wrapper Element. Required
  • options: looks like: { sound: 'source', chartList: [] }
    • footer: Object. Default null.
      • height: Number|String Height of footer input. If you want to add the unit, can use the string form. E.g: '20vw'.
      • img: String Image source.
    • sound: String Audio source. Default ''.
    • chartList: Array Array of chartList patterns. Default [].
      • A pattern looks like: { pos: 'left', w: 100, h: 30, img: '', delay: 2000 [, ...] }
        • pos: String Position of the pattern. Use one of the three options:
          • 'left'
          • 'center'
          • 'right'
        • w: Number|String Width of pattern. If you want to add the unit, can use the string form. E.g: '20vw'.
        • h: Number|String Height of pattern. If you want to add the unit, can use the string form. E.g: '20vw'.
        • top: Number|String Custom set the margin from the previous. If you want to add the unit, can use the string form. E.g: '20vw'.
        • img: String Image source.
        • delay: Number Delay from the previous pattern display. Default 1500.
        • custom: Boolean Whether to enable custom mode.
        • html: String Custom html structure of pattern when custom is true.
        • pause: Boolean Whether to pause the running of patterns after this pattern display.
        • muted: Boolean Whether not to play the sound when this pattern show.
        • callback: Function if set, run callback function after this pattern show.
    • SwiperModule: Object Can use custom Swiper. Note the version to 4+. Default null.
  • Functions:
    • start(): Start to display patterns.
    • pause(): Pause the running of patterns.
    • reset(): Reset patterns.

Use in browser

<div id="wrapper"></div>

<script src="swiper.min.js"></script>
<script src="simulateChatting.min.js"></script>
<script>
  var simulateChat = new SimulateChat('#wrapper', {
    sound: 'msg.mp3',
    footer: {
      height: 40,
      img: 'footerInput.jpg'
    },
    chartList: [...]
  });

  simulateChat.start();
</script>

CDN

To use via a CDN include this in your html:

<script src="https://cdn.jsdelivr.net/npm/simulate-chatting@0/build/simulateChatting.min.js"></script>
0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.3

7 years ago