在我的移動Safari瀏覽器的項目,我需要建立一個信息發佈功能。當文本行超過文本區域的最大行時,它需要在文本區域內滾動。我無法在Ext.field.textarea中找到'可滾動'屬性,任何想法如何? 乾杯!Sencha Touch 2.0 - 如何在移動Safari的textarea中設置滾動?
1
A
回答
3
有聯繫2.0.x的一個bug使得框架明確地防止滾動操作。據說一個修補程序將在2.1,雖然我沒有正式看到,只是從一個論壇上的人。
在此之前,有一種用於touch1解決這裏http://www.sencha.com/forum/showthread.php?180207-TextArea-scroll-on-iOS-not-working,你可以移植到V2。它基本上包括將一個事件偵聽到實際textarea的領域(不是煎茶對象),然後調用了preventDefault如果它是一個有效的表示ScrollEvent。
完整的代碼是在那個環節,但突出的位都在這裏。
抓住< textarea的>字段(不是煎茶觸摸對象)直接使用addListener申請 'handleTouch' 上touchstart和 'handleMove' 上touchmove
handleTouch: function(e) {
this.lastY = e.pageY;
},
handleMove: function(e) {
var textArea = e.target;
var top = textArea.scrollTop <= 0;
var bottom = textArea.scrollTop + textArea.clientHeight >= textArea.scrollHeight;
var up = e.pageY > this.lastY;
var down = e.pageY < this.lastY;
this.lastY = e.pageY;
// default (mobile safari) action when dragging past the top or bottom of a scrollable
// textarea is to scroll the containing div, so prevent that.
if((top && up) || (bottom && down)) {
e.preventDefault();
e.stopPropagation(); // this tops scroll going to parent
}
// Sencha disables textarea scrolling on iOS by default,
// so stop propagating the event to delegate to iOS.
if(!(top && bottom)) {
e.stopPropagation(); // this tops scroll going to parent
}
}
0
Ext.define('Aspen.util.TextArea', {
override: 'Ext.form.TextArea',
adjustHeight: Ext.Function.createBuffered(function (textarea) {
var textAreaEl = textarea.getComponent().input;
if (textAreaEl) {
textAreaEl.dom.style.height = 'auto';
textAreaEl.dom.style.height = textAreaEl.dom.scrollHeight + "px";
}
}, 200, this),
constructor: function() {
this.callParent(arguments);
this.on({
scope: this,
keyup: function (textarea) {
textarea.adjustHeight(textarea);
},
change: function (textarea, newValue) {
textarea.adjustHeight(textarea);
}
});
}
});
相關問題
- 1. 使用拖動事件來移動Sencha Touch 2.0中的滾動條
- 2. 字段設置不在sencha touch中滾動
- 3. 你如何防止移動safari上textarea的頁面滾動
- 4. 在Sencha Touch中滾動問題
- 5. 問題在sencha touch中滾動div
- 6. Sencha Touch移動平臺
- 7. Parse.com Sencha Touch 2.0
- 8. 如何在Sencha Touch 2.0中清除Cookies
- 9. 如何設置lwuit textarea滾動爲false
- 10. fieldset動態設置值sencha touch 2.2
- 11. 2 Sencha Touch中的滾動列表不滾動
- 12. Sencha Touch在PhoneGap webview中呈現與在移動Safari中不同的東西
- 13. 如何實現sencha touch 2.0中的sass
- 14. 未移動到iPod Touch中的設置
- 15. 如何在Ext Touch(Sencha Touch)中處理Ext.Panels上的滾動事件?
- 16. jQuery滾動移動Safari
- 17. 模糊事件不在iOS上觸發移動Safari在Sencha Touch中
- 18. 如何在sencha touch 2.0中保存textarea的複選框和數據狀態?
- 19. Sencha設置Ext.Panel'可滾動'屬性
- 20. Sencha Touch:自動滾動不能在DataView中工作
- 21. 面板中的Sencha Touch 2.0 Dataview
- 22. sencha touch :: list不滾動右邊
- 23. Sencha Touch 2&webkit溢出滾動:觸摸
- 24. 使用Sencha Touch阻止列表滾動
- 25. 使用sencha touch進行無限滾動
- 26. Sencha Touch垂直滾動問題
- 27. 如何在Sencha Touch 2上設置啓動畫面和啓動畫面?
- 28. 在Sencha Touch 2中設置動畫尺寸
- 29. Sencha Touch:使用Vimeo視頻滾動Ext.Panel打破滾動
- 30. 如何在Safari移動版(iPad)上正確滾動?