{"name":"rc-bullets","version":"1.2.0","description":"awesome barrage powered by CSS3 animation and built by react ","author":{"name":"zerosoul"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/zerosoul/rc-bullets.git"},"main":"dist/index.js","module":"dist/index.es.js","jsnext:main":"dist/index.es.js","engines":{"node":">=8","npm":">=5"},"keywords":["弹幕","danmaku","barrage","bullet","react","CSS3","年会"],"scripts":{"build":"rollup -c","start":"rollup -c -w","prepare":"rm -rf ./dist && npm run build","predeploy":"cd example && npm install && npm run build","deploy":"gh-pages -d example/build"},"peerDependencies":{"react":"^16.8.0","react-dom":"^16.8.0"},"devDependencies":{"@babel/core":"^7.7.4","@babel/plugin-proposal-class-properties":"^7.7.4","@babel/preset-env":"^7.7.4","@babel/preset-react":"^7.7.4","@svgr/rollup":"^4.3.3","babel-eslint":"^10.0.3","babel-plugin-styled-components":"^1.10.6","cross-env":"^6.0.3","eslint":"^6.7.1","eslint-config-prettier":"^6.5.0","eslint-plugin-react":"^7.16.0","eslint-plugin-react-hooks":"^2.3.0","gh-pages":"^2.1.1","prettier":"^1.19.1","react":"^16.12.0","react-dom":"^16.12.0","react-scripts":"^3.2.0","rollup":"^1.27.5","rollup-plugin-babel":"^4.3.3","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-peer-deps-external":"^2.2.0","rollup-plugin-terser":"^5.1.2","rollup-plugin-url":"^3.0.1","styled-components":"^4.4.1"},"gitHead":"6a95383e9e0eb41dc468e389d3a4badadfdee431","bugs":{"url":"https://github.com/zerosoul/rc-bullets/issues"},"homepage":"https://github.com/zerosoul/rc-bullets#readme","_id":"rc-bullets@1.2.0","_nodeVersion":"10.16.0","_npmVersion":"6.12.0","dist":{"integrity":"sha512-nR0yeUE9n4CvVaHd9A/s5yBrMo8CVPUDjinXg7UcVI3w6TJ4jjCgRy5Yx7anfOtcNqfHGPopPkNn4S1TsnJV5A==","shasum":"277f050ea3a46ff2586902e77316fc3f62a17097","tarball":"http://registry-npm.ywwl.com/rc-bullets/download/rc-bullets-1.2.0.tgz","fileCount":6,"unpackedSize":669294,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd34zSCRA9TVsSAnZWagAAkLEP/1nf89yVIULnn6qyID95\nRHLkTViq9rytM/0u3AyPLyQDPXS/kZFo+aMUcopraOzIeApJX0tIOPOK0LmJ\n3+IUxZp6JdERqNMKHibl8vsZxoS9A/Ud95TOmiXxIvIBP/HFJwaGGGllZq5J\nwH06O+ZmFMDJvO61s201vqeZOh5IarHekUFf9odWlCWx3BoSNiytqzqLt1Yo\n2257oCwJOsUaV4PwPchvr5s3nHolyTCUc3ZNa/GBHfUhagt2aqALVCL1SSUW\n0lEte14W+wfL66Si+vpLcp3o5wtJjNrMODYCG9534CM3OSDVhyZiQS0lnYPe\ndyxYDMJqJU+5kRwhH0oEn14bMyJvU4RG13wY0T1la/uDSFn5PnS5a2RuhG+J\nk2docyJP4TjMMEdiT8VVcNBDTFaS0TVKvMcTRA4Zam+5bgFrvJAzTWZfZ4+B\nhRiNGDLe7fDWjb7eTIHttIc2rSGqo7eQS4EwEWjaLZ8P3dU4AHzT/cNti9JP\nPA9DZj0BoqXD6yKVqHnibq0KWGiIZNLD2y0BBqIDy62GsuwKMkdwqCaVwUSR\nynHxTO8AgBsGESYHRfDRS11zS9+Ow9KrK1g7NVsfcNXJUM6Yaze07uKiNDXE\n/lmqX3Ebl0XW0ze/STr/l7z9yvur3JW5HnaUvIPtz8F5XNCSlZ7hnH2Dy4aw\nQMV4\r\n=biz6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHP7iusjdHePDpV8Tw/zRvEWidd/z7uFQ863gz5DWTi9AiEAhqI0hIugrX+hkHcQoLtVDXWeCI+y3pIEFrKnCocsk38="}],"size":204341,"noattachment":false,"key":"/rc-bullets/-/rc-bullets-1.2.0.tgz"},"maintainers":[{"name":"tristanyang","email":"yanggc888@gmail.com"}],"_npmUser":{"name":"tristanyang","email":"yanggc888@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rc-bullets_1.2.0_1574931665957_0.4372273292277835"},"_hasShrinkwrap":false,"readme":"# React 弹幕\n\n> 🌈 基于 CSS3 Animation，使用 React 构建，可扩展，高性能。\n\n[![NPM](https://img.shields.io/npm/v/rc-bullets.svg)](https://www.npmjs.com/package/rc-bullets) [![NPM downloads](https://img.shields.io/npm/dm/rc-bullets.svg)](http://npmjs.com/package/rc-bullets) [![twitter](https://img.shields.io/twitter/follow/wsygc?style=social)](https://twitter.com/wsygc)\n\n## 演示地址\n\n👉[zerosoul.github.io/rc-bullets/](https://zerosoul.github.io/rc-bullets/)\n\n![demo gif](demo.gif)\n\n## 安装\n\nnpm:\n\n```bash\nnpm install --save rc-bullets\n```\n\nyarn:\n\n```bash\nyarn add rc-bullets\n```\n\n## 初始化一个简单的弹幕场景\n\n```jsx\nimport React, { useEffect, useState } from 'react';\nimport BulletScreen, { StyledBullet } from 'rc-bullets';\n\nconst headUrl='https://zerosoul.github.io/rc-bullets/assets/img/heads/girl.jpg';\nexport default function Demo() {\n  // 弹幕屏幕\n  const [screen, setScreen] = useState(null);\n  // 弹幕内容\n  const [bullet, setBullet] = useState('');\n  useEffect(() => {\n    // 给页面中某个元素初始化弹幕屏幕，一般为一个大区块。此处的配置项全局生效\n    let s = new BulletScreen('.screen',{duration:20});\n    // or\n    // let s=new BulletScreen(document.querySelector('.screen));\n    setScreen(s);\n  }, []);\n  // 弹幕内容输入事件处理\n  const handleChange = ({ target: { value } }) => {\n    setBullet(value);\n  };\n  // 发送弹幕\n  const handleSend = () => {\n    if (bullet) {\n      // push 纯文本\n      screen.push(bullet);\n      // or 使用 StyledBullet\n\n      screen.push(\n        <StyledBullet\n          head={headUrl}\n          msg={bullet}\n          backgroundColor={'#fff'}\n          size='large'\n        />\n      );\n      // or 还可以这样使用，效果等同使用 StyledBullet 组件\n      screen.push({msg:bullet,head:headUrl,color:\"#eee\" size=\"large\" backgroundColor:\"rgba(2,2,2,.3)\"})\n    }\n  };\n  return (\n    <main>\n      <div className=\"screen\" style={{ width: '100vw', height: '80vh' }}></div>\n      <input value={bullet} onChange={handleChange} />\n      <button onClick={handleSend}>发送</button>\n    </main>\n  );\n}\n```\n\n## 特性\n\n- 支持传入 React 组件，灵活控制弹幕内容和 UI，并提供一个默认样式组件：`<StyledBullet/>`\n- 弹幕屏幕管理：清屏，暂停，隐藏（后续可能会加入针对单个弹幕的控制）\n- 弹幕动画参数化：运动函数（匀速/ease/步进/cubic-bezier）、时长（秒）、循环次数、延迟等\n- 鼠标悬浮弹幕暂停\n\n## 常用 API\n\n- 初始化弹幕屏幕：`const screen = new BulletScreen(<queryString>|<HTMLElement>,[<option>])`，此处的`option`和下面的一致，偏向全局初始化，没有则使用默认值，每次发送弹幕不传则使用默认或全局设置，传了则该条弹幕覆盖全局设置。\n- 发送弹幕：`const bulletId = screen.push(<string>|<ReactElement>,[<option>])`\n\n`option`：\n\n| 选项           | 含义               | 值类型        | 默认值      | 备注                                                                                                                      |\n| -------------- | ------------------ | ------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- |\n| top            | 弹幕位置           | string        | undefined   | 自已强制定制距离顶部的高度，格式同 CSS 中的 top                                                                           |\n| trackHeight    | 轨道高度           | number        | 50          | 均分轨道的高度                                                                                                            |\n| onStart        | 自定义动画开始函数 | function      | null        | e.g.(bulletId,screen)=>{//do something}可以自定义一些动作，比如播放某个音效，在特定时间暂停该弹幕：screen.pause(bulletId) |\n| onEnd          | 自定义动画结束函数 | function      | null        | e.g.(bulletId,screen)=>{//do something}可以自定义一些动作，比如播放某个音效                                               |\n| pauseOnClick   | 鼠标点击暂停       | boolean       | false       | 再次点击继续                                                                                                              |\n| pauseOnHover   | 鼠标悬停暂停       | boolean       | true        | 鼠标进入暂停，离开继续                                                                                                    |\n| loopCount      | 循环次数           | number/string | 1           | 值为‘infinite’时，表示无限循环                                                                                            |\n| duration       | 滚动时长           | number/string | 10          | 数字则单位为‘秒’，字符串则支持'10s'和'300ms'两种单位                                                                      |\n| delay          | 延迟               | number/string | 0           | 数字则单位为‘秒’，字符串则支持'10s'和'300ms'两种单位                                                                      | [animation-delay](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-delay)支持的所有值 |\n| direction      | 动画方向           | string        | normal      | [animation-direction](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-direction)支持的所有值                   |\n| animateTimeFun | 动画函数           | string        | linear:匀速 | [animation-timing-function](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-timing-function)支持的所有值       |\n\n- 弹幕清屏：`screen.clear([<bulletId>])`，无参则清除全部\n- 暂停弹幕：`screen.pause([<bulletId>])`，无参则暂停全部\n- 弹幕继续：`screen.resume([<bulletId>])`，无参则继续全部\n- 隐藏弹幕（滚动继续）：`screen.hide([<bulletId>])`，无参则隐藏全部\n- 显示弹幕：`screen.show([<bulletId>])`，无参则显示全部\n- 自带的一个弹幕样式组件：`<StyledBullet msg=\"<弹幕内容>\" head=\"<头像地址>\" color=\"<字体颜色>\" backgroundColor=\"<背景色>\" size=\"<尺寸:small|normal|large|huge|自定义大小,基于em机制，默认normal>\">`\n\n## TO DO\n\n- ~~弹幕过多时，防重叠处理~~\n- react hooks 版本：`useBulletScreen`\n\n## 自己动手，丰衣足食\n\n### 克隆项目\n\n`git clone https://github.com/zerosoul/rc-bullets.git && cd rc-bullets`\n\n### 本地类库构建\n\n`npm i && npm run start`\n\n### 本地 demo\n\n`cd example && npm i && npm run start`\n\n## 支持\n\n![赞赏码](example/src/assets/img/reward.jpg)\n\n## License\n\nMIT © [zerosoul](https://github.com/zerosoul)\n","publish_time":1574931666131,"_cnpm_publish_time":1574931666131,"dist-tags":{"latest":"1.5.16"}}