我正在使用ReactCSSTransitionGroup标签列表,因此当用户删除标签时,它会淡出.我注意到有点跳跃,所以我减慢了动画转换持续时间以查看发生了什么.
标签以奇怪的方式移动,并且由于宽度不同,当它消失时看起来有点刺耳.这就是React动画的工作原理,还是我做错了什么?
这是全速(.3s)的另一个例子.
代码如下:
let ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
TagList = React.createClass({
displayName: 'TagList',
propTypes: {
tags: React.PropTypes.array,
onTagClick: React.PropTypes.func.isRequired
},
render() {
let tags;
if (!this.props.tags) {
return false;
}
tags = this.props.tags.map((tag, i) => {
return <Tag key={i}
index={i}
onTagClick={this.props.onTagClick}>{tag}</Tag>
});
return (
<div className="tag-list">
<ReactCSSTransitionGroup transitionName="tag">
{tags}
</ReactCSSTransitionGroup>
</div>
)
}
});
Tag = React.createClass({
displayName: 'Tag',
propTypes: {
onTagClick: React.PropTypes.func.isRequired
},
render() {
return (
<span className="tag"
onClick={this.props.onTagClick.bind(null, this.props.index)}>
<span className="tag-name">{this.props.children}</span>
</span>
)
}
});
Run Code Online (Sandbox Code Playgroud) 鉴于这样的事情:
const audio = React.findDOMNode(this.refs.audio);
const seeker = React.findDOMNode(this.refs.seeker);
const {left, right} = seeker.getBoundingClientRect();
const seekToPerc = (event.clientX - left) / (right - left);
audio.currentTime = this.props.totalRunTime * seekToPerc;
Run Code Online (Sandbox Code Playgroud)
这是否过度使用const?我应该let在这里使用吗?
我不太明白它的window.devicePixelRatio价值是什么,以及它如何决定我对该设备所需的尺寸图像(2x,3x等).
例如,在iMac 5K Retina(2015年末),我预计像素比率至少为3左右,但它实际上是2,与iPad Air和iPhone 6s相同.这是否意味着它更喜欢2x位图?3倍?
我注意到一些新闻网站(例如华盛顿邮报)能够弹出 Web 通知,即使我没有在选项卡中打开该网站。我不记得这在以前是可能的。如果网站没有打开,网站怎么可能执行必要的 JS?如何使用 Web 通知完成此操作,是否有特定设置来完成此操作?
我有以下类型别名:
type TestType = {
critical: string,
failProps: Object,
successProps: ?Object,
test: Function,
};
Run Code Online (Sandbox Code Playgroud)
我想更具体一点test.该功能应该是这个签名:
function (value: string): boolean { /* ... */ }
Run Code Online (Sandbox Code Playgroud)
我如何指出test应采用单个字符串参数并返回布尔值?
我通常能够很容易地解决这个错误,但这次似乎没有任何作用。
我的main.ts文件有这个:
import locale from 'element-ui/lib/locale/lang/en';
Run Code Online (Sandbox Code Playgroud)
错误:
ERROR in /Volumes/SuperData/Sites/reelcrafter/rc-ts/src/main.ts
6:20 Could not find a declaration file for module 'element-ui/lib/locale/lang/en'. '/Volumes/SuperData/Sites/reelcrafter/rc-ts/node_modules/element-ui/lib/locale/lang/en.js' implicitly has an 'any' type.
Try `npm install @types/element-ui` if it exists or add a new declaration (.d.ts) file containing `declare module 'element-ui';`
4 | import store from './store';
5 | import ElementUI from 'element-ui';
> 6 | import locale from 'element-ui/lib/locale/lang/en';
| ^
7 | import VueDragDrop from 'vue-drag-drop';
8 | import './styles/element-setup.scss';
9 | import …Run Code Online (Sandbox Code Playgroud) 我一直在浏览网络和 StackOverflow,但无法让它发挥作用。我有一个音频文件,我想将其拆分为 mp3 文件并生成相应的 m3u8 文件。
我试过这个,这是最接近的:
ffmpeg -i sometrack.wav -c:a libmp3lame -b:a 256k -map 0:0 -f segment -segment_time 10 -segment_list outputlist.m3u8 -segment_format mpegts 'output%03d.mp3'
Run Code Online (Sandbox Code Playgroud)
但是所有的mp3文件我播放的时候都是乱码。
javascript ×3
animation ×1
const ×1
ecmascript-6 ×1
element-ui ×1
ffmpeg ×1
flowtype ×1
html ×1
html5 ×1
mp3 ×1
reactjs ×1
retina ×1
typescript ×1