在实现react-reveal时,我遇到了一个奇怪的问题.如果在向下滚动页面时动画未运行,直到停止然后动画按预期运行,会发生什么.有没有人有过这个问题的经验?提前干杯
履行
所以我只是简单地制作了一个渐变的div组件
class FadingDiv extends Component {
...
render() {
return (
<Fade>
<div className={this.props.className}>
{children}
</div>
</Fade>
)
}
}
Run Code Online (Sandbox Code Playgroud)
然后简单地将div标签切换到FadingDiv我想要实现效果的位置.这适用于safari和firefox,但是(令人惊讶的)chrome给了我一些问题.任何帮助都将受到大力赞赏,我感觉到了赏金.
所以我试图在我的投资组合网站上为一些文本实现悬停状态动画.简而言之,文本需要从黑色或白色(可以改变),白色到蓝色动画.
我尝试过使用以下内容
@keyframes textAnimation {
0% {
color: inherit
}
50% {
color: white
}
100% {
color: blue
}
}
Run Code Online (Sandbox Code Playgroud)
但是,因为它是一个悬停动画 - 如果我停止悬停,动画会切换并恢复到之前的值.我有一个伴随动画(Purely CSS)与悬停一起使用,所以我需要它基本上将动画反转回原始值.
我也试过在<span>使用中添加类setTimeout...但是这是一个非常密集的页面,从过去的经验来看,以这种方式混合JS + CSS - 并且时间很完美 - 在低端是超级难的机器.
PS我正在使用React.js
任何想法将不胜感激.
所以我有一个从右侧滑出的汉堡菜单,我想把我的菜单滑开<div>,以防止重叠(它们的不透明度都<1,所以看起来很奇怪)。
无论如何,我在使用以下代码时使用jQuery更改left + right值,转换效果很好
transition: all .3s ease-in-out;
-webkit-transition: all .3s ease-in-out;
Run Code Online (Sandbox Code Playgroud)
但是,我还为正在移动的 div 使用了淡入淡出动画,并且由于某种原因正在触发。基本上是闪烁,然后在进入屏幕时慢慢淡入。所以,我想做如下事情:
transition: left .3s ease-in-out;
-webkit-transition: left .3s ease-in-out;
transition: right .3s ease-in-out;
-webkit-transition: right .3s ease-in-out;
Run Code Online (Sandbox Code Playgroud)
结果:右侧按预期工作,但左侧只是跳转到新位置,而右侧仍在动画中。知道我做错了什么吗?这是整个 css 类
aboutScreen{
position: absolute;
text-align: center;
height: 100%;
top: 0;
left: 150px;
right: 150px;
background-color: rgba(0, 0, 0,0.7);
transition: left .3s ease-in-out;
-webkit-transition: left .3s ease-in-out;
transition: right .3s ease-in-out;
-webkit-transition: right .3s ease-in-out;
}
Run Code Online (Sandbox Code Playgroud)
注意:如果你想要 JQuery,请告诉我
我正在使用动画,以便弹出窗口从右侧进入.我正在使用以下代码 -
var toValue = 200;
if(this.state.fileMenu){
toValue = 0;
}
Animated.spring(
this.state.bounceValue,
{
toValue: toValue,
velocity: 3,
tension: 2,
friction: 5,
}
).start();
//I want to call a function here after the animation is finished.
this.setState({fileMenu: !this.state.fileMenu});
Run Code Online (Sandbox Code Playgroud)
代码工作得很好,看起来很棒,但是,我现在想要只在动画完成时调用一个函数,并且严格只调用一次.只是想知道我怎么能这样做?不确定这是否是一个非常简单的问题.
我正在为单人作业制作扑克游戏,我想知道是否有任何一种方法可以执行以下操作(注意:非常粗略地编写了代码)
JTextArea textArea = new JTextArea();
public void printer(String s){
//I want to delay here, for 2 seconds each time i print to the jtextarea
textArea.append(s);
}
public void runGame(){
printer("Dealing cards...");
//I want to delay to add to an effect of the time it takes to actually deal the cards
pokerHand.setVisibility(true);
printer("What you like to do?");
//
//Code here containing running the game
//
printer("Daniel Negreanu folds");
//I want to have a delay here for the time it takes …Run Code Online (Sandbox Code Playgroud) 我正在制作一个语言翻译应用程序,我有以下代码
var setInputLang = (item) => {
this.state.inputLang= item;
this.inputLangPic = //code here;
}
///This is called within a view in my render function
<TouchableOpacity //Code here to set country >
<Image
source = {require('../img/flags/png/india.png')}
style = {{flex: 0.33, height: 50, margin:10}}
/>
</TouchableOpacity>
Run Code Online (Sandbox Code Playgroud)
基本上,我希望能够在按下图像时将输入语言的图片路径设置为正在按下的任何图像
我有多个标志可供选择,并且存储 inputLang 需要为所有这些工作。这就是我打算做的
this.inputLangPic = {require('../img/flags/' + inputLang + '.png')}
Run Code Online (Sandbox Code Playgroud)
这不起作用,我想知道如何做到这一点?当前代码给了我一个错误提示“未知命名模块:'../img/flags/png/india.png',这很奇怪,因为我之前用过它来生成图像并且它工作得很好
提前致谢
编辑:另外,我将如何将变量从可触摸不透明度传递到 inputLang 中?我已将其标记为“//此处设置国家/地区的代码”
所以我从网络套接字连接接收文本,并将其添加到文本组件。它从灰色开始,然后在 x 时间后变成黑色(应用程序处理文本)。我有下面的代码
<Text style={styles.confirmedText}>
{this.state.confirmedText}
<Animated.Text style={{ fontFamily: "Helvetica Neue", color: "#9b9b9b" }}>
{this.state.tempText}
</Animated.Text>
</Text>
Run Code Online (Sandbox Code Playgroud)
所以这tempText是不断变化的,但我希望当文本从空字符串变为淡入动画时 -> 一些/任何文本。任何想法我怎么能做到这一点?
注意:我知道我的代码没有尝试实现这一点,但我无法使用 Animated.Text 找到任何工作示例。
提前致谢,
编辑:更好的是,如果 temp 的值是 say“some text”,并且添加了一个词,例如“some text plus”,那么添加的单独动画的词“plus”会很棒。虽然看起来很难