{"versions":{"1.0.0":{"name":"heyushuo-marquee","version":"1.0.0","description":"弹窗组件","main":"dist/marquee.min.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","start":"webpack-dev-server --hot --inline","build":"webpack --display-error-details --config webpack.config.js"},"author":{"name":"heyushuo"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/heyushuo/npm-package.git"},"devDependencies":{"babel-core":"^6.26.0","babel-loader":"^7.1.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-runtime":"^6.23.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-es2015":"^6.24.1","babel-preset-stage-2":"^6.24.1","css-loader":"^0.28.7","es6-promise":"^4.1.1","less":"^2.7.3","less-loader":"^4.0.5","node-sass":"^4.9.4","sass":"^1.14.3","sass-loader":"^7.1.0","style-loader":"^0.19.0","url-loader":"^0.6.2","vue":"^2.5.9","vue-hot-reload-api":"^2.2.4","vue-html-loader":"^1.2.4","vue-loader":"^13.5.0","vue-router":"^3.0.1","vue-style-loader":"^3.0.3","vue-template-compiler":"^2.5.9","vuex":"^3.0.1","webpack":"^3.9.1","webpack-dev-server":"^2.9.5"},"dependencies":{"axios":"^0.18.0"},"bugs":{"url":"https://github.com/heyushuo/npm-package/issues"},"homepage":"https://github.com/heyushuo/npm-package#readme","_id":"heyushuo-marquee@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"anonymous","email":"3217996347@qq.com"},"dist":{"integrity":"sha512-/7UyPA2rwPGeJgxnzRVGnmEu04xBbW+ivPPJVREvBnqBNde0r8TXSp454QNK/bEqshd96ZhgNF653zUh8Pmcxg==","shasum":"b4474f710e569d67abccea98f1b710e0dac4b09b","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heyushuo-marquee/-/heyushuo-marquee-1.0.0.tgz","fileCount":5,"unpackedSize":21260,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcg+boCRA9TVsSAnZWagAAM+kQAJflax9KSP+cDEQvLiJx\nW1yBcqRWQZCrlnz1kBiEAbH4Gou/pWjnac+GD4D7Jizlaf1IOnfqQ7ackgzb\nMvD8BvESXZp50BueMcCNR6h76Rjx9/GcJqbnsfqmx+CdTagJjwEWda3jK4ga\nMSUyvksGcqTj42j6Hh1S8tJ0pHPV1V5m36s/QMqr4g4Cq6xA2bs/10mCheue\nIgVvaii2ec2Ez4gcE3Ezehk+DUFiwGNSfCsoG6FJxD/ytC72Kzpi6TqxLTs2\n4NhJvQ2Nd3AmlDNo5qHUgdUkVm1noGOjJG1GS8G66Kwl8Jej1vAZnQxWspDb\nrq0jYBvStlUnhJblKLNrAWm8cFsX8TpecSRbMk59jDErL+Uc259huLnfp06j\naBGlq0rsvyVIT0ByVZzI8Osbd1nYYat5/h0apz7c0Nsx5qKZoPASKmbtrP9f\nwbq4bOrx2MbDZaJQQWZlAIF31YXj4zsuKspJrg88O/eIus5hPAQp2tykBh+p\nNp4DSyizr7Ou/QDsoC2d/9WnlgO6P53FFSrePqf/vMz3MxxIUzLIMezNL3oA\nIupBQh5YGVVQwGRig25y8qCXyWuvOdr+BmpKTY6tkmT7npvjJpNDSahBAlGM\n/t5AoScJHG51DLwpP7NT7St/liPCpIAoUr/m2S2DjzMOYEVD1Qa2DxDMVBB4\nobZh\r\n=ZNU8\r\n-----END PGP SIGNATURE-----\r\n","size":7850},"maintainers":[{"name":"anonymous","email":"3217996347@qq.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/heyushuo-marquee_1.0.0_1552148199703_0.3789301808787684"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-23T23:08:42.960Z","contributors":[]},"1.0.1":{"name":"heyushuo-marquee","version":"1.0.1","description":"弹窗组件","main":"dist/marquee.min.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","start":"webpack-dev-server --hot --inline","build":"webpack --display-error-details --config webpack.config.js"},"author":{"name":"heyushuo"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/heyushuo/npm-package.git"},"devDependencies":{"babel-core":"^6.26.0","babel-loader":"^7.1.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-runtime":"^6.23.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-es2015":"^6.24.1","babel-preset-stage-2":"^6.24.1","css-loader":"^0.28.7","es6-promise":"^4.1.1","less":"^2.7.3","less-loader":"^4.0.5","node-sass":"^4.9.4","sass":"^1.14.3","sass-loader":"^7.1.0","style-loader":"^0.19.0","url-loader":"^0.6.2","vue":"^2.5.9","vue-hot-reload-api":"^2.2.4","vue-html-loader":"^1.2.4","vue-loader":"^13.5.0","vue-router":"^3.0.1","vue-style-loader":"^3.0.3","vue-template-compiler":"^2.5.9","vuex":"^3.0.1","webpack":"^3.9.1","webpack-dev-server":"^2.9.5"},"dependencies":{"axios":"^0.18.0"},"bugs":{"url":"https://github.com/heyushuo/npm-package/issues"},"homepage":"https://github.com/heyushuo/npm-package#readme","_id":"heyushuo-marquee@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"anonymous","email":"3217996347@qq.com"},"dist":{"integrity":"sha512-txD6rKkHWcWOfP4+HuFOjZ7/jEq8jsMzjKSodPh2yN8x1AI+t5SoLadGsmOk+vrFpUhv9glpvrC87vBLHWwQQw==","shasum":"ef0f67866e79012d18fe945606b9b2a966a34af6","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heyushuo-marquee/-/heyushuo-marquee-1.0.1.tgz","fileCount":5,"unpackedSize":18754,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcg+kjCRA9TVsSAnZWagAA21kP/RI8t+BTLSKFtzC41qGZ\nzeGdBthGSVaJ0I8VK+VUMGDfPez8+ZNcsQVle07/mRTubzRWBHiozY74oKkE\ntAtKj9EAZqUwKBt79JXIKB4KS7ar6HDk1lHgy8gcfoH3tb9IH6EYDsW7DpNd\nPPj25D6O8qiY2UALPqrFxHk0HDrJCSDGX81Q/6usIb7HA1FfrPodCZXVV89g\niOP/RVkADfWN6nZENvIsDIkCauucIY7iEw0bGeJHernu99G4ktfv4kmtFRlq\nhuCqq0ulCTGdTKhwJJMfWaVi23mFuNlEv2ixUDQoI4S9aylVAjLcHhPD8WR3\nQhfcrbGjGFlPYpqk4bwArRl3pFElsGrZjo+z55zWwvW4CoEO/LUCiomwHneC\niXCGyC1/ANY+qr9r0VxXF4H9mdPvnI6JzEnW/057BTV3HaOR5t2Fk11FnYQv\nqHM8gPb6LPinBuCq9bFvHulSzGhfoAKrGpFuo2gKtHKlCpynBIIiTKKTSuE7\n3bBISnDU1NQtEXV/IUGvbcf4QtBFsJv0jcOzP8y3uGf08ylGt3oB2XJjS+9/\nxRVCTi1OEGjPFDnrT4p7eABgaLtVUIVED+LX0jXcp288J52wcdO1gPrHh1Yy\nq0K8EBycSy2uVLAgKODIPb2Aw97A/yO8YNcSHL83pYlDxEdKkhuZjNvuqTNX\nEw3V\r\n=123m\r\n-----END PGP SIGNATURE-----\r\n","size":7109},"maintainers":[{"name":"anonymous","email":"3217996347@qq.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/heyushuo-marquee_1.0.1_1552148771079_0.23809595184580568"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-23T23:08:43.816Z","contributors":[]},"1.0.2":{"name":"heyushuo-marquee","version":"1.0.2","description":"跑马灯效果","main":"dist/marquee.min.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","start":"webpack-dev-server --hot --inline","build":"webpack --display-error-details --config webpack.config.js"},"author":{"name":"heyushuo"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/heyushuo/npm-package.git"},"devDependencies":{"babel-core":"^6.26.0","babel-loader":"^7.1.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-runtime":"^6.23.0","babel-polyfill":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-es2015":"^6.24.1","babel-preset-stage-2":"^6.24.1","css-loader":"^0.28.7","es6-promise":"^4.1.1","less":"^2.7.3","less-loader":"^4.0.5","node-sass":"^4.9.4","sass":"^1.14.3","sass-loader":"^7.1.0","style-loader":"^0.19.0","url-loader":"^0.6.2","vue":"^2.5.9","vue-hot-reload-api":"^2.2.4","vue-html-loader":"^1.2.4","vue-loader":"^13.5.0","vue-router":"^3.0.1","vue-style-loader":"^3.0.3","vue-template-compiler":"^2.5.9","vuex":"^3.0.1","webpack":"^3.9.1","webpack-dev-server":"^2.9.5"},"dependencies":{"axios":"^0.18.0"},"bugs":{"url":"https://github.com/heyushuo/npm-package/issues"},"homepage":"https://github.com/heyushuo/npm-package#readme","_id":"heyushuo-marquee@1.0.2","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"anonymous","email":"3217996347@qq.com"},"dist":{"integrity":"sha512-5ILvIhjhGi8Biqu+kyT2BF3wRx/e9GERlwS2rS3tnchvAvOspGbfQBbxFqYIB4r50M0h+JaEStp3l+9wCaHxDA==","shasum":"fdddbb0840cd982ef69c93e81229786f92bedd4b","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/heyushuo-marquee/-/heyushuo-marquee-1.0.2.tgz","fileCount":5,"unpackedSize":18757,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcg+s+CRA9TVsSAnZWagAAXvoP/2cRbahnz8+1HPRNhsM1\nrn4VEzl+fUvBkjZwNqnXap+GRhZNrPvLg7rLLudVMJzSyWHfmG7lGgcRqfVn\nAo8wWqYcfVmJonSe5nQoHIA71xuZtTS3UhqqvxtgfEFK+/QXeaP5NBO13XxO\nPorIr0y6F//sRXUKCy/rn3dPEDA7FOOr9e4rA8WurSR9ywLatRfQ9nfwD6oL\n3pwgwabEDVNW4/yIzGa78DuKGC6qVocAMNGiAfkExOpjucnSz3QlNtkIaFiB\nH5gwo8bcOE1s4C/jZ4oWvWYJ/BD+I7qCUDF2owxHIJENsBNe1YjHred4fE5m\n8wNvACony3HI0eYF/SvQbbQtaDC7Jvs784FOvg/dZ5vup95wy7kxeNzJg5mg\n7fTpq0l19WPyyGLZ1Wct++NEsO8Yk2JvxgLGOuesUFFOip1EuQvKW4/1PpBv\n+qpJRWait7kNkRfCc2AvIH8hyG84lkSvvRKlRSLSwVgRSwZW8R9Crp9yzTG+\nMMucUaPNSy7gEZjBJ8s32vqRilrDZMqsx3jjlpWYu/ssqNp4+yOKKnHF2qO0\nthDrU87nzo4jmaOHRt3qoqqc403I8Suxhu56KO5q7rvdkw604qno7yMKyT/9\ndheceIil9yYRmVCnvr8I3O42x2a6/ZASZ6xYrpkFQGCiHTgFkKy4s3Dttl6/\nIynf\r\n=7S2C\r\n-----END PGP SIGNATURE-----\r\n","size":7106},"maintainers":[{"name":"anonymous","email":"3217996347@qq.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/heyushuo-marquee_1.0.2_1552149309673_0.7019610099330695"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-23T23:08:44.713Z","contributors":[]}},"dist-tags":{"latest":"1.0.2"},"name":"heyushuo-marquee","time":{"created":"2022-01-27T17:59:42.201Z","modified":"2022-01-27T17:59:42.201Z","1.0.0":"2019-03-09T16:16:39.838Z","1.0.1":"2019-03-09T16:26:11.207Z","1.0.2":"2019-03-09T16:35:09.752Z"},"readme":"## Vue 实现跑马灯效果\r\n\r\n### 前言\r\n\r\n最近做活动需要做跑马灯效果，其他同事也有实现，本来打算复制他们代码，发现都是使用`setInterval`实现了，也没有封装为组件，所以自己用`CSS3`实现了一下跑马灯效果,并封装为组件,这样以后在需要写的时候,只需要引入组件就可以了。\r\n\r\n### 实现的效果如下\r\n\r\n![](https://user-gold-cdn.xitu.io/2019/3/9/169631ba6fd78b57?w=329&h=122&f=gif&s=139118)\r\n\r\n### 实现思路\r\n\r\n`HTML` 结构父盒子固定,子盒子滚动,并包含需要效果的内容\r\n\r\n跑马灯效果 `CSS3` 实现肯定需要 `infinite` (循环执行动画)\r\n\r\n运动前需要计算父盒子的宽度(`wrapWidth`),还有子盒子的总宽度(`offsetWidth`)\r\n\r\n需要给定速度通过宽度计算出`CSS3`动画需要的时间`duration`\r\n\r\n### 组件设计\r\n\r\n向外暴露三个参数\r\n\r\n- content: 因为滚动的数据大部分都是后台获取的,监听 content,当 content 有值的时候开始滚动(content 可以是任何类型数据)\r\n- delay: 多久时开始执行动画只有第一次滚动时候生效(默认是 0.3s)\r\n- speed: 速度(默认 100)\r\n\r\n[github 地址源码地址](https://github.com/heyushuo/vue-marquee)\r\n\r\n### 源码实现如下\r\n\r\n源码中大部分都添加了注释,如有问题请指出谢谢\r\n\r\n```Vue\r\n<template>\r\n  <div ref=\"wrap\" class=\"wrap\">\r\n    <div ref=\"content\" class=\"content\" :class=\"animationClass\" :style=\"contentStyle\" @animationend=\"onAnimationEnd\" @webkitAnimationEnd=\"onAnimationEnd\">\r\n      <slot></slot>\r\n    </div>\r\n  </div>\r\n</template>\r\n<script>\r\nexport default {\r\n  props: {\r\n    content: {\r\n      default: ''\r\n    },\r\n    delay: {\r\n      type: Number,\r\n      default: 0.5\r\n    },\r\n    speed: {\r\n      type: Number,\r\n      default: 100\r\n    }\r\n  },\r\n  mounted() {},\r\n  data() {\r\n    return {\r\n      wrapWidth: 0,     //父盒子宽度\r\n      firstRound: true, //判断是否\r\n      duration: 0,      //css3一次动画需要的时间\r\n      offsetWidth: 0,    //子盒子的宽度\r\n      animationClass: '' //添加animate动画\r\n    };\r\n  },\r\n  computed: {\r\n    contentStyle() {\r\n      return {\r\n        //第一次从头开始,第二次动画的时候需要从最右边出来所以宽度需要多出父盒子的宽度\r\n        paddingLeft: (this.firstRound ? 0 : this.wrapWidth) + 'px',\r\n        //只有第一次的时候需要延迟\r\n        animationDelay: (this.firstRound ? this.delay : 0) + 's',\r\n        animationDuration: this.duration + 's'\r\n      };\r\n    }\r\n  },\r\n  watch: {\r\n    content: {\r\n      //监听到有内容,从后台获取到数据了,开始计算宽度,并计算时间,添加动画\r\n      handler() {\r\n        this.$nextTick(() => {\r\n          const { wrap, content } = this.$refs;\r\n          const wrapWidth = wrap.getBoundingClientRect().width;\r\n          const offsetWidth = content.getBoundingClientRect().width;\r\n          this.wrapWidth = wrapWidth;\r\n          this.offsetWidth = offsetWidth;\r\n          this.duration = offsetWidth / this.speed;\r\n          this.animationClass = 'animate';\r\n        });\r\n      }\r\n    }\r\n  },\r\n  methods: {\r\n    //这个函数是第一次动画结束的时候,第一次没有使用infinite,第一次动画执行完成后开始使用添加animate-infinite动画\r\n    onAnimationEnd() {\r\n      this.firstRound = false;\r\n      //这是时候样式多出了padding-left:this.wrapWidth;所以要想速度一样需要重新计算时间\r\n      this.duration = (this.offsetWidth + this.wrapWidth) / this.speed;\r\n      this.animationClass = 'animate-infinite';\r\n    }\r\n  }\r\n};\r\n</script>\r\n<style scoped>\r\n.wrap {\r\n  width: 100%;\r\n  height: 24px;\r\n  overflow: hidden;\r\n  position: relative;\r\n  background: rgba(211, 125, 066, 1);\r\n  position: relative;\r\n  padding: 0;\r\n}\r\n\r\n.wrap .content {\r\n  position: absolute;\r\n  white-space: nowrap;\r\n}\r\n\r\n.animate {\r\n  animation: paomadeng linear;\r\n}\r\n\r\n.animate-infinite {\r\n  animation: paomadeng-infinite linear infinite;\r\n}\r\n\r\n@keyframes paomadeng {\r\n  to {\r\n    transform: translate3d(-100%, 0, 0);\r\n  }\r\n}\r\n\r\n@keyframes paomadeng-infinite {\r\n  to {\r\n    transform: translate3d(-100%, 0, 0);\r\n  }\r\n}\r\n</style>\r\n```\r\n\r\n### 把源码发布到 npm 上\r\n\r\n请参考我的另外一篇文章,[如何将自己的 vue 组件发布为 npm 包](https://github.com/heyushuo/Blob/blob/master/JavaScript/10.%E5%A6%82%E4%BD%95%E5%B0%86%E8%87%AA%E5%B7%B1%E7%9A%84vue%E7%BB%84%E4%BB%B6%E5%8F%91%E5%B8%83%E4%B8%BAnpm%E5%8C%85.md)\r\n\r\n### 使用方法\r\n\r\n[github 如何使用地址和源码地址](https://github.com/heyushuo/vue-marquee)\r\n\r\n```JavaScript\r\nnpm install heyushuo-marquee --save\r\nimport PaoMaDeng from 'heyushuo-marquee';\r\n\r\n```\r\n\r\n[github 如何使用地址和源码地址](https://github.com/heyushuo/vue-marquee)","users":{}}