我编写了一个方法,该方法将容器滚动到其中的一个元素,但将该元素保留在视图的中间。它看起来是这样的: // Function for scrolling to an element, and placing it in the middle of the view
// By default, the container parameter is set to the browser window
function scrollIntoViewMiddle(element, container) {
if (container === undefined) {
cont
这个scrollBy函数在中工作,但是火狐和Opera忽略了它。有人能帮助解决这个问题吗?
function scrollLeft(s){
document.frames['my_iframe'].scrollBy(-s,0);
window.frames['my_iframe'].scrollBy(-s,0);
}
function scrollRight(s){
document.frames['my_iframe'].scrollBy(s,0);
window.frames['my_iframe'].scrollBy(s,
我无法为我的角形找到一个可行的解决办法。基本上,我希望在我的表单被成功捕获后自动回滚到顶部。
我能够捕获提交和重置表单,但有一些困难,试图滚动回顶部后,重新设置。
这是我account-payable.component.ts中的account-payable.component.ts函数
onSubmit() {
this.submitted = true;
// stop here if form is invalid
if (this.accountPayableForm.invalid) {
return;
}
this.load
也许你在现场测试中遇到了类似的问题…
在测试执行期间,我收到来自控制台的信息,该元素无法滚动到视图中。我发现可能使用java脚本执行器就是解决方案。这是一个下拉列表。
有2个onclick,对应2个动作阶段,都包含动态数:
onclick="selector('phone_dynamicnumberlike98046454')" - general
onclick="pick('phone_dynamicnumberlike454674645',event)" - choose the type from dropdown
因此,
我在我的页面顶部有一个固定的div,并在页面下方有一个链接列表。有一个用户可以单击的链接运行onclick:
function setOffset(){
location.hash = offset; //where offset is some number I want as the hash
scrollTo(0, 40);
}
我想要发生的是跳转到散列链接,然后滚动额外的40,将项目带到视图中,并从固定的div下移出。问题是scrollTo会跳到页面的顶部并杀死散列。有谁有什么想法吗?
在Google中,element.scrollIntoView()与behavior: 'smooth'不同时在多个容器上工作。一旦在一个容器上触发平滑滚动,第二个容器就停止滚动。在Firefox中,这个问题并不存在;这两个容器可以同时滚动。
我的解决办法是使用behavior: 'instant',但我喜欢使用behavior: 'smooth'来获得更好的用户体验。
示例
是使用角度的柱塞
html
<p>
In Google Chrome element.scrollIntoView() with behavior '