textarea在android上停止滚动
我正在创建一个ionic/cordova混合应用程序。在我的一个观点中,我有一个相当大的文本区域,当键盘打开时,它占据了整个屏幕。问题是当我尝试滚动到页面底部时,textarea会捕捉到它并停止页面滚动。有没有可能让textarea滚动到底部,然后页面在底部滚动?是的,我建议在textarea后面放置一个块元素,如andtextarea在android上停止滚动,android,cordova,ionic-framework,Android,Cordova,Ionic Framework,我正在创建一个ionic/cordova混合应用程序。在我的一个观点中,我有一个相当大的文本区域,当键盘打开时,它占据了整个屏幕。问题是当我尝试滚动到页面底部时,textarea会捕捉到它并停止页面滚动。有没有可能让textarea滚动到底部,然后页面在底部滚动?是的,我建议在textarea后面放置一个块元素,如and标记。我创建了几个日志类型的应用程序,这些应用程序需要一个textarea作为输入,我尝试了很多丰富的编辑器,比如tinymce,甚至尝试了contenteditable属性,但
标记。我创建了几个日志类型的应用程序,这些应用程序需要一个textarea作为输入,我尝试了很多丰富的编辑器,比如tinymce,甚至尝试了contenteditable属性,但我总是回到原生textarea 下面是我的配置,它使文本编辑器达到最佳状态: CSS //JS
$scope.showKeyboard=函数(thetxtid){
//隐藏视图中的每个元素,使文本区域为“全屏”
对于(变量i=0;i<…;i++){
document.getElementById(…).style.display='none';
}
}
$ionicNavBarDelegate.showBar(假)//如果你有导航条,把它也隐藏起来
$timeout(函数(){
//调整文本区域大小
document.getElementById(thetxtid).style.height=window.innerHeight+'px';//这将考虑键盘高度
},300)
};
$scope.hideKeyboard=函数(thetxtid){
//展示你的元素
对于(变量i=0;i<…;i++){
document.getElementById(…).style.display='block';
}
$ionicNavBarDelegate.showBar(true);
$timeout(函数(){
//调整文本区域大小将文本区域的高度设置为其内容的高度
var _id=thetxtid;
text=document.getElementById(_id);
_scrollH=text.scrollHeight;
text.style.height=_scrollH+“px”;
},300);
};
HTML
我希望这有帮助。
祝你好运这太棒了,谢谢你!这正是我要找的。
textarea {
margin: 0;
border-radius: 0;
font-size: 19px; /*optional*/
-moz-user-select: text; /*android too*/
-webkit-user-select: text;
}
$scope.showKeyboard = function(thetxtid) {
//hide every element in the view so the text area is "fullscreen"
for (var i = 0; i < ...; i++) {
document.getElementById(...).style.display = 'none';
}
}
$ionicNavBarDelegate.showBar(false); //if you have a nav bar hide it too
$timeout(function(){
//resize text area
document.getElementById(thetxtid).style.height = window.innerHeight+'px'; // this takes the keyboard height into consideration
},300)
};
$scope.hideKeyboard = function(thetxtid) {
//show your elements
for (var i = 0; i < ...; i++) {
document.getElementById(...).style.display = 'block';
}
$ionicNavBarDelegate.showBar(true);
$timeout(function(){
//resize text area set the height of the text area to the height of its contents
var _id = thetxtid;
text = document.getElementById(_id);
_scrollH = text.scrollHeight;
text.style.height = _scrollH + "px";
},300);
};
<textarea class="paper" id="txtid" ng-focus="showKeyboard('txtid')" ng-blur="hideKeyboard('txtid')" placeholder="Something to Share?" ng-model="content.path" ng-trim="false"></textarea>