标签: scroll

Jetpack 编写代码以在单击文本时向下滚动到特定 UI 元素的位置

我试图在单击文本时向下滚动到特定 UI 元素的位置。

我的文本的代码是:

                Text(
                "What is autosaving?",
                color = colorResource(id = R.color.text_highlight),
                fontSize = with(LocalDensity.current) {
                    dimensionResource(id = R.dimen._11ssp).toSp()
                },
                fontFamily = FontFamily(
                    Font(R.font.poppins_regular)
                ),
                modifier = Modifier.constrainAs(whatIsAutosaving) {
                    top.linkTo(glWhatIsAutoSaving)
                    start.linkTo(parent.start)
                    end.linkTo(parent.end)
                },
            )
Run Code Online (Sandbox Code Playgroud)

单击此文本后,我的屏幕应滚动到另一个文本的开始位置。另一个文本的代码是:

        Text(
        stringResource(id = R.string.autosave_info),
        color = colorResource(id = R.color.bright_green),
        fontSize = with(LocalDensity.current) {
            dimensionResource(id = R.dimen._11ssp).toSp()
        },                fontFamily = FontFamily(
            Font(R.font.poppins_regular)
        ),
        modifier = Modifier.constrainAs(autoSaveInfo) {
            top.linkTo(glAutoSaveInfo)
            start.linkTo(glLeft)
            end.linkTo(glRight)
            width = Dimension.fillToConstraints
        },
    )
Run Code Online (Sandbox Code Playgroud)

我该如何实现这一目标?

编辑:

我的屏幕的完整代码是:

@Composable
fun Autosave(navController: NavController) {
    val query …
Run Code Online (Sandbox Code Playgroud)

android scroll android-jetpack-compose android-jetpack-compose-layout android-compose-layout

25
推荐指数
1
解决办法
2万
查看次数

如何通过C#中的代码向下滚动文本框

我正在使用winforms,我偶尔会更新一个文本框(显示消息).但是,当文本到达框的末尾时,它会生成滚动条,我不知道如何向下滚动到底部.我唯一看到的是ScrollToCaret,但Caret正处于文本的开头.滚动的命令是什么?

c# scroll textbox winforms

24
推荐指数
3
解决办法
4万
查看次数

Android:滚动Imageview

我的ImageView是普通屏幕高度的两倍(960倾角).我想在屏幕上上下滚动它.屏幕底部应包含一个按钮.我尝试过ScrollView和Imageview的各种组合,没有任何成功.我还使用:isScrollContainer属性进行了细化而没有结果.谁知道怎么做?干杯,卢卡

android scroll imageview

24
推荐指数
5
解决办法
9万
查看次数

ScrollView根本不滚动

我无法正确滚动ScrollView.它总是切断底部的内容,就像它是正常的LinearLayout一样.

我的代码

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" >

    <LinearLayout android:id="@+id/scroll_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:isScrollContainer="true"
        android:orientation="vertical" >
Run Code Online (Sandbox Code Playgroud)

当然,我已经尝试添加/删除"fillViewport"和"isScrollContainer"属性,它根本没有改变任何东西.

提前致谢.

android scroll android-linearlayout android-scrollview

24
推荐指数
3
解决办法
4万
查看次数

滚动到页面上的特定元素

我想在页面的开头有4个按钮/链接,在它们下面有内容.

在按钮上我把这个代码:

<a href="#idElement1">Scroll to element 1</a>
<a href="#idElement2">Scroll to element 2</a>
<a href="#idElement3">Scroll to element 3</a>
<a href="#idElement4">Scroll to element 4</a>
Run Code Online (Sandbox Code Playgroud)

在链接下将有内容:

<h2 id="idElement1">Element1</h2>
content....
<h2 id="idElement2">Element2</h2>
content....
<h2 id="idElement3">Element3</h2>
content....
<h2 id="idElement4">Element4</h2>
content....
Run Code Online (Sandbox Code Playgroud)

它现在正在工作,但不能让它看起来更顺畅.

我使用了这段代码,却无法使用它.

$('html, body').animate({
    scrollTop: $("#elementID").offset().top
}, 2000);
Run Code Online (Sandbox Code Playgroud)

有什么建议?谢谢.

编辑:和小提琴:http://jsfiddle.net/WxJLx/2/

javascript jquery animation scroll jquery-animate

24
推荐指数
8
解决办法
7万
查看次数

jquery : detecting scroll position

I want to get an alert when, while scrolling, my footer comes to view.

$(window).on("mousewheel", function(){
    if ($(window).scrollTop() + $(window).height() > $('#footer').position().top){    
        alert("footer visible");
    }  
    else{
        alert("footer invisible");  
    }
});
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/JRUnr/10/

All conditions with height seem right, but not during scrolling.

javascript jquery scroll footer

24
推荐指数
1
解决办法
5万
查看次数

使用jQuery同步滚动?

我正在尝试DIV使用以下代码实现两个同步滚动.

DEMO

$(document).ready(function() {
    $("#div1").scroll(function () { 
        $("#div2").scrollTop($("#div1").scrollTop());
    });
    $("#div2").scroll(function () { 
        $("#div1").scrollTop($("#div2").scrollTop());
    });
});
Run Code Online (Sandbox Code Playgroud)

#div1#div2比方说,它具有相同的内容但不同的大小

#div1 {
 height : 800px;
 width: 600px;
}
#div1 {
 height : 400px;
 width: 200px;
}
Run Code Online (Sandbox Code Playgroud)

有了这段代码,我面临两个问题.

1)滚动没有很好地同步,因为div具有不同的大小.我知道,这是因为,我直接设定了scrollTop价值.我需要找到滚动内容的百分比并scrollTop为另一个计算相应的值div.我不确定,如何找到实际的高度和当前滚动位置.

2)此问题仅在firefox.在Firefox中,滚动不像其他浏览器那样流畅.我认为这是因为上面的代码创建了一个无限循环的滚动事件.我不确定,为什么这只发生在firefox上.有没有办法找到滚动事件的来源,以便我可以解决这个问题.

任何帮助将不胜感激.

javascript css jquery scroll

24
推荐指数
1
解决办法
2万
查看次数

Angularjs:滚动到达div中滚动条底部时如何触发事件?

我正在尝试在滚动条到达结束时触发事件.我发现了这个例子.这是我的代码.问题是它根本不调用loadmore().控制台声明的值为:

848
899
in scroll
881
899
in scroll
892
899
in scroll
897
899
in scroll
900
899
Run Code Online (Sandbox Code Playgroud)

似乎它永远不会发生如果声明!奇怪的是,如果我在inspect元素中调试它,那么它会触发事件......我的指示:

directive('scrolly', function () {
    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            var raw = element[0];
            console.log('loading directive');
            element.bind('scroll', function () {
                console.log('in scroll');
                console.log(raw.scrollTop + raw.offsetHeight);
                console.log(raw.scrollHeight);
                if (raw.scrollTop + raw.offsetHeight == raw.scrollHeight) { //at the bottom
                    scope.$apply(attrs.scrolly);
                }
            })
        }
    }
Run Code Online (Sandbox Code Playgroud)

events scroll angularjs

24
推荐指数
3
解决办法
4万
查看次数

ELK:如何在Elastic-search中检索超过10000个结果/事件

问题: 在GET /搜索查询中通过搜索检索弹性搜索超过10,000个结果.

GET hostname:port /myIndex/_search { 
    "size": 10000,
    "query": {
        "term": { "field": "myField" }
    }
}
Run Code Online (Sandbox Code Playgroud)

我一直在使用size选项知道:

index.max_result_window = 100000

但是,如果我的查询大小为650,000个文档,或者甚至更多,我如何在一个GET中检索所有结果?

我一直在阅读有关SCROLL,FROM-TO和PAGINATION API的信息,但它们都不会超过10K.

这是Elasticsearch论坛的例子,我一直在使用:

GET /_search?scroll=1m
Run Code Online (Sandbox Code Playgroud)

任何人都可以提供一个示例,您可以在其中检索GET搜索查​​询的所有文档吗?

非常感谢你.

pagination scroll get resultset elasticsearch

24
推荐指数
4
解决办法
3万
查看次数

无法阻止iOS上滚动窗口的"touchmove"

我们正在尝试在我们的iOS网络应用上滚动元素,同时防止窗口本身滚动.我们正在touchmove窗口上捕获事件,以编程方式滚动元素并(尝试)通过调用preventDefault事件来阻止窗口本身滚动.

不幸的是,这在Mobile Safari中不起作用.窗口继续在我们的元素下滚动.问题听起来与https://bugs.webkit.org/show_bug.cgi?id=163207中描述的Webkit错误完全相同,但该问题在iOS 10.3中已得到修复,而我运行的是11.3.

捕获touchforcestart和调用preventDefault似乎确实阻止了窗口的滚动,但是我们正在调用它touchstart,因为窗口仍然滚动,这似乎"太晚了".滚动仅在下次touchstart调用时被阻止.

关于发生了什么的任何想法?我们感到困惑,因为这显然是一个错误,但它似乎已经修复了一段时间.

scroll mobile-safari ios preventdefault touchmove

24
推荐指数
2
解决办法
2万
查看次数