antd-mini-rpx
Advanced tools
Comparing version 0.0.21-alpha.1 to 0.0.21-beta.0
@@ -13,15 +13,31 @@ "use strict"; | ||
didMount: function () { | ||
var value = this.props.value; | ||
this.setData({ | ||
fileList: value | ||
}); | ||
this.handleValue(); | ||
}, | ||
didUpdate: function (prevProps) { | ||
if (!(0, fast_deep_equal_1.default)(prevProps.value, this.props.value)) { | ||
this.setData({ | ||
fileList: this.props.value | ||
}); | ||
this.handleValue(); | ||
} | ||
}, | ||
methods: { | ||
handleValue: function () { | ||
var curValue; | ||
var value = this.props.value; | ||
if (typeof value === 'string') { | ||
curValue = [].concat(value); | ||
} | ||
else if (Array.isArray(value) && | ||
value.length && | ||
value.some(function (v) { return typeof v === 'string'; })) { | ||
curValue = value.map(function (v) { return (typeof v === 'string' ? { | ||
url: v, | ||
status: 'done' | ||
} : v); }); | ||
} | ||
else { | ||
curValue = value; | ||
} | ||
this.setData({ | ||
fileList: curValue | ||
}); | ||
}, | ||
onChooseImage: function () { | ||
@@ -28,0 +44,0 @@ return tslib_1.__awaiter(this, void 0, void 0, function () { |
@@ -42,3 +42,3 @@ import { IBaseProps } from '../_base'; | ||
*/ | ||
value?: Array<File>; | ||
value?: Array<File | string> | string; | ||
@@ -45,0 +45,0 @@ /** |
@@ -7,2 +7,5 @@ "use strict"; | ||
Component({ | ||
data: { | ||
supportSjs: my.canIUse('sjs.event'), | ||
}, | ||
props: props_1.MaskDefaultProps, | ||
@@ -9,0 +12,0 @@ methods: { |
@@ -7,8 +7,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
export interface IMaskProps extends IBaseProps { | ||
maskZindex: string, | ||
type: 'product' | 'market', | ||
show: boolean, | ||
fixMaskFull: false, | ||
onMaskTap: (v: Record<string, any>) => void | ||
maskZindex: string; | ||
type: 'product' | 'market'; | ||
show: boolean; | ||
fixMaskFull: boolean; | ||
disableScroll: boolean; | ||
onMaskTap: (v: Record<string, any>) => void; | ||
} | ||
export declare const MaskDefaultProps: Partial<IMaskProps>; |
@@ -11,4 +11,5 @@ "use strict"; | ||
show: true, | ||
fixMaskFull: false | ||
fixMaskFull: false, | ||
disableScroll: false | ||
}; | ||
exports.MaskDefaultProps = MaskDefaultProps; |
@@ -5,15 +5,11 @@ "use strict"; | ||
var console_1 = require("../_util/console"); | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
var noop = function () { }; | ||
var _canIUseTransitionEnd = my.canIUse('view.onTransitionEnd'); | ||
Component({ | ||
props: props_1.NoticeBarDefaultProps, | ||
data: { | ||
_show: true, | ||
_canIUseTransitionEnd: _canIUseTransitionEnd, | ||
_marqueeStyle: '', | ||
_animatedWidth: 0, | ||
_overflowWidth: 0, | ||
_duration: 0, | ||
_viewWidth: 0, | ||
show: true, | ||
marqueeStyle: '', | ||
animatedWidth: 0, | ||
overflowWidth: 0, | ||
duration: 0, | ||
viewWidth: 0, | ||
}, | ||
@@ -24,9 +20,3 @@ didMount: function () { | ||
if (enableMarquee) { | ||
if (!_canIUseTransitionEnd) { | ||
this._measureText(); | ||
this._startAnimation(); | ||
} | ||
else { | ||
this._measureText(this.startMarquee.bind(this)); | ||
} | ||
this.measureText(this.startMarquee.bind(this)); | ||
} | ||
@@ -39,18 +29,26 @@ }, | ||
if (enableMarquee) { | ||
if (!this._marqueeTimer && !_canIUseTransitionEnd) { | ||
this._measureText(); | ||
this._startAnimation(); | ||
} | ||
else { | ||
this._measureText(this.startMarquee.bind(this)); | ||
} | ||
this.measureText(this.startMarquee.bind(this)); | ||
} | ||
}, | ||
didUnmount: function () { | ||
if (this._marqueeTimer) { | ||
clearTimeout(this._marqueeTimer); | ||
this._marqueeTimer = null; | ||
} | ||
pageEvents: { | ||
onShow: function () { | ||
this.resetState(); | ||
}, | ||
}, | ||
methods: { | ||
resetState: function () { | ||
var _this = this; | ||
if (this.props.enableMarquee) { | ||
this.setData({ | ||
marqueeStyle: '', | ||
animatedWidth: 0, | ||
overflowWidth: 0, | ||
duration: 0, | ||
viewWidth: 0, | ||
}, function () { | ||
_this.resetMarquee(); | ||
_this.measureText(_this.startMarquee.bind(_this)); | ||
}); | ||
} | ||
}, | ||
showError: function () { | ||
@@ -69,3 +67,3 @@ var actions = this.props.actions; | ||
this.setData({ | ||
_show: false, | ||
show: false, | ||
}); | ||
@@ -88,10 +86,10 @@ return onTap(); | ||
var loop = this.props.loop; | ||
var _viewWidth = this.data._viewWidth; | ||
var viewWidth = this.data.viewWidth; | ||
var showMarqueeWidth = '0px'; | ||
if (loop) { | ||
showMarqueeWidth = "".concat(_viewWidth, "px"); | ||
showMarqueeWidth = "".concat(viewWidth, "px"); | ||
} | ||
var _marqueeStyle = "transform: translate3d(".concat(showMarqueeWidth, ", 0, 0); transition: 0s all linear;"); | ||
var marqueeStyle = "transform: translate3d(".concat(showMarqueeWidth, ", 0, 0); transition: 0s all linear;"); | ||
this.setData({ | ||
_marqueeStyle: _marqueeStyle, | ||
marqueeStyle: marqueeStyle, | ||
}); | ||
@@ -102,11 +100,11 @@ }, | ||
var leading = 500; | ||
var _a = this.data, _duration = _a._duration, _overflowWidth = _a._overflowWidth, _viewWidth = _a._viewWidth; | ||
var marqueeScrollWidth = _overflowWidth; | ||
var _a = this.data, duration = _a.duration, overflowWidth = _a.overflowWidth, viewWidth = _a.viewWidth; | ||
var marqueeScrollWidth = overflowWidth; | ||
if (loop) { | ||
marqueeScrollWidth = _overflowWidth + _viewWidth; | ||
marqueeScrollWidth = overflowWidth + viewWidth; | ||
} | ||
var _marqueeStyle = "transform: translate3d(".concat(-marqueeScrollWidth, "px, 0, 0); transition: ").concat(_duration, "s all linear ").concat(typeof leading === 'number' ? "".concat(leading / 1000, "s") : '0s', ";"); | ||
if (this.data._marqueeStyle !== _marqueeStyle) { | ||
var marqueeStyle = "transform: translate3d(".concat(-marqueeScrollWidth, "px, 0, 0); transition: ").concat(duration, "s all linear ").concat(typeof leading === 'number' ? "".concat(leading / 1000, "s") : '0s', ";"); | ||
if (this.data.marqueeStyle !== marqueeStyle) { | ||
this.setData({ | ||
_marqueeStyle: _marqueeStyle, | ||
marqueeStyle: marqueeStyle, | ||
}); | ||
@@ -118,13 +116,12 @@ } | ||
var loop = this.props.loop; | ||
var trailing = 800; | ||
var trailing = 200; | ||
if (loop) { | ||
setTimeout(function () { | ||
_this.resetMarquee(); | ||
_this._measureText(_this.startMarquee.bind(_this)); | ||
}, typeof trailing === 'number' ? trailing : 0); | ||
_this.measureText(_this.startMarquee.bind(_this)); | ||
}, trailing); | ||
} | ||
}, | ||
_measureText: function (callback) { | ||
measureText: function (callback) { | ||
var _this = this; | ||
if (callback === void 0) { callback = noop; } | ||
var fps = 40; | ||
@@ -142,13 +139,13 @@ var loop = this.props.loop; | ||
// eslint-disable-next-line max-len | ||
var _overflowWidth = (ret && ret[0] && ret[1] && (ret[0].width - ret[1].width)) || 0; | ||
var _viewWidth = ((_a = ret[1]) === null || _a === void 0 ? void 0 : _a.width) || 0; | ||
var marqueeScrollWidth = _overflowWidth; | ||
var overflowWidth = (ret && ret[0] && ret[1] && (ret[0].width - ret[1].width)) || 0; | ||
var viewWidth = ((_a = ret[1]) === null || _a === void 0 ? void 0 : _a.width) || 0; | ||
var marqueeScrollWidth = overflowWidth; | ||
if (loop) { | ||
marqueeScrollWidth = _overflowWidth + _viewWidth; | ||
marqueeScrollWidth = overflowWidth + viewWidth; | ||
} | ||
if (_overflowWidth > 0) { | ||
if (overflowWidth > 0) { | ||
_this.setData({ | ||
_overflowWidth: _overflowWidth, | ||
_viewWidth: _viewWidth, | ||
_duration: (marqueeScrollWidth / fps), | ||
overflowWidth: overflowWidth, | ||
viewWidth: viewWidth, | ||
duration: (marqueeScrollWidth / fps), | ||
}); | ||
@@ -160,46 +157,3 @@ callback(); | ||
}, | ||
_startAnimation: function () { | ||
var _this = this; | ||
if (this._marqueeTimer) { | ||
clearTimeout(this._marqueeTimer); | ||
} | ||
var loop = false; | ||
var leading = 500; | ||
var trailing = 800; | ||
var fps = 40; | ||
var TIMEOUT = 1 / fps * 1000; | ||
var isLeading = this.data._animatedWidth === 0; | ||
var timeout = isLeading ? leading : TIMEOUT; | ||
var animate = function () { | ||
var _overflowWidth = _this.data._overflowWidth; | ||
var _animatedWidth = _this.data._animatedWidth + 1; | ||
var isRoundOver = _animatedWidth > _overflowWidth; | ||
if (isRoundOver) { | ||
if (loop) { | ||
_animatedWidth = 0; | ||
} | ||
else { | ||
return; | ||
} | ||
} | ||
if (isRoundOver && trailing) { | ||
_this._marqueeTimer = setTimeout(function () { | ||
_this.setData({ | ||
_animatedWidth: _animatedWidth, | ||
}); | ||
_this._marqueeTimer = setTimeout(animate, TIMEOUT); | ||
}, trailing); | ||
} | ||
else { | ||
_this.setData({ | ||
_animatedWidth: _animatedWidth, | ||
}); | ||
_this._marqueeTimer = setTimeout(animate, TIMEOUT); | ||
} | ||
}; | ||
if (this.data._overflowWidth !== 0) { | ||
this._marqueeTimer = setTimeout(animate, timeout); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -58,1 +58,21 @@ import { IBaseProps } from '../_base'; | ||
export declare const NoticeBarDefaultProps: Partial<INoticeBarProps>; | ||
export type INoticeBarData = { | ||
show: boolean; | ||
marqueeStyle: string; | ||
animatedWidth: number; | ||
overflowWidth: number; | ||
duration: number; | ||
viewWidth: number; | ||
} | ||
export type INoticeBarMethods = { | ||
resetState: () => void; | ||
showError: () => void; | ||
onTap: () => void; | ||
onActionTap: (e: any) => void; | ||
resetMarquee: () => void; | ||
startMarquee: () => void; | ||
onTransitionEnd: () => void; | ||
measureText: (fn: (...args: any[]) => void) => void; | ||
} |
@@ -7,20 +7,22 @@ "use strict"; | ||
data: { | ||
classNames: '', | ||
supportSjs: my.canIUse('sjs.event'), | ||
closing: false, | ||
}, | ||
deriveDataFromProps: function (nextProps) { | ||
var classNames = [ | ||
nextProps.className || '', | ||
nextProps.disableScroll ? 'amd-popup-disable-scroll' : '', | ||
nextProps.animation ? 'amd-popup-animation' : '', | ||
]; | ||
this.setData({ | ||
classNames: classNames.join(' ').trim(), | ||
}); | ||
didUpdate: function (prevProps) { | ||
var _a = this.props, visible = _a.visible, duration = _a.duration, animation = _a.animation; | ||
if (prevProps.visible && !visible) { | ||
if (animation && duration > 0) { | ||
this.setData({ closing: true }); | ||
} | ||
} | ||
}, | ||
methods: { | ||
onMaskClose: function () { | ||
var _a = this.props, onClose = _a.onClose, maskClosable = _a.maskClosable; | ||
var closing = this.data.closing; | ||
if (closing) { | ||
return; | ||
} | ||
var maskClosable = this.props.maskClosable; | ||
if (maskClosable) { | ||
onClose === null || onClose === void 0 ? void 0 : onClose(); | ||
this.onClose(); | ||
} | ||
@@ -31,6 +33,12 @@ }, | ||
if (onClose) { | ||
onClose === null || onClose === void 0 ? void 0 : onClose(); | ||
onClose(); | ||
} | ||
}, | ||
onAnimationEnd: function () { | ||
var closing = this.data.closing; | ||
if (closing) { | ||
this.setData({ closing: false }); | ||
} | ||
}, | ||
}, | ||
}); |
@@ -30,3 +30,15 @@ import { IBaseProps } from '../_base'; | ||
showCloseIcon?: boolean; | ||
/** | ||
* @desciption 是否开启过渡动画 | ||
*/ | ||
animation?: boolean; | ||
/** | ||
* @description 弹窗展示时,是否禁止页面滚动 | ||
*/ | ||
disableScroll?: boolean; | ||
/** | ||
* @description 过渡动画时长,单位毫秒 | ||
*/ | ||
duration?: number; | ||
} | ||
export declare const PopupDefaultProps: Partial<IPopupProps>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
@@ -9,2 +10,3 @@ var props_1 = require("./props"); | ||
var tabsStore_1 = require("../_util/tabsStore"); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
var canSwipeable = my.canIUse('swiper.disable-touch'); | ||
@@ -196,3 +198,3 @@ var component2 = my.canIUse('component2'); | ||
if (onChange) { | ||
return onChange((_d = e.detail) === null || _d === void 0 ? void 0 : _d.current); | ||
return onChange((_d = e.detail) === null || _d === void 0 ? void 0 : _d.current, (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -245,3 +247,3 @@ }, | ||
this.currentLeft = (_d = e === null || e === void 0 ? void 0 : e.currentTarget) === null || _d === void 0 ? void 0 : _d.offsetLeft; | ||
return onChange(index); | ||
return onChange(index, (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -248,0 +250,0 @@ }, |
{ | ||
"component": true | ||
"component": true, | ||
"usingComponents": { | ||
"badge": "../Badge/index" | ||
} | ||
} |
@@ -84,3 +84,3 @@ | ||
*/ | ||
stickyTop?: boolean; | ||
stickyTop?: string | number; | ||
@@ -87,0 +87,0 @@ /** |
@@ -10,2 +10,3 @@ "use strict"; | ||
data: { | ||
id: '', | ||
fileList: [], | ||
@@ -15,18 +16,37 @@ playVideoUrl: '', | ||
didMount: function () { | ||
var _a = this.props, value = _a.value, id = _a.id; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.videoContext = my.createVideoContext(id || 'myVideo'); | ||
this.videoContext = my.createVideoContext("video_".concat(this.$page.$id, "_").concat(this.$id)); | ||
this.setData({ | ||
fileList: value | ||
id: "video_".concat(this.$page.$id, "_").concat(this.$id) | ||
}); | ||
this.handleValue(); | ||
}, | ||
didUpdate: function (prevProps) { | ||
if (!(0, fast_deep_equal_1.default)(prevProps.value, this.props.value)) { | ||
this.setData({ | ||
fileList: this.props.value | ||
}); | ||
this.handleValue(); | ||
} | ||
}, | ||
methods: { | ||
handleValue: function () { | ||
var curValue; | ||
var value = this.props.value; | ||
if (typeof value === 'string') { | ||
curValue = [].concat(value); | ||
} | ||
else if (Array.isArray(value) && | ||
value.length && | ||
value.some(function (v) { return typeof v === 'string'; })) { | ||
curValue = value.map(function (v) { return (typeof v === 'string' ? { | ||
url: v, | ||
status: 'done' | ||
} : v); }); | ||
} | ||
else { | ||
curValue = value; | ||
} | ||
this.setData({ | ||
fileList: curValue | ||
}); | ||
}, | ||
onChooseVideo: function () { | ||
@@ -33,0 +53,0 @@ return tslib_1.__awaiter(this, void 0, void 0, function () { |
@@ -37,3 +37,3 @@ import { IBaseProps } from '../_base'; | ||
*/ | ||
value?: File[]; | ||
value?: Array<File | string> | string; | ||
@@ -69,6 +69,2 @@ /** | ||
/** | ||
* @description video播放器标识 | ||
*/ | ||
id: string; | ||
/** | ||
* @description 上传视频的最大数量 | ||
@@ -100,3 +96,3 @@ * @default 1 | ||
*/ | ||
onAfterUpload?: (res) => string | void | Promise<string | void>; | ||
onAfterUpload?: (res) => string | void | Promise<string | void>; | ||
@@ -103,0 +99,0 @@ /** |
{ | ||
"name": "antd-mini-rpx", | ||
"version": "0.0.21-alpha.1", | ||
"version": "0.0.21-beta.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "minidev dev --no-source-map", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
594388
515
10862