gui-scroll-message.vue 1.6 KB

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