[Libreoffice-commits] online.git: loleaflet/build loleaflet/src
Henry Castro (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jan 30 21:01:46 UTC 2020
loleaflet/build/deps.js | 2
loleaflet/src/dom/DomEvent.DoubleTap.js | 77 ----------------
loleaflet/src/dom/DomEvent.LongTap.js | 148 --------------------------------
3 files changed, 227 deletions(-)
New commits:
commit d8245a5a99a6aeddae49b756b0bcc75af0674f35
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Thu Jan 30 13:30:44 2020 -0400
Commit: Henry Castro <hcastro at collabora.com>
CommitDate: Thu Jan 30 22:01:28 2020 +0100
loleaflet: mobile: remove unused 'long tap' and 'double tap' files
They are no longer used instead of the Hammer recognizer library
Change-Id: Ied076c5731dcaeca37e1a15b6b637cbb62250b20
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87751
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Henry Castro <hcastro at collabora.com>
diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index f3e8b72e6..29026afca 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -235,7 +235,6 @@ var deps = {
TouchZoom: {
src: ['dom/DomEvent.js',
- 'dom/DomEvent.DoubleTap.js',
'dom/DomEvent.Pointer.js',
'core/Handler.js',
'map/handler/Map.TouchGesture.js'],
@@ -362,7 +361,6 @@ var deps = {
ControlTabs: {
src: ['control/Control.js',
'dom/DomEvent.js',
- 'dom/DomEvent.LongTap.js',
'control/Control.Tabs.js'],
heading: 'Controls',
desc: 'Tabs for switching sheets'
diff --git a/loleaflet/src/dom/DomEvent.DoubleTap.js b/loleaflet/src/dom/DomEvent.DoubleTap.js
deleted file mode 100644
index 459c54e69..000000000
--- a/loleaflet/src/dom/DomEvent.DoubleTap.js
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- js-indent-level: 8 -*- */
-/*
- * Extends the event handling code with double tap support for mobile browsers.
- */
-
-L.extend(L.DomEvent, {
-
- _touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart',
- _touchend: L.Browser.msPointer ? 'MSPointerUp' : L.Browser.pointer ? 'pointerup' : 'touchend',
-
- // inspired by Zepto touch code by Thomas Fuchs
- addDoubleTapListener: function (obj, handler, id) {
- var last, touch,
- doubleTap = false,
- delay = 250;
-
- function onTouchStart(e) {
- var count;
-
- if (L.Browser.pointer) {
- count = L.DomEvent._pointersCount;
- } else {
- count = e.touches.length;
- }
-
- if (count > 1) { return; }
-
- var now = Date.now(),
- delta = now - (last || now);
-
- touch = e.touches ? e.touches[0] : e;
- doubleTap = (delta > 0 && delta <= delay);
- last = now;
- }
-
- function onTouchEnd() {
- if (doubleTap) {
- if (L.Browser.pointer) {
- // work around .type being readonly with MSPointer* events
- var newTouch = {},
- prop, i;
-
- for (i in touch) {
- prop = touch[i];
- newTouch[i] = prop && prop.bind ? prop.bind(touch) : prop;
- }
- touch = newTouch;
- }
- touch.type = 'dblclick';
- touch.button = 0;
- handler(touch);
- last = null;
- }
- }
-
- var pre = '_leaflet_',
- touchstart = this._touchstart,
- touchend = this._touchend;
-
- obj[pre + touchstart + id] = onTouchStart;
- obj[pre + touchend + id] = onTouchEnd;
-
- obj.addEventListener(touchstart, onTouchStart, false);
- obj.addEventListener(touchend, onTouchEnd, false);
- return this;
- },
-
- removeDoubleTapListener: function (obj, id) {
- var pre = '_leaflet_',
- touchend = obj[pre + this._touchend + id];
-
- obj.removeEventListener(this._touchstart, obj[pre + this._touchstart + id], false);
- obj.removeEventListener(this._touchend, touchend, false);
-
- return this;
- }
-});
diff --git a/loleaflet/src/dom/DomEvent.LongTap.js b/loleaflet/src/dom/DomEvent.LongTap.js
deleted file mode 100644
index 05319967e..000000000
--- a/loleaflet/src/dom/DomEvent.LongTap.js
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Similar to DomEvent.DoubleTap.js (which implements the 'dblclick' event for
- * touchscreens), this implements the 'contextmenu' event on long touchscreen
- * press for combination of browsers/input devices that don't - namely,
- * Safari on iOS devices.
- *
- * This has been mostly copy-pasted from map/handler/Map.Tap.js and should be
- * refactored somehow.
- */
-L.DomEvent.enableLongTap = function enableLongTap(el, tolerance, timeout) {
- // Skip non-touchscreens and browsers which implement PointerEvent
- if (!L.Browser.touch || L.Browser.pointer) {
- return;
- }
-
- // Prevent double handling
- if (el._hasLongTapContextMenus) {
- return;
- }
- el._hasLongTapContextMenus = true;
-
- // Default value for the 'tolerance' parameter: 15 pixels
- // This is the amount of pixels that the touch can move around during
- // a long tap, and still fire contextmenu events.
- if (!tolerance) {
- tolerance = 15;
- }
-
- // Default value for the 'timeout' parameter: 2000 milliseconds
- // This is how long a user has to hold down the touch to trigger the
- // contextmenu event
- if (!timeout) {
- timeout = 2000;
- }
-
- var holdTimeout;
- var fireClick = true; // Whether to fire a click event on touchup
- var startPos; // Position of the touch on touchstart
- var newPos; // Position of the touch on the last touchmove
-
- function onDown(ev) {
- if (!ev.touches) {
- return;
- }
-
- L.DomEvent.preventDefault(ev);
- fireClick = true;
-
- // don't simulate click or track longpress if more than 1 touch
- if (ev.touches.length > 1) {
- fireClick = false;
- clearTimeout(holdTimeout);
- return;
- }
-
- var first = ev.touches[0];
- var target = first.target;
-
- startPos = newPos = L.point(first.clientX, first.clientY);
-
- // if touching a link, highlight it
- if (target.tagName && target.tagName.toLowerCase() === 'a') {
- L.DomUtil.addClass(target, 'leaflet-active');
- }
-
- // simulate long hold but setting a timeout
- holdTimeout = setTimeout(function() {
- if (isTapValid()) {
- fireClick = false;
- onUp();
- simulateEvent('contextmenu', first);
- }
- }, timeout);
-
- simulateEvent('mousedown', first);
-
- L.DomEvent.on(el, {
- touchmove: onMove,
- touchend: onUp
- });
- }
-
- function isTapValid() {
- return newPos.distanceTo(startPos) <= tolerance;
- }
-
- function onUp(ev) {
- clearTimeout(holdTimeout);
-
- L.DomEvent.off(el, {
- touchmove: onMove,
- touchend: onUp
- });
-
- if (fireClick && ev && ev.changedTouches) {
- var first = ev.changedTouches[0];
- var target = first.target;
-
- if (target && target.tagName && el.tagName.toLowerCase() === 'a') {
- L.DomUtil.removeClass(target, 'leaflet-active');
- }
-
- simulateEvent('mouseup', first);
-
- // simulate click if the touch didn't move too much
- if (isTapValid()) {
- simulateEvent('click', first);
- }
- }
- }
-
- function onMove(ev) {
- var first = ev.touches[0];
- newPos = new L.Point(first.clientX, first.clientY);
- simulateEvent('mousemove', first);
- }
-
- function simulateEvent(type, ev) {
- var simulatedEvent = document.createEvent('MouseEvents');
-
- simulatedEvent._simulated = true;
- ev.target._simulatedClick = true;
-
- simulatedEvent.initMouseEvent(
- type,
- true,
- true,
- window,
- 1,
- ev.screenX,
- ev.screenY,
- ev.clientX,
- ev.clientY,
- false,
- false,
- false,
- false,
- 0,
- null
- );
-
- console.log('dispatching simulated contextmenu event: ', simulatedEvent);
-
- ev.target.dispatchEvent(simulatedEvent);
- }
-
- L.DomEvent.on(el, 'touchstart', onDown, this);
-};
More information about the Libreoffice-commits
mailing list