summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2019-10-23 17:47:58 +0300
committerTor Lillqvist <tml@collabora.com>2019-12-05 23:23:20 +0100
commit662f8d687a56d01e8b192aefdeed4051102d19e4 (patch)
treebe4ccdf6d664b669e47b1bbc711bf680582f893a /filter
parente7a87ff3651bde1ba8399c553556babe36807cbe (diff)
tdf#127939: Make slideshow touch input work properly again on iOS 13
For some reason, navigator.userAgent in WebKit on iOS 13 claims it to be a Macintosh, so our old code to recognise iOS did not work any longer. Also the Hammer.js included in this file looked at navigator.userAgent and its decision what to do based on that did not work properly either. Simplify our code by handling swipe gestures all the time, even when such won't be generated (on mouse-only devices). Also, Hammer.JS was too eager to think it detected a pointer-only device based on the presense of window.PointerEvent. That sems to be present now in iOS 13. Let's not blindly think that means it is a pointer-only device. If the device supports touch events, don't bother with PointerEvents. Change-Id: I57d972415798967e871c6e262f16043561ed6af5 Reviewed-on: https://gerrit.libreoffice.org/81404 Reviewed-by: Tor Lillqvist <tml@collabora.com> Tested-by: Tor Lillqvist <tml@collabora.com> (cherry picked from commit 8f78d6a0d1b4d8d2e21aad9e90510fe6be4df5bb) Reviewed-on: https://gerrit.libreoffice.org/83731 Reviewed-on: https://gerrit.libreoffice.org/83883 Tested-by: Jenkins (cherry picked from commit 8012a200d1a7c5cd1b64a147ca6899fb8863ce8b) Reviewed-on: https://gerrit.libreoffice.org/84529
Diffstat (limited to 'filter')
-rw-r--r--filter/source/svg/presentation_engine.js46
1 files changed, 22 insertions, 24 deletions
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index 6dff0f2b4a67..5e67ecd2ea7e 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -494,7 +494,7 @@ function createInputInstance(manager) {
if (inputClass) {
Type = inputClass;
- } else if (SUPPORT_POINTER_EVENTS) {
+ } else if (!SUPPORT_TOUCH && SUPPORT_POINTER_EVENTS) {
Type = PointerEventInput;
} else if (SUPPORT_ONLY_TOUCH) {
Type = TouchInput;
@@ -823,6 +823,7 @@ inherit(MouseInput, Input, {
* @param {Object} ev
*/
handler: function MEhandler(ev) {
+ // console.log('==> MouseInput handler');
var eventType = MOUSE_INPUT_MAP[ev.type];
// on start we want to have the left mouse button down
@@ -897,6 +898,7 @@ inherit(PointerEventInput, Input, {
* @param {Object} ev
*/
handler: function PEhandler(ev) {
+ // console.log('==> PointerEventInput handler');
var store = this.store;
var removePointer = false;
@@ -966,6 +968,7 @@ function SingleTouchInput() {
inherit(SingleTouchInput, Input, {
handler: function TEhandler(ev) {
+ // console.log('==> SingleTouchInput handler');
var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
// should we handle the touch events?
@@ -1033,6 +1036,7 @@ function TouchInput() {
inherit(TouchInput, Input, {
handler: function MTEhandler(ev) {
+ // console.log('==> TouchInput handler');
var type = TOUCH_INPUT_MAP[ev.type];
var touches = getTouches.call(this, ev, type);
if (!touches) {
@@ -1141,6 +1145,7 @@ inherit(TouchMouseInput, Input, {
* @param {Object} inputData
*/
handler: function TMEhandler(manager, inputEvent, inputData) {
+ // console.log('==> TouchMouseInput handler');
var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH),
isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
@@ -6480,26 +6485,22 @@ function init()
theSlideIndexPage = new SlideIndexPage();
aSlideShow.displaySlide( theMetaDoc.nStartSlideNumber, false );
- // In the iOS app, allow slide switching with swipe gestures left
+ // Allow slide switching with swipe gestures left
// and right. Swiping up or down will exit the slideshow.
- var ua = navigator.userAgent;
- if (ua.indexOf(' AppleWebKit/') !== -1 &&
- ua.indexOf(' Mobile/') !== -1) {
- var hammer = new Hammer(ROOT_NODE);
- hammer.on('swipeleft', function() {
- switchSlide(1, false);
- });
- hammer.on('swiperight', function() {
- switchSlide(-1, false);
- });
- hammer.get('swipe').set({ direction: Hammer.DIRECTION_ALL });
- hammer.on('swipeup', function() {
- aSlideShow.exitSlideShowInApp();
- });
- hammer.on('swipedown', function() {
- aSlideShow.exitSlideShowInApp();
- });
- }
+ var hammer = new Hammer(ROOT_NODE);
+ hammer.on('swipeleft', function() {
+ switchSlide(1, false);
+ });
+ hammer.on('swiperight', function() {
+ switchSlide(-1, false);
+ });
+ hammer.get('swipe').set({ direction: Hammer.DIRECTION_ALL });
+ hammer.on('swipeup', function() {
+ aSlideShow.exitSlideShowInApp();
+ });
+ hammer.on('swipedown', function() {
+ aSlideShow.exitSlideShowInApp();
+ });
}
function presentationEngineStop(message)
@@ -18410,10 +18411,7 @@ SlideShow.prototype.rewindAllEffects = function()
SlideShow.prototype.exitSlideShowInApp = function()
{
- var ua = navigator.userAgent;
- if (ua.indexOf(' AppleWebKit/') !== -1 &&
- ua.indexOf(' Mobile/') !== -1 &&
- window.webkit !== undefined &&
+ if (window.webkit !== undefined &&
window.webkit.messageHandlers !== undefined &&
window.webkit.messageHandlers.lool !== undefined)
window.webkit.messageHandlers.lool.postMessage('EXITSLIDESHOW', '*');