- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚发现 Barba.js 并发现它非常有用。它提供同一网站的 URL 之间的平滑转换。
我整理了一个 Plunker 由两个页面(index.html 和 about.html)组成,借助 jQuery 的 fadeIn()
和 fadeOut()
方法可以顺利加载。
$(document).ready(function() {
var transEffect = Barba.BaseTransition.extend({
start: function() {
this.newContainerLoading.then(val => this.fadeInNewcontent($(this.newContainer)));
},
fadeInNewcontent: function(nc) {
nc.hide();
var _this = this;
$(this.oldContainer).fadeOut(1000).promise().done(() => {
nc.css('visibility', 'visible');
nc.fadeIn(1000, function() {
_this.done();
});
$('html, body').animate({
scrollTop: 300
},1000);
});
}
});
Barba.Pjax.getTransition = function() {
return transEffect;
}
Barba.Pjax.start();
});
此动画的问题在于它们之间存在白屏间隔。
如何消除这个间隔,使过渡更平滑?我所说的“更平滑”是指类似于 this one (点击“查看案例”)。
最佳答案
白色屏幕是主体颜色,因为您正在使用 promise().done(..)
jquery
在之后应用 fadeIn
fadeOut
完成,主体颜色就会出现。所以,这是一个与您所拥有的类似的示例:
<style type="text/css">
.One{
width: 100%;
height: 100%;
position: absolute;
margin: 0px;
padding: 0px;
top: 0px;
left: 0px;
background-color: #476d80;
cursor: pointer;
z-index: 1;
}
.Two{
width: 100%;
height: 100%;
position: absolute;
margin: 0px;
padding: 0px;
top: 0px;
left: 0px;
background-color: #03A9F4;
cursor: pointer;
display: none;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('div.one').click(function(){
$(this).fadeOut(1000).promise().done(function(){
$('div.Two').fadeIn(1000);
});
});
});
</script>
<div class="One"></div>
<div class="Two"></div>
就像您在上面的示例中看到的那样,也会出现白屏,因此如果您不希望出现这种情况,请不要使用 promise().done(..)
。
$(document).ready(function(){
$('div.one').click(function(){
$(this).fadeOut(1000);
$('div.Two').fadeIn(1000);
});
});
您可以像这样编辑代码:
$(this.oldContainer).fadeOut(1000).promise().done(() => {
$('html, body').animate({
scrollTop: 300
},1000);
});
nc.css('visibility', 'visible');
nc.fadeIn(1000, function() {
_this.done();
});
关于jQuery:消除动画之间的白屏 "pause",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51343571/
我正在编写一个小脚本来练习使用 boost 库。 使用these header /命名空间,这是我的主要功能: int main() { ifstream inNew("../../Downloads
我正在用 SpriteKit 创建我的第一款游戏。我正在尝试暂停我的 GameScene,然后通过 SpriteKit 运行一些动画。问题是,如果我使用 self.view?.isPaused = t
我在尝试暂停倒计时器时遇到问题。我试图做到这一点,以便在单击播放按钮后,该按钮变为暂停按钮。但由于某种原因它不会暂停。 我尝试将 id“pButton”更改为“pauseButton”,这是有效的,但
在滚动更新之前,我想在我们的监控工具中为每台主机设置停机时间。我为此创建了一个自定义模块。设置停机时间时可能会出现问题,我们无法解决。在那种情况下,我想让用户选择是否应中止部署或继续部署而不设置停机时
根据 this paragraph ,以下有问题: /* usr_interrupt is set by the signal handler. */ if (!usr_interrupt)
我有一个 TThread 对象,希望能够通过程序主窗体上的按钮启动/停止线程。我一直在寻找实现这一目标的方法,到目前为止我有以下想法: 当用户单击“停止”时终止并释放线程,并在单击“开始”时创建一个新
这里我有一个方法 public static Color pickColor(){ final aero.colorpicker.Frame frame = new aero.colorpic
我在这个循环中犯了一些错误,我真的无法弄清楚。这是循环: while (true) { System.out.print(stepName[currentTick]);
我刚刚发现 Barba.js 并发现它非常有用。它提供同一网站的 URL 之间的平滑转换。 我整理了一个 Plunker 由两个页面(index.html 和 about.html)组成,借助 jQu
我写了一个程序来尝试用 C 语言编写线程,但这很奇怪 它不会陷入 while 状态(例如 while (1){}) 我尝试用 getchar、scanf 和 while(1) 暂停我的程序,但它没有停
music.pause(); 似乎在我的代码中不起作用。当我单击播放按钮(该按钮是使用 html 5 Canvas 中的框制作的)时,它可以播放音乐,但是当我单击停止按钮时,它不起作用。请帮助我。 这
我一直在用 python 3.3 编写一个基本的计算器,我希望能够在命令窗口中运行它。 但是我一读完它就关闭了窗口,我还没来得及查看最终答案。 所以我想知道是否有等效于 c++ System('PAU
考虑以下代码: 进程 A(在随机时间点): void catch(){}; // empty handler. signal(SIGCHLD,&catch); // attach empty hand
我在 x.m 中使用了函数“pause”(不带参数),但它无法挂起程序。当程序执行此功能时,它只是继续运行。 最佳答案 kbhit对我不起作用。使用 input函数帮助我解决了问题。 关于Octave
我一直在寻找一些自动的方式来编号与 biblatex 的投影机马德里同一张幻灯片上的引用文献。这适用于 \pause和 \footcite{} .但是当我在同一张幻灯片上有多个项目符号(例如 5),并
好的,所以我上周在iOS8推出之前启动了一个应用程序。在iOS7及更低版本中,一切正常。但是现在,由于人们已经更新到iOS8,我的应用程序无故暂停/崩溃。 当我将NSMutableArray设置为NS
试图在我的应用程序中放置一个“暂停”按钮,以播放一些声音片段循环播放。 当我打电话mp.pause();一切都破了,我完全迷路了! 这是我正在使用的方法。 protected void man
我已经尝试过简单的controls =“pause”代码,但是我不想显示可见的音乐播放器。我希望第二次单击“播放按钮”时出现暂停功能。 有没有办法在此代码中插入“点击暂停”功能?我不想看到一个单独的按
所以我有这样的功能: function music(song) { var audio = new Audio("audio/" + song + ".ogg"); audio.play(); } 我
当我在 Chrome 中打开异常时暂停时,它会在弹出 JavaScript 错误时正确暂停,但我看不到异常消息本身。 有什么办法可以在点击“继续”之前看到该消息吗? 注意有时可以尝试从源代码中读取它,
我是一名优秀的程序员,十分优秀!