我有一个ListBox可能有很多行的模板化DB记录,包括一个Image,绑定到一个ObservableCollection<MyItem>.有时收藏可以容纳数千件物品.
性能很好,但滚动是默认的跳跃行为.我希望它有平滑的滚动,所以我取消选中ScrollViewer.CanContentScroll.
现在我有平滑的滚动,但性能很可怕:数据在一个单独的线程中检索,并且线程快速完成,但结果显示在中需要10-20秒ListBox.我假设这是因为取消选中ScrollViewer.CanContentScroll将底层更改VirtualizingStackPanel为常规StackPanel,因此在显示结果之前加载整个集合.
所以我的问题是:如何在不牺牲VirtualizingStackPanel行为和性能的情况下保持平滑滚动?
我正在使用MVVM模式,我有一个创建新视图的视图ViewModel,在用户单击保存后,此视图关闭并打开一个单独的视图,其中显示了一组视图模型ListView.
这ListView是按字母顺序排序的,因此新的ViewModel可能会出现在ListBox用户无法立即看到的底部.
我的问题是如何让视图自动滚动到新添加的项目?
我想它会使用附加的行为和ScrollIntoView事件ListView,但是我需要从GridView我不确定的事件中捕获哪个事件.
干杯
我有一个自定义类扩展WebView,显示HTML内容.当用户单击HTML文档中的链接时,我计算要滚动到的X值,然后使用scrollTo(x,y)通过runnable显示该位置(参见下文)
post( new Runnable() {
@Override
public void run() {
scrollTo( x, 0 );
MyWebView.this.invalidate();
MyWebView.this.buildDrawingCache();
MyWebView.this.refreshDrawableState();
MyWebView.this.postInvalidate();
}
} );
Run Code Online (Sandbox Code Playgroud)
滚动后,webview可能无法呈现整个文档.显示文本应该是的白色空间的矩形块,每次都看似随机放置.这是一个截图:http://i.imgur.com/g192Y.jpg
当我触摸webview进行滚动时,它会立即渲染缺失的部分.
到目前为止,这种行为仅限于三星Galaxy 10.1"平板电脑.
有没有人知道解决方法/如何强制webkit重新呈现页面?
如何在UIViewController中执行以下操作(包含tableview作为子视图)
我最初有一个UIViewController显示预览部分(UIView)
//Setup container for preview section
UIView *tempContainer = [[UIView alloc]initWithFrame:CGRectMake(0, 20, 320, 100)];
self.preview_answer_container = tempContainer;
self.preview_answer_container.backgroundColor = [UIColor clearColor];
[tempContainer release];
[self.view addSubview:self.preview_answer_container];
Run Code Online (Sandbox Code Playgroud)
我还在下面添加了一个UITableView(和一个搜索栏)
//setup tableview
UITableView *tempTable = [[UITableView alloc]initWithFrame:CGRectMake(0,44 ,320,self.view.frame.size.height - 44)];
self.tagFriendsTableView = tempTable;
self.tagFriendsTableView.delegate = self;
self.tagFriendsTableView.dataSource = self;
[tempTable release];
[self.view addSubview:self.tagFriendsTableView];
Run Code Online (Sandbox Code Playgroud)

使用此设置,我的滚动区域很小(仅预览部分下方的静态区域)
如何修改我的代码,以便1)我可以向上滚动整个页面,即预览部分和tableview将向上滚动2)当搜索栏到达顶部(导航栏下方)时,滚动整体将停止(参见屏幕截图),但UITableView中的内容仍然是可滚动的

编辑:
添加了UIScroll视图的代码.但是,对我来说没有任何改变.我的代码出了什么问题?
//setup scroll view
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
//Search
UISearchBar *tempBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 120 + 20, 320, 44)];
self.sBar = tempBar; …Run Code Online (Sandbox Code Playgroud) 我有一个溢出隐藏div中的元素列表.因此并非所有元素都可见.现在,如果一个元素被激活,它应该在div中可见.
如何使用jQuery滚动到活动元素?
最后一个元素具有活动类只是方便.它将动态切换.
var scrollToEl = $("div.element.active");
console.log(zoomToEl);Run Code Online (Sandbox Code Playgroud)
#main,
#sidebar {
height: 200px;
}
#wrapper {
width: 190px;
float: left;
background: grey;
overflow: auto;
overflow-x: hidden;
}
#sidebar div.element {
height: 150px;
width: 150px;
background-color: green;
margin-bottom: 10px;
}
#sidebar div.element.active {
background-color: red;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="main">
<div id="wrapper" class="sidebar">
<div id="sidebar">
<div class="element" data-slide-id="0">a
</div>
<div class="element" data-slide-id="1">b
</div>
<div class="element" data-slide-id="2">c
</div>
<div class="element" data-slide-id="3">d
</div>
<div class="element" data-slide-id="4">e
</div>
<div class="element" data-slide-id="5">f
</div>
<div class="element" …Run Code Online (Sandbox Code Playgroud)DOMMouseScroll 仅适用于Firefox.
wheel似乎适用于Firefox和Chrome.这是什么?没有找到关于这个的文档.
mousewheel 不适用于Firefox.
我应该如何使用它们,以获得最佳的浏览器兼容性.
给出的例子:
document.addEventListener('ScrollEvent', function(e){
DoSomething();
});
Run Code Online (Sandbox Code Playgroud) 我有一个容器:
scroll-snap-points-y: repeat(100%);
snap-type: mandatory;
snap-type: y mandatory;
Run Code Online (Sandbox Code Playgroud)
还有三个孩子:
height: 100%;
scroll-snap-align: center;
scroll-snap-stop: always;
Run Code Online (Sandbox Code Playgroud)
在Firefox中,该功能的运行与预期的一样,但在Chrome中似乎存在一个阈值。仅滚动少量内容时,Chrome会回到第一个孩子,而Firefox将滚动到下一个孩子。仅在滚动大约子高度的30%之后,Chrome才会捕捉到下一个高度。
此行为可以在此代码笔中看到。
有什么方法可以禁用此隐藏阈值并使Chrome立即滚动到下一个孩子吗?
我正在设置UICollectionView的内容插图:
[_collectionView setContentInset:UIEdgeInsetsMake(0.f, 0.f, 100.f, 0.f)];
Run Code Online (Sandbox Code Playgroud)
然后我用这种方法以编程方式一直滚动到UICollectionView的底部:
- (void)scrollToLastMessageAnimated:(BOOL)animated;
{
if (_messages.count == 0) { return; }
NSUInteger indexOfLastSection = _messagesBySections.count - 1;
NSInteger indexOfMessageInLastSection = [_messagesBySections[indexOfLastSection] count] - 1;
NSIndexPath *path = [NSIndexPath indexPathForItem:indexOfMessageInLastSection
inSection:indexOfLastSection];
[_collectionView scrollToItemAtIndexPath:path
atScrollPosition:UICollectionViewScrollPositionCenteredVertically
animated:animated];
}
Run Code Online (Sandbox Code Playgroud)
它向下滚动,但它忽略了contentInset,这意味着最后一个单元格低于指定的内容插入:
左侧图像显示了视图出现后现在的显示方式.在右图中,我手动向下滚动到最后一条消息.
我正在使用AutoLayout,任何想法为什么会发生这种情况?
编辑:
以下是IB设置的屏幕截图:

找到页面上滚动的所有元素的最可靠和有效的方法是什么?
目前,我正在考虑使用element.all()与filter()比较height和scrollHeight属性值:
element.all(by.xpath("//*")).filter(function (elm) {
return protractor.promise.all([
elm.getAttribute("height"),
elm.getAttribute("scrollHeight")
]).then(function (heights) {
return heights[1] > heights[0];
});
});
Run Code Online (Sandbox Code Playgroud)
但我不确定这种方法的正确性和性能.
我正在以编程方式向recyclerview位置0添加一个项目
public void addQuestion(Question question){
this.questionList.add(0, question);
notifyItemInserted(0);
}
Run Code Online (Sandbox Code Playgroud)
这项工作非常好,项目确实出现在顶部的列表中,但用户必须向上滚动才能看到新项目.
是否有任何技巧如何项目出现在顶部,Recyclerview自动滚动?
scroll ×10
javascript ×3
android ×2
ios ×2
wpf ×2
add ×1
autolayout ×1
c# ×1
css ×1
events ×1
jquery ×1
listbox ×1
listview ×1
mvvm ×1
objective-c ×1
performance ×1
protractor ×1
render ×1
selenium ×1
uiscrollview ×1
uitableview ×1
webkit ×1
webview ×1