sencha touch 可自动增长高度TextArea
js代码如下:
/*
*高度自动增长的文本框
*/
Ext.define('ux.TextArea', {
extend: 'Ext.field.TextArea',
xtype: 'autoTextArea',
config: {
clearIcon: false,
//不配置maxRows和lineHeight则没有增长限制
maxRows: 3,
lineHeight: 29
},
initialize: function () {
var me = this;
me.callParent(arguments);
me.adjustHeight = Ext.Function.createBuffered(function () {
var textAreaEl = me.getComponent().input;
if (textAreaEl) {
var scrollHeight = textAreaEl.dom.scrollHeight,
height;
//根据条件调整高度
if (!me.maxHeight || (me.maxHeight > scrollHeight)) {
height = scrollHeight;
} else {
height = me.maxHeight;
}
textAreaEl.dom.style.height = 'auto';
textAreaEl.dom.style.height = height + "px";
}
}, 200, me);
me.on({
scope: me,
keyup: 'adjustHeight',
change: 'adjustHeight',
painted: 'initHeight'
});
},
//初始化高度
initHeight: function () {
var me = this,
lingHeight = me.getLineHeight(),
maxRows = me.getMaxRows();
//如果有设置lineHeight和maxRows会产生一个最高高度
console.log(lingHeight, maxRows); if (lingHeight && maxRows) {
me.maxHeight = lingHeight * maxRows;
}
},
//重新初始化
reset: function () {
var me = this,
textAreaEl = me.getComponent().input;
if (textAreaEl && me.getValue().length==0) {
textAreaEl.dom.style.height = 'auto';
textAreaEl.dom.style.height = me.getLineHeight() + "29px";
}
}
});
css:
/*#region textarea */
.x-field-textarea .x-form-field {
line-height:29px;
min-height:29px;
height:34px;
overflow-y:hidden;
padding:0.2em 0 0 0.2em;
border-radius:6px;
}
.x-field-textarea {
min-height:;
border-radius:6px;
}
.x-field-textarea .x-field-input {
padding-right:0 !important;
}
/*#endregion*/
使用示例:
flex: 3,
itemId: 'textArea',
xtype: 'autoTextArea',
placeHolder: '说两句',
margin: '10px 15px'
sencha touch 可自动增长高度TextArea的更多相关文章
- sencha touch Carousel 自动切换
代码是在网上找的,忘记原出处了 /** * 跑马灯自动切换 */ Ext.define('ux.RotatingCarousel', { extend: 'Ext.carousel.Carousel' ...
- sencha touch JsonP 自动提示消息 masked
//公用类 Ext.define('app.util', { alternateClassName: 'util', statics: { /*为Ext.Viewport添加一个消息提示组件(需要初始 ...
- 【翻译】使用Sencha Touch开发Google Glass应用程序
原文:Developing for Google Glass with Sencha Touch 作者:Ross Gerbasi Ross Gerbasi is a Senior Engineer a ...
- textarea 实现高度自动增长
有时候希望textarea 能够自动调整高度来适应输入的内容 网上看到了很多解决方案,比如动态创建一个隐藏的div,当用户输入的时候将textarea的内容绑定到div,由于div的高度会自动撑开,因 ...
- Jquery实现 TextArea 文本框根据输入内容自动适应高度
原文 Jquery实现 TextArea 文本框根据输入内容自动适应高度 在玩微博的时候我们可能会注意到一个细节就是不管是新浪微博还是腾讯微博在转发和评论的时候给你的默认文本框的高度都不会很高,这可能 ...
- sencha touch textarea 手机上不显示滚动条,且不能滚动
最近在项目中发现 sencha touch 中的 textarea 在手机上不显示滚动条,也不能滚动. 在浏览器中之所以能显示滚动条滚动,那是浏览器为 textarea 添加的滚动条. 但在手机中是不 ...
- HTML的TextArea标记跟随文本内容自动设置高度
js <textarea name="textarea" id="textarea" style='overflow-y: hidden;height:2 ...
- 设置HTML的TextArea标记跟随文本内容自动设置高度
写内容的时候用的是textarea来写,可以换行,然后预览页面也要显示是换行才行,所以预览页面还是要用textarea来显示, 样式去掉边框,不可以拉伸,不可编辑 // html <textar ...
- Android环境配置Sencha Touch
转自http://www.phonegap100.com/portal.php?mod=view&aid=19 作为你开发的一部分,为安卓设备开发的 Sencha Touch框架应该在安卓虚拟 ...
随机推荐
- CentOS 7 安装、配置、使用 PostgreSQL 10 安装及基础配置
官网安装方法:https://www.postgresql.org/download/linux/redhat/ 卸载的话使用 yum remove 相应的安装 Install the reposit ...
- 正则表达式awk
以冒号: 为分隔符打印出来:打印第一段$1: -F 分隔符 [root@localhost awk]# awk -F ':' '{print $1}' test.txt root bin daemo ...
- 在PC上运行安卓(Android)应用程序的几个方法
三种方法: 1.在PC安装一个安卓模拟器,在模拟器里面运行apk: 2.虚拟机安装 Android x86 然后在此系统里运行: 3.利用谷歌chrome浏览器运行(这是一个新颖.有前途.激动人心的方 ...
- vue v-if与v-show使用注意问题
在使用中发现v-show和v-if用哪个都不可以控制元素块的显示隐藏, 之前v-show和v-if都是这样写的: <span v-if="{loadingComplete:false} ...
- symfony 事务提交
1. 添加数据 新建一个对象,给对象赋值 $em = $this->getDoctrine()->getManager(); //添加事物 $em->getConnection()- ...
- selenium +chrome headless Adhoc模式渲染网页
mannual和adhoc模式比较 Manual vs. Adhoc In the script above, we start the ChromeDriver server process whe ...
- splash渲染网页
#coding=utf8 import requests,time,random import threadpool render_html = 'http://192.168.30.128:8050 ...
- Python_selenium二次封装selenium的几个方法
Python_selenium二次封装selenium的几个方法 将常用的几个webdriver方法封装到自己写的一个类中去,此实例中是将"浏览器后退.浏览器前进.打开站点和关闭浏览器&qu ...
- error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1600”不匹配值“1800”
_MSC_VER 定义编译器的版本.下面是一些编译器版本的_MSC_VER值:MS VC++ 10.0 _MSC_VER = 1600MS VC++ 9.0 _MSC_VER = 1500MS VC+ ...
- Netty权威指南之Netty入门程序
package com.hjp.netty.netty; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Chan ...