gui-scroll-message.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view
  3. class="gui-scroll-body gui-flex gui-row gui-nowrap">
  4. <!-- #ifdef APP-NVUE -->
  5. <view
  6. class="gui-scroll-msg gui-scrolling"
  7. ref="guiscrollbody">
  8. <slot></slot>
  9. </view>
  10. <!-- #endif -->
  11. <!-- #ifndef APP-NVUE -->
  12. <view
  13. class="gui-scroll-msg gui-scrolling"
  14. :style="{'animation-duration':speed+'s'}">
  15. <slot></slot>
  16. </view>
  17. <!-- #endif -->
  18. </view>
  19. </template>
  20. <script>
  21. // #ifdef APP-NVUE
  22. const BindingX = uni.requireNativePlugin('bindingx');
  23. // #endif
  24. export default {
  25. name : "gui-scroll-message",
  26. props : {
  27. speed : {type:Number, default:12},
  28. distance : {type:Number, default:1200}
  29. },
  30. data() {
  31. return {
  32. BindingXObj : {},
  33. AnimateObj : 0
  34. }
  35. },
  36. // #ifdef APP-NVUE
  37. mounted:function(){
  38. setTimeout(()=>{
  39. this.BindingXObj = this.$refs.guiscrollbody.ref;
  40. this.animationL();
  41. }, 100);
  42. },
  43. methods:{
  44. animationL : function(){
  45. this.AnimateObj = BindingX.bind({
  46. eventType : 'timing',
  47. exitExpression : 't>'+(this.speed*1000),
  48. props : [
  49. {
  50. element : this.BindingXObj,
  51. property : 'transform.translateX',
  52. expression : "500+(-"+this.distance+")*t/"+(this.speed*1000)
  53. }
  54. ]
  55. }, (e)=>{
  56. if(e.state === 'exit') {
  57. setTimeout(()=>{
  58. this.animationL();
  59. },100);
  60. }
  61. });
  62. }
  63. }
  64. // #endif
  65. }
  66. </script>
  67. <style scoped>
  68. .gui-scroll-body{overflow:hidden;}
  69. /* #ifndef APP-NVUE */
  70. .gui-scrolling{animation:graceScrollingx 12s linear infinite;}
  71. @keyframes graceScrollingx{ 0% { transform:translateX(60%); } 100% { transform: translateX(-100%); }}
  72. /* #endif */
  73. </style>