码迷,mamicode.com
首页 > 移动开发 > 详细

textarea 手机上不显示滚动条,且不能滚动

时间:2014-11-15 10:01:07      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:des   io   ar   on   art   cti   ad   amp   ef   

找了一个老外重写的可滑动的 textarea:

Ext.define(‘LeslieTest.view.TextArea‘,
{
    extend : ‘Ext.field.TextArea‘,
    xtype : ‘scrollTextArea‘,
    
    initialize : function() {
        this.callParent();
        this.element.dom.addEventListener(
                Ext.feature.has.Touch ? ‘touchstart‘
                        : ‘mousedown‘,
                this.handleTouchListener = Ext.bind(
                        this.handleTouch, this), false);
        this.element.dom.addEventListener(
                Ext.feature.has.Touch ? ‘touchmove‘
                        : ‘mousemove‘,
                this.handleMoveListener = Ext.bind(
                        this.handleMove, this), false);
        this.moveListenersAttached = true;
    },
    
    destroy : function() {
        if (this.moveListenersAttached) {
            this.moveListenersAttached = false;
            this.element.dom.removeEventListener(
                    Ext.feature.has.Touch ? ‘touchstart‘
                            : ‘mousedown‘,
                    this.handleTouchListener, false);
            this.element.dom.removeEventListener(
                    Ext.feature.has.Touch ? ‘touchmove‘
                            : ‘mousemove‘,
                    this.handleMoveListener, false);
            this.handleTouchListener = this.handleMoveListener = null;
        }
        this.callParent();
    },
    
    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;

        if ((top && up) || (bottom && down))
            e.preventDefault();

        if (!(top && bottom))
            e.stopPropagation();
    }
});

textarea 手机上不显示滚动条,且不能滚动

标签:des   io   ar   on   art   cti   ad   amp   ef   

原文地址:http://www.cnblogs.com/xiaocaoydj/p/4098837.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!