Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
iconfalse
titleThis page has been translated automatically

We want to provide you with the latest help content in your language as soon as possible. This page has been translated automatically and may contain grammatical errors or inaccuracies. We want this content to be useful to you. Please let us know at the bottom of this page if this information was helpful.

View the original article in Russian: Touch-события

Начиная с версии Starting with version 7.1.4.0, в a Touch property with a set of methods has been added to the CommandCenter.Tab добавлено свойство Touch с набором методов. В свойстве Touch есть базовые методы: TouchStartTouchEndTouchMoveTouchCancel, а так же комплексные методы с перегрузками TouchSwipeIntoViewSwipeBetween и другие.

Это только первый этап внедрения тач-событий в браузере Chrome, поэтому они пока что доступны только из C# кода. В ближайших версиях будет реализовано управление из интерфейса.

Примеры

...

. The Touch property has basic methods: TouchStart , TouchEnd , TouchMove , TouchCancel , as well as complex methods with Touch overloads, SwipeIntoView , SwipeBetween and others.

This is only the first stage of implementing touch events in the Chrome browser, so for now they are only available from C # code. In the next versions, control from the interface will be implemented.

Examples of

Emulation of touch-pressing

...

Code Block
languagec#
var tab = instance.ActiveTab;
var init = tab.FindElementByXPath("/html/body/button", 0); // Ищем HTML элемент через XPath
tab.Touch.Touch(init); // Жмём по нему

...

Scrolling

...

Code Block
languagec#
var tab = instance.ActiveTab;
HtmlElement init = tab.FindElementByXPath(".//button", 0); // Ищем HTML элемент через XPath
tab.Touch.SwipeIntoView(init); // Скроллим экран тачами до нужного HTML элемента

...

Swipe right

...

Code Block
languagec#
var tab = instance.ActiveTab;

// Будем делать свайп внутри HTML элемента. Составим XPath выражение.
var canvas = tab.FindElementByXPath(@"//*[@id=""canvas""]", 0);

// Получаем его размеры: ширину и высоту
var width = canvas.BoundingClientWidth;
var height = canvas.BoundingClientHeight;

// Определяем координаты первого касания по оси X, и последнего - когда отпускаем палец
var offsetX = width / 4;
var minX = canvas.DisplacementInBrowser.X + offsetX;
var maxX = minX + width - 2*offsetX;

// Определяем координаты первого касания по оси Y, и последнего - когда отпускаем палец
var offsetY = height / 4;
var minY = canvas.DisplacementInBrowser.Y + offsetY;
var maxY = minY;

// Делаем свайп вправо
tab.Touch.SwipeBetween(minX, minY, maxX, maxY);

...

Settings

By default, a number of parameters are taken into account and randomized: speed, acceleration, motion curve, and others. All movements will be as natural as possible out of the box, but if you need to make adjustments to the behavior of touch events, there is such a possibility too.

Code Block
languagec#
var tab = instance.ActiveTab;
var parameters = tab.Touch.GetCopyOfTouchEmulationParameters(); // Получаем текущие настройки тача
// Дальше пишем "parameters." и после точки syntax editor подскажет доступны поля этого объекта.

////////////////////////
// Некоторые примеры
////////////////////////
parameters.Acceleration = 1.2f; // Поставим ускорение посильнее

parameters.MinCurvature = 0; // Пусть минимальная кривизна - прямая линия
parameters.MaxCurvature = 1; // А максимальная кривизна - очень сильный изгиб

// Изгиб кривой ближе к начальной точке
parameters.MinCurvePeakShift = 0f;
parameters.MaxCurvePeakShift = 0.2f;

parameters.MinStep = 1; // Начальная скорость пониже
parameters.MaxStep = 60; // А финальная - выше

parameters.RightThumbProbability = 0.7f; // В 70% случаев будет использоваться правый палец, а в 30% - левый.

tab.Touch.SetTouchEmulationParameters(parameters); // ВАЖНО: ПРИМЕНЯЕМ НАСТРОЙКИ - ИНАЧЕ НИЧЕГО НЕ ИЗМЕНИТСЯ

// Ещё больше настроек здесь: https://help.zennolab.com/en/v7/zennoposter/7.1.4/webframe.html#topic951.html
// instance.ActiveTab.Touch.SetTouchEmulationParameters(new TouchEmulationParameters()); // Устанавливаем настройки по умолчанию

Demonstration project

...

Download

View file
nametouch-sample-project.zp