From f40757c50fc12c14c63d12412b77cf6f5cb5094a Mon Sep 17 00:00:00 2001 From: Yueyu Date: Thu, 2 Sep 2021 20:52:24 +0800 Subject: [PATCH 1/4] iOS: scroll up a little bit if the textbox is on the bottom part of the screen --- src/editor/engine/Sprite.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/editor/engine/Sprite.js b/src/editor/engine/Sprite.js index 785b428..b5d62f8 100755 --- a/src/editor/engine/Sprite.js +++ b/src/editor/engine/Sprite.js @@ -913,6 +913,13 @@ export default class Sprite { me.unfocusText(); }); } 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 + if (gn('textbox').offsetTop + gn('textbox').offsetHeight > WINDOW_INNER_HEIGHT / 2) { + // 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) { ti.focus(); } else { From bdc158f6d23848173c642b5a395987e0e8e521ff Mon Sep 17 00:00:00 2001 From: Yueyu Date: Thu, 2 Sep 2021 21:00:22 +0800 Subject: [PATCH 2/4] import WINDOW_INNER_HEIGHT from lib --- src/editor/engine/Sprite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor/engine/Sprite.js b/src/editor/engine/Sprite.js index b5d62f8..ba0cfbe 100755 --- a/src/editor/engine/Sprite.js +++ b/src/editor/engine/Sprite.js @@ -28,7 +28,7 @@ import {newHTML, newDiv, newP, gn, setCanvasSizeScaledToWindowDocumentHeight, DEGTOR, getIdFor, setProps, isTablet, isiOS, isAndroid, fitInRect, scaleMultiplier, setCanvasSize, - globaly, globalx, rgbToHex} from '../../utils/lib'; + globaly, globalx, rgbToHex, WINDOW_INNER_HEIGHT} from '../../utils/lib'; export default class Sprite { constructor (attr, whenDone) { From 4ccc880cf658f520ec928079891400f847d14c8a Mon Sep 17 00:00:00 2001 From: Yueyu Date: Thu, 2 Sep 2021 21:02:44 +0800 Subject: [PATCH 3/4] code lint --- src/editor/engine/Sprite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor/engine/Sprite.js b/src/editor/engine/Sprite.js index ba0cfbe..b990777 100755 --- a/src/editor/engine/Sprite.js +++ b/src/editor/engine/Sprite.js @@ -916,7 +916,7 @@ export default class Sprite { // 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 if (gn('textbox').offsetTop + gn('textbox').offsetHeight > WINDOW_INNER_HEIGHT / 2) { - // scroll up a little more than the textbox height + // 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); } From 3a35279a6c9d620e1389ffd13361ee0f71bb032c Mon Sep 17 00:00:00 2001 From: Yueyu Date: Sat, 4 Sep 2021 07:27:54 +0800 Subject: [PATCH 4/4] change to 45% of the window.innerHeight to show color and font size menu --- src/editor/engine/Sprite.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/editor/engine/Sprite.js b/src/editor/engine/Sprite.js index b990777..91dac56 100755 --- a/src/editor/engine/Sprite.js +++ b/src/editor/engine/Sprite.js @@ -915,7 +915,9 @@ export default class Sprite { } 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 - if (gn('textbox').offsetTop + gn('textbox').offsetHeight > WINDOW_INNER_HEIGHT / 2) { + // 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);