Extjs 复选框和文本区域 - 如何禁用文本区域滚动行为的复选框?

Extjs checkbox and textarea - how to disable the checkbox on scroll behavior of the textarea?

我有一个显示一些文本的文本区域,右侧有一个垂直滚动条,文本区域下方有一个复选框,如下面的代码所示:

xtype: 'container',
items: [{
    {
        xtype: 'textarea',
        scrollY: true,
        screenX: true,
        height: 130,
        minHeight: 80,
        top: 10,
        width: 650,
        id: 'testDisplay',
        name: 'testDisplay',
        itemId: 'testDisplay',
        bind: {
            value: some text
        },
        listeners: {
            afterrender: function(cmp) {
                textAreaComp = me.down('#testDisplay');
                textAreaComp.setValue(someInfo);
            }
        },
    }, 
    {
        xtype: 'checkboxfield',
        name: 'testDisplayChkbox',
        id: 'testDisplayChkbox',
        itemId: 'testDisplayChkbox',
        checked: false,
        boxLabel: someLabel,
    }
}]

我希望首先禁用复选框,然后在滚动到位于复选框上方的文本区域末尾后启用它。如何实现?

ExtJS 中没有为此内置的侦听器。您必须在 DOM 中查找文本区域并附加一个 onscroll 事件。然后您可以检查滚动是否到达底部并启用您的复选框。 尝试以下代码以及 look at this fiddle:

Ext.create({
    renderTo: Ext.getBody(),
    xtype: 'container',
    items: [{
        xtype: 'textareafield',
        value: 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?',
        afterRender: function () {
            // get checkbox
            const myCheckBox = this.up('container').getComponent('myCheckBox');
            // add onscroll listener to textarea
            this.el.down('textarea').dom.onscroll = function () {
                // check if scrolling reached bottom
                if (this.scrollHeight <= (this.scrollTop + this.offsetHeight)) {
                    myCheckBox.setDisabled(false);
                }
            };
        }
    }, {
        xtype: 'checkboxfield',
        itemId: 'myCheckBox',
        label: 'Lorem ipsum',
        checked: false,
        disabled: true
    }]
});