什么会使 Meteor 应用程序停止滚动?
What would make a Meteor app stop scrolling?
任何浏览器。所有其他功能都正常运行。我可以遍历路线、打开模式、下拉菜单、操作集合……一切正常。
但在某些时候,浏览器将不再滚动。在任何观点。除非我刷新浏览器window。然后滚动恢复正常。
这可能是什么原因造成的?为什么刷新页面可以解决问题?有没有办法把反应性颠倒过来?
这可能是由于离开了 (Bootstrap ?) 模式而没有正确关闭它。
当您在 HTML5 框架中显示模式时,它们通常会显示背景(某种全屏灰色组件)并禁用滚动以模拟桌面体验。
您可以使用简单的 iron:router
模式解决此问题,如果您不使用此包,请确保在您离开可能显示模式的页面时执行相应的代码。
client/views/modal/modal.html
<template name="modal">
<div id="modal" class="modal fade">
...
</div>
</template>
<template name="main">
{{> modal}}
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal">
Show Modal
</button>
</template>
client/config/router.js :
// define the plugin
Iron.Router.plugins.hideBootstrapModalOnStop=function(router,options){
router.onStop(function(){
// hide modal backdrop on route change
$(".modal-backdrop").remove();
// remove modal-open state on body
$("body").removeClass("modal-open");
});
};
// activate the plugin
Router.plugin("hideBootstrapModalOnStop");
在 HTML 正文标签上设置的 .modal-open
class 是在设置时禁用滚动的标签,因此请确保我们在任何时候删除 class当可能显示模式时,我们离开页面,我们防止这种奇怪的意外行为发生。
任何浏览器。所有其他功能都正常运行。我可以遍历路线、打开模式、下拉菜单、操作集合……一切正常。
但在某些时候,浏览器将不再滚动。在任何观点。除非我刷新浏览器window。然后滚动恢复正常。
这可能是什么原因造成的?为什么刷新页面可以解决问题?有没有办法把反应性颠倒过来?
这可能是由于离开了 (Bootstrap ?) 模式而没有正确关闭它。
当您在 HTML5 框架中显示模式时,它们通常会显示背景(某种全屏灰色组件)并禁用滚动以模拟桌面体验。
您可以使用简单的 iron:router
模式解决此问题,如果您不使用此包,请确保在您离开可能显示模式的页面时执行相应的代码。
client/views/modal/modal.html
<template name="modal">
<div id="modal" class="modal fade">
...
</div>
</template>
<template name="main">
{{> modal}}
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal">
Show Modal
</button>
</template>
client/config/router.js :
// define the plugin
Iron.Router.plugins.hideBootstrapModalOnStop=function(router,options){
router.onStop(function(){
// hide modal backdrop on route change
$(".modal-backdrop").remove();
// remove modal-open state on body
$("body").removeClass("modal-open");
});
};
// activate the plugin
Router.plugin("hideBootstrapModalOnStop");
在 HTML 正文标签上设置的 .modal-open
class 是在设置时禁用滚动的标签,因此请确保我们在任何时候删除 class当可能显示模式时,我们离开页面,我们防止这种奇怪的意外行为发生。