在iOS中,下面的代码具有兽皮(之间)和scrollBy()一个明显的闪烁:jQuery显示/隐藏后执行的回调函数?
element.hide();
window.scrollBy(0, -elementHeight);
这是因为显示之间切换:无并显示:在iOS块是一个沉重的任务,因为如果元素被添加到DOM并从DOM中移除。
我需要一种方法来执行window.scrollBy()作为回调,一旦hide()成功完成并且DOM已经更新。有没有办法在jQuery中做到这一点?
在iOS中,下面的代码具有兽皮(之间)和scrollBy()一个明显的闪烁:jQuery显示/隐藏后执行的回调函数?
element.hide();
window.scrollBy(0, -elementHeight);
这是因为显示之间切换:无并显示:在iOS块是一个沉重的任务,因为如果元素被添加到DOM并从DOM中移除。
我需要一种方法来执行window.scrollBy()作为回调,一旦hide()成功完成并且DOM已经更新。有没有办法在jQuery中做到这一点?
要么经过一个时间和一个回调,或者只是传递一个回调的选项,如:
element.hide(0, some_function);
// or
element.hide({done: some_function});
默认情况下,第二个选项需要400毫秒。立即执行以下操作之一:
element.hide(0, some_function);
// or
element.hide({duration: 0, done: some_function});
See the jQuery documentation了解更多详情。
从jQuery API:
.hide(选项)
完整 类型:Function() 的函数调用一次在动画完成。
尝试这种情况:
element.hide({完成:函数(){ window.scrollBy(0,-elementHeight);});
只需阅读说明文件。 element.hide(回调); * facepalm * – user1031947 2014-09-20 21:53:19
http://stackoverflow.com/questions/7769475/jquery-show-hide-with-callback-animates-dont-want-it – nisargjhaveri 2014-09-20 21:55:20