mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-28 18:15:37 -05:00
Merge pull request #514 from yueyuzhao/issue/474
iOS: scroll up a little bit if the textbox is on the bottom half of the screen
This commit is contained in:
commit
009bcb5be7
1 changed files with 10 additions and 1 deletions
|
@ -28,7 +28,7 @@ import {newHTML, newDiv, newP, gn,
|
||||||
setCanvasSizeScaledToWindowDocumentHeight,
|
setCanvasSizeScaledToWindowDocumentHeight,
|
||||||
DEGTOR, getIdFor, setProps, isTablet, isiOS,
|
DEGTOR, getIdFor, setProps, isTablet, isiOS,
|
||||||
isAndroid, fitInRect, scaleMultiplier, setCanvasSize,
|
isAndroid, fitInRect, scaleMultiplier, setCanvasSize,
|
||||||
globaly, globalx, rgbToHex} from '../../utils/lib';
|
globaly, globalx, rgbToHex, WINDOW_INNER_HEIGHT} from '../../utils/lib';
|
||||||
|
|
||||||
export default class Sprite {
|
export default class Sprite {
|
||||||
constructor (attr, whenDone) {
|
constructor (attr, whenDone) {
|
||||||
|
@ -913,6 +913,15 @@ export default class Sprite {
|
||||||
me.unfocusText();
|
me.unfocusText();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// On iOS if the bottom of the textbox is lower than half of the screen
|
||||||
|
// the color and font size menu may be covered by the keyboard
|
||||||
|
// 0.45 is a magic number and we should compare the bottom Y of the textbox VS
|
||||||
|
// WINDOW_INNER_HEIGHT substract the keyboard height.
|
||||||
|
if (gn('textbox').offsetTop + gn('textbox').offsetHeight > WINDOW_INNER_HEIGHT * 0.45) {
|
||||||
|
// scroll up a little more than the textbox height
|
||||||
|
// to show the color menu and font size menu.
|
||||||
|
window.scroll(0, gn('textbox').offsetHeight * 1.2);
|
||||||
|
}
|
||||||
if (isTablet) {
|
if (isTablet) {
|
||||||
ti.focus();
|
ti.focus();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue