@smt-ui/component
Advanced tools
Comparing version 1.2.5 to 1.2.6
{ | ||
"name": "@smt-ui/component", | ||
"version": "1.2.5", | ||
"version": "1.2.6", | ||
"description": "extension base", | ||
@@ -47,3 +47,3 @@ "author": "jialipeng <jialipeng@baidu.com>", | ||
}, | ||
"gitHead": "033dae05cf68aa8e1099c55aad409b7ebd5495c8" | ||
"gitHead": "1052d3d79b0a2f5fa38eb0e43b988d66206dd236" | ||
} |
@@ -7,2 +7,4 @@ "use strict"; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
@@ -15,5 +17,6 @@ | ||
*/ | ||
// 文本宽度,用于计算速度 | ||
var textWidth = 0; | ||
/* global swan */ | ||
Component({ | ||
// eslint-disable-line | ||
externalClasses: ['notice-bar-class', 'text-class'], | ||
@@ -75,2 +78,4 @@ properties: { | ||
containerWidth: 0, | ||
// 文本宽度,计算速度 | ||
textWidth: 0, | ||
// 动画配置 | ||
@@ -107,3 +112,3 @@ animationData: null, | ||
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() { | ||
var _this2$data, scroll, speed, delay, containerWidth, duration; | ||
var _this2$data, scroll, speed, delay, _yield, _yield2, containerWidth, textWidth, duration; | ||
@@ -128,3 +133,3 @@ return _regenerator["default"].wrap(function _callee$(_context) { | ||
case 5: | ||
containerWidth = _context.sent; | ||
_context.t0 = _context.sent; | ||
_context.next = 8; | ||
@@ -134,6 +139,15 @@ return _this2.getWidths('.notice-bar .text-container .text'); | ||
case 8: | ||
textWidth = _context.sent; | ||
_context.t1 = _context.sent; | ||
_context.next = 11; | ||
return [_context.t0, _context.t1]; | ||
case 11: | ||
_yield = _context.sent; | ||
_yield2 = (0, _slicedToArray2["default"])(_yield, 2); | ||
containerWidth = _yield2[0]; | ||
textWidth = _yield2[1]; | ||
duration = +(textWidth / speed * 1000).toFixed(2); | ||
_this2.setData({ | ||
textWidth: textWidth, | ||
containerWidth: containerWidth | ||
@@ -148,3 +162,3 @@ }, function () { | ||
case 11: | ||
case 17: | ||
case "end": | ||
@@ -194,2 +208,3 @@ return _context.stop(); | ||
var _this$data = this.data, | ||
textWidth = _this$data.textWidth, | ||
speed = _this$data.speed, | ||
@@ -196,0 +211,0 @@ containerWidth = _this$data.containerWidth, |
@@ -6,6 +6,5 @@ /** | ||
*/ | ||
// 文本宽度,用于计算速度 | ||
let textWidth = 0; | ||
Component({ | ||
/* global swan */ | ||
Component({ // eslint-disable-line | ||
externalClasses: ['notice-bar-class', 'text-class'], | ||
@@ -79,2 +78,5 @@ | ||
// 文本宽度,计算速度 | ||
textWidth: 0, | ||
// 动画配置 | ||
@@ -117,8 +119,8 @@ animationData: null, | ||
} | ||
const containerWidth = await this.getWidths('.notice-bar .text-container'); | ||
textWidth = await this.getWidths('.notice-bar .text-container .text'); | ||
const [containerWidth, textWidth] = await [ | ||
await this.getWidths('.notice-bar .text-container'), | ||
await this.getWidths('.notice-bar .text-container .text') | ||
]; | ||
const duration = +(textWidth / speed * 1000).toFixed(2); | ||
this.setData({ | ||
containerWidth | ||
}, () => { | ||
this.setData({textWidth, containerWidth}, () => { | ||
if (textWidth > containerWidth) { | ||
@@ -161,3 +163,3 @@ setTimeout(() => this.genAnimate(duration, textWidth), delay * 1000); | ||
aniEndHandler() { | ||
const {speed, containerWidth, infinite} = this.data; | ||
const {textWidth, speed, containerWidth, infinite} = this.data; | ||
const duration = +((textWidth + containerWidth) / speed * 1000).toFixed(2); | ||
@@ -164,0 +166,0 @@ const fn = () => this.genAnimate(duration, textWidth + containerWidth); |
@@ -1,1 +0,1 @@ | ||
{"name":"component","label":"通用","type":"component","configPath":"./smart-design-config.json","version":"1.2.4"} | ||
{"name":"component","label":"通用","type":"component","configPath":"./smart-design-config.json","version":"1.2.5"} |
Sorry, the diff of this file is too big to display
1077953
16219