diff options
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/Buttons.hx | 28 | ||||
| -rw-r--r-- | src/client/Utils.hx | 6 | ||||
| -rw-r--r-- | src/client/players/Raw.hx | 1 | ||||
| -rw-r--r-- | src/client/players/Youtube.hx | 1 |
4 files changed, 34 insertions, 2 deletions
diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx index aba629e..b11e3fd 100644 --- a/src/client/Buttons.hx +++ b/src/client/Buttons.hx @@ -335,7 +335,10 @@ class Buttons { static function initChatInput(main:Main):Void { final guestName:InputElement = cast ge("#guestname"); guestName.onkeydown = e -> { - if (e.keyCode == KeyCode.Return) main.guestLogin(guestName.value); + if (e.keyCode == KeyCode.Return) { + main.guestLogin(guestName.value); + if (Utils.isTouch()) guestName.blur(); + } } final guestPass:InputElement = cast ge("#guestpass"); @@ -343,12 +346,32 @@ class Buttons { if (e.keyCode == KeyCode.Return) { main.userLogin(guestName.value, guestPass.value); guestPass.value = ""; + if (Utils.isTouch()) guestPass.blur(); } } + if (Utils.isIOS()) { + document.ontouchmove = e -> { + e.preventDefault(); + } + ge("#chat").style.height = "-webkit-fill-available"; + } final chatline:InputElement = cast ge("#chatline"); chatline.onfocus = e -> { - if (Utils.isTouch()) main.scrollChatToEnd(); + if (Utils.isIOS()) { + var startY = window.scrollY; + Timer.delay(() -> { + window.scrollBy(0, -(window.scrollY - startY)); + ge("#chat").style.height = '${window.innerHeight}px'; + ge("#video").scrollTop = 0; + main.scrollChatToEnd(); + }, 100); + } else if (Utils.isTouch()) main.scrollChatToEnd(); + } + chatline.onblur = e -> { + if (Utils.isIOS()) { + ge("#chat").style.height = "-webkit-fill-available"; + } } new InputWithHistory(chatline, 50, value -> { if (main.handleCommands(value)) return true; @@ -359,6 +382,7 @@ class Buttons { text: value } }); + if (Utils.isTouch()) chatline.blur(); return true; }); } diff --git a/src/client/Utils.hx b/src/client/Utils.hx index f23365e..818dfdf 100644 --- a/src/client/Utils.hx +++ b/src/client/Utils.hx @@ -1,6 +1,7 @@ package client; import js.Browser.document; +import js.Browser.navigator; import js.Browser.window; import js.html.Element; import js.html.URL; @@ -10,6 +11,11 @@ class Utils { return js.Syntax.code("'ontouchstart' in window"); } + public static function isIOS():Bool { + return ~/^(iPhone|iPad|iPod)/.match(navigator.platform) + || (~/^Mac/.match(navigator.platform) && navigator.maxTouchPoints > 4); + } + public static function nodeFromString(div:String):Element { final wrapper = document.createDivElement(); wrapper.innerHTML = div; diff --git a/src/client/players/Raw.hx b/src/client/players/Raw.hx index 5889732..4b78b0f 100644 --- a/src/client/players/Raw.hx +++ b/src/client/players/Raw.hx @@ -105,6 +105,7 @@ class Raw implements IPlayer { } else { video = document.createVideoElement(); video.id = "videoplayer"; + video.setAttribute("playsinline", ""); video.src = url; video.oncanplaythrough = player.onCanBePlayed; video.onseeking = player.onSetTime; diff --git a/src/client/players/Youtube.hx b/src/client/players/Youtube.hx index 23b2439..65a93c9 100644 --- a/src/client/players/Youtube.hx +++ b/src/client/players/Youtube.hx @@ -226,6 +226,7 @@ class Youtube implements IPlayer { videoId: extractVideoId(item.url), playerVars: { autoplay: 1, + playsinline: 1, modestbranding: 1, rel: 0, showinfo: 0 |
