Commit 2f6831ec authored by Oleg Korshul's avatar Oleg Korshul

mobile web: zoom edge

parent 981877ff
...@@ -909,6 +909,10 @@ ...@@ -909,6 +909,10 @@
} }
asc_applyFunction(callback, vsize, hsize); asc_applyFunction(callback, vsize, hsize);
if (this.Api.isMobileVersion) {
this.MobileTouchManager.Resize();
}
}; };
WorkbookView.prototype._onScrollY = function(pos) { WorkbookView.prototype._onScrollY = function(pos) {
......
...@@ -475,6 +475,8 @@ function (window, undefined) ...@@ -475,6 +475,8 @@ function (window, undefined)
this.IsTouching = true; this.IsTouching = true;
AscCommon.g_inputContext.enableVirtualKeyboard(); AscCommon.g_inputContext.enableVirtualKeyboard();
this.checkPointerMultiTouchAdd(e);
global_mouseEvent.KoefPixToMM = 5; global_mouseEvent.KoefPixToMM = 5;
AscCommon.check_MouseDownEvent(_e, true); AscCommon.check_MouseDownEvent(_e, true);
global_mouseEvent.KoefPixToMM = 1; global_mouseEvent.KoefPixToMM = 1;
...@@ -494,7 +496,7 @@ function (window, undefined) ...@@ -494,7 +496,7 @@ function (window, undefined)
bIsKoefPixToMM = this.CheckObjectTrack(); bIsKoefPixToMM = this.CheckObjectTrack();
} }
if (e.touches && 2 == e.touches.length) if ((e.touches && 2 == e.touches.length) || (2 == this.getPointerCount()))
{ {
this.Mode = AscCommon.MobileTouchMode.Zoom; this.Mode = AscCommon.MobileTouchMode.Zoom;
} }
...@@ -630,13 +632,7 @@ function (window, undefined) ...@@ -630,13 +632,7 @@ function (window, undefined)
} }
case AscCommon.MobileTouchMode.Zoom: case AscCommon.MobileTouchMode.Zoom:
{ {
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX; this.ZoomDistance = this.getPointerDistance(e);
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
this.ZoomDistance = Math.sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
this.ZoomValue = this.delegate.GetZoom(); this.ZoomValue = this.delegate.GetZoom();
break; break;
...@@ -659,6 +655,8 @@ function (window, undefined) ...@@ -659,6 +655,8 @@ function (window, undefined)
}; };
CMobileTouchManager.prototype.onTouchMove = function(e) CMobileTouchManager.prototype.onTouchMove = function(e)
{ {
this.checkPointerMultiTouchAdd(e);
var _e = e.touches ? e.touches[0] : e; var _e = e.touches ? e.touches[0] : e;
if (this.Mode != AscCommon.MobileTouchMode.FlowObj && this.Mode != AscCommon.MobileTouchMode.TableMove) if (this.Mode != AscCommon.MobileTouchMode.FlowObj && this.Mode != AscCommon.MobileTouchMode.TableMove)
AscCommon.check_MouseMoveEvent(e.touches ? e.touches[0] : e); AscCommon.check_MouseMoveEvent(e.touches ? e.touches[0] : e);
...@@ -696,19 +694,14 @@ function (window, undefined) ...@@ -696,19 +694,14 @@ function (window, undefined)
} }
case AscCommon.MobileTouchMode.Zoom: case AscCommon.MobileTouchMode.Zoom:
{ {
if (2 != e.touches.length) var isTouch2 = ((e.touches && 2 == e.touches.length) || (2 == this.getPointerCount()));
if (!isTouch2)
{ {
this.Mode = AscCommon.MobileTouchMode.None; this.Mode = AscCommon.MobileTouchMode.None;
return; return;
} }
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX; var zoomCurrentDist = this.getPointerDistance(e);
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
var zoomCurrentDist = Math.sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
if (zoomCurrentDist == 0) if (zoomCurrentDist == 0)
zoomCurrentDist = 1; zoomCurrentDist = 1;
...@@ -846,6 +839,8 @@ function (window, undefined) ...@@ -846,6 +839,8 @@ function (window, undefined)
break; break;
} }
this.checkPointerMultiTouchRemove(e);
if (this.Api.isViewMode || isPreventDefault) if (this.Api.isViewMode || isPreventDefault)
AscCommon.g_inputContext.preventVirtualKeyboard(e); AscCommon.g_inputContext.preventVirtualKeyboard(e);
......
...@@ -610,6 +610,8 @@ ...@@ -610,6 +610,8 @@
/* eventsElement */ /* eventsElement */
this.eventsElement = _config.eventsElement; this.eventsElement = _config.eventsElement;
this.pointerTouchesCoords = {};
} }
CMobileTouchManagerBase.prototype.initEvents = function(_id) CMobileTouchManagerBase.prototype.initEvents = function(_id)
...@@ -1798,7 +1800,7 @@ ...@@ -1798,7 +1800,7 @@
this.MoveAfterDown = false; this.MoveAfterDown = false;
if (e.touches && 2 == e.touches.length) if ((e.touches && 2 == e.touches.length) || (2 == this.getPointerCount()))
{ {
this.Mode = AscCommon.MobileTouchMode.Zoom; this.Mode = AscCommon.MobileTouchMode.Zoom;
} }
...@@ -1832,13 +1834,7 @@ ...@@ -1832,13 +1834,7 @@
{ {
this.delegate.HtmlPage.NoneRepaintPages = true; this.delegate.HtmlPage.NoneRepaintPages = true;
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX; this.ZoomDistance = this.getPointerDistance(e);
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
this.ZoomDistance = Math.sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
this.ZoomValue = this.delegate.GetZoom(); this.ZoomValue = this.delegate.GetZoom();
break; break;
...@@ -1875,19 +1871,14 @@ ...@@ -1875,19 +1871,14 @@
} }
case AscCommon.MobileTouchMode.Zoom: case AscCommon.MobileTouchMode.Zoom:
{ {
if (2 != e.touches.length) var isTouch2 = ((e.touches && 2 == e.touches.length) || (2 == this.getPointerCount()));
if (!isTouch2)
{ {
this.Mode = AscCommon.MobileTouchMode.None; this.Mode = AscCommon.MobileTouchMode.None;
return; return;
} }
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX; var zoomCurrentDist = this.getPointerDistance(e);
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
var zoomCurrentDist = Math.sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
if (zoomCurrentDist == 0) if (zoomCurrentDist == 0)
zoomCurrentDist = 1; zoomCurrentDist = 1;
...@@ -2005,6 +1996,83 @@ ...@@ -2005,6 +1996,83 @@
return false; return false;
}; };
CMobileTouchManagerBase.prototype.checkPointerMultiTouchAdd = function(e)
{
if (!this.checkPointerEvent(e))
return;
this.pointerTouchesCoords[e["pointerId"]] = {X:e.pageX, Y:e.pageY};
};
CMobileTouchManagerBase.prototype.checkPointerMultiTouchRemove = function(e)
{
if (!this.checkPointerEvent(e))
return;
delete this.pointerTouchesCoords[e["pointerId"]];
};
CMobileTouchManagerBase.prototype.checkPointerEvent = function(e)
{
if (!AscCommon.AscBrowser.isIE)
return false;
var _type = e.type;
if (_type.toLowerCase)
_type = _type.toLowerCase();
if (-1 == _type.indexOf("pointer"))
return -1;
if (undefined == e["pointerId"])
return false;
return true;
};
CMobileTouchManagerBase.prototype.getPointerDistance = function(e)
{
var isPointers = this.checkPointerEvent(e);
if (e.touches && (e.touches.length > 1) && !isPointers)
{
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX;
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
return Math.sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
}
else if (isPointers)
{
var _touch1 = {X : 0, Y : 0};
var _touch2 = {X : 0, Y : 0};
var _counter = 0;
for (var i in this.pointerTouchesCoords)
{
if (_counter == 0)
_touch1 = this.pointerTouchesCoords[i];
else
_touch2 = this.pointerTouchesCoords[i];
++_counter;
if (_counter > 1)
break;
}
return Math.sqrt((_touch1.X - _touch2.X) * (_touch1.X - _touch2.X) + (_touch1.Y - _touch2.Y) * (_touch1.Y - _touch2.Y));
}
return 0;
};
CMobileTouchManagerBase.prototype.getPointerCount = function(e)
{
var _count = 0;
for (var i in this.pointerTouchesCoords)
++_count;
return _count;
};
//--------------------------------------------------------export---------------------------------------------------- //--------------------------------------------------------export----------------------------------------------------
AscCommon.CMobileDelegateSimple = CMobileDelegateSimple; AscCommon.CMobileDelegateSimple = CMobileDelegateSimple;
AscCommon.CMobileTouchManagerBase = CMobileTouchManagerBase; AscCommon.CMobileTouchManagerBase = CMobileTouchManagerBase;
......
...@@ -371,6 +371,8 @@ ...@@ -371,6 +371,8 @@
this.IsTouching = true; this.IsTouching = true;
AscCommon.g_inputContext.enableVirtualKeyboard(); AscCommon.g_inputContext.enableVirtualKeyboard();
this.checkPointerMultiTouchAdd(e);
if (this.delegate.IsReader()) if (this.delegate.IsReader())
return this.onTouchStart_renderer(e); return this.onTouchStart_renderer(e);
...@@ -399,7 +401,7 @@ ...@@ -399,7 +401,7 @@
} }
} }
if (e.touches && 2 == e.touches.length) if ((e.touches && 2 == e.touches.length) || (2 == this.getPointerCount()))
{ {
this.Mode = AscCommon.MobileTouchMode.Zoom; this.Mode = AscCommon.MobileTouchMode.Zoom;
} }
...@@ -539,13 +541,7 @@ ...@@ -539,13 +541,7 @@
{ {
this.delegate.HtmlPage.NoneRepaintPages = true; this.delegate.HtmlPage.NoneRepaintPages = true;
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX; this.ZoomDistance = this.getPointerDistance(e);
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
this.ZoomDistance = Math.sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
this.ZoomValue = this.delegate.GetZoom(); this.ZoomValue = this.delegate.GetZoom();
break; break;
...@@ -578,6 +574,8 @@ ...@@ -578,6 +574,8 @@
}; };
CMobileTouchManager.prototype.onTouchMove = function(e) CMobileTouchManager.prototype.onTouchMove = function(e)
{ {
this.checkPointerMultiTouchAdd(e);
if (this.delegate.IsReader()) if (this.delegate.IsReader())
return this.onTouchMove_renderer(e); return this.onTouchMove_renderer(e);
...@@ -617,19 +615,14 @@ ...@@ -617,19 +615,14 @@
} }
case AscCommon.MobileTouchMode.Zoom: case AscCommon.MobileTouchMode.Zoom:
{ {
if (2 != e.touches.length) var isTouch2 = ((e.touches && 2 == e.touches.length) || (2 == this.getPointerCount()));
if (!isTouch2)
{ {
this.Mode = AscCommon.MobileTouchMode.None; this.Mode = AscCommon.MobileTouchMode.None;
return; return;
} }
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX; var zoomCurrentDist = this.getPointerDistance(e);
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
var zoomCurrentDist = Math.sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
if (zoomCurrentDist == 0) if (zoomCurrentDist == 0)
zoomCurrentDist = 1; zoomCurrentDist = 1;
...@@ -737,7 +730,10 @@ ...@@ -737,7 +730,10 @@
this.IsTouching = false; this.IsTouching = false;
if (this.delegate.IsReader()) if (this.delegate.IsReader())
{
this.checkPointerMultiTouchRemove(e);
return this.onTouchEnd_renderer(e); return this.onTouchEnd_renderer(e);
}
var _e = e.changedTouches ? e.changedTouches[0] : e; var _e = e.changedTouches ? e.changedTouches[0] : e;
if (this.Mode != AscCommon.MobileTouchMode.FlowObj && this.Mode != AscCommon.MobileTouchMode.TableMove) if (this.Mode != AscCommon.MobileTouchMode.FlowObj && this.Mode != AscCommon.MobileTouchMode.TableMove)
...@@ -937,6 +933,8 @@ ...@@ -937,6 +933,8 @@
break; break;
} }
this.checkPointerMultiTouchRemove(e);
if (this.Api.isViewMode || isPreventDefault) if (this.Api.isViewMode || isPreventDefault)
AscCommon.g_inputContext.preventVirtualKeyboard(e); AscCommon.g_inputContext.preventVirtualKeyboard(e);
......
...@@ -83,6 +83,8 @@ ...@@ -83,6 +83,8 @@
this.IsTouching = true; this.IsTouching = true;
AscCommon.g_inputContext.enableVirtualKeyboard(); AscCommon.g_inputContext.enableVirtualKeyboard();
this.checkPointerMultiTouchAdd(e);
if (this.delegate.IsReader()) if (this.delegate.IsReader())
return this.onTouchStart_renderer(e); return this.onTouchStart_renderer(e);
...@@ -111,7 +113,7 @@ ...@@ -111,7 +113,7 @@
} }
} }
if (e.touches && 2 == e.touches.length) if ((e.touches && 2 == e.touches.length) || (2 == this.getPointerCount()))
{ {
this.Mode = AscCommon.MobileTouchMode.Zoom; this.Mode = AscCommon.MobileTouchMode.Zoom;
} }
...@@ -251,13 +253,7 @@ ...@@ -251,13 +253,7 @@
{ {
this.delegate.HtmlPage.NoneRepaintPages = true; this.delegate.HtmlPage.NoneRepaintPages = true;
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX; this.ZoomDistance = this.getPointerDistance(e);
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
this.ZoomDistance = Math.sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
this.ZoomValue = this.delegate.GetZoom(); this.ZoomValue = this.delegate.GetZoom();
break; break;
...@@ -290,6 +286,8 @@ ...@@ -290,6 +286,8 @@
}; };
CMobileTouchManager.prototype.onTouchMove = function(e) CMobileTouchManager.prototype.onTouchMove = function(e)
{ {
this.checkPointerMultiTouchAdd(e);
if (this.delegate.IsReader()) if (this.delegate.IsReader())
return this.onTouchMove_renderer(e); return this.onTouchMove_renderer(e);
...@@ -329,19 +327,14 @@ ...@@ -329,19 +327,14 @@
} }
case AscCommon.MobileTouchMode.Zoom: case AscCommon.MobileTouchMode.Zoom:
{ {
if (2 != e.touches.length) var isTouch2 = ((e.touches && 2 == e.touches.length) || (2 == this.getPointerCount()));
if (!isTouch2)
{ {
this.Mode = AscCommon.MobileTouchMode.None; this.Mode = AscCommon.MobileTouchMode.None;
return; return;
} }
var _x1 = (e.touches[0].pageX !== undefined) ? e.touches[0].pageX : e.touches[0].clientX; var zoomCurrentDist = this.getPointerDistance(e);
var _y1 = (e.touches[0].pageY !== undefined) ? e.touches[0].pageY : e.touches[0].clientY;
var _x2 = (e.touches[1].pageX !== undefined) ? e.touches[1].pageX : e.touches[1].clientX;
var _y2 = (e.touches[1].pageY !== undefined) ? e.touches[1].pageY : e.touches[1].clientY;
var zoomCurrentDist = Math.sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
if (zoomCurrentDist == 0) if (zoomCurrentDist == 0)
zoomCurrentDist = 1; zoomCurrentDist = 1;
...@@ -449,7 +442,10 @@ ...@@ -449,7 +442,10 @@
this.IsTouching = false; this.IsTouching = false;
if (this.delegate.IsReader()) if (this.delegate.IsReader())
{
this.checkPointerMultiTouchRemove(e);
return this.onTouchEnd_renderer(e); return this.onTouchEnd_renderer(e);
}
var _e = e.changedTouches ? e.changedTouches[0] : e; var _e = e.changedTouches ? e.changedTouches[0] : e;
if (this.Mode != AscCommon.MobileTouchMode.FlowObj && this.Mode != AscCommon.MobileTouchMode.TableMove) if (this.Mode != AscCommon.MobileTouchMode.FlowObj && this.Mode != AscCommon.MobileTouchMode.TableMove)
...@@ -649,6 +645,8 @@ ...@@ -649,6 +645,8 @@
break; break;
} }
this.checkPointerMultiTouchRemove(e);
if (this.Api.isViewMode || isPreventDefault) if (this.Api.isViewMode || isPreventDefault)
AscCommon.g_inputContext.preventVirtualKeyboard(e); AscCommon.g_inputContext.preventVirtualKeyboard(e);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment