|
7#
楼主 |
发表于 2012-5-14 09:59:18
|
只看该作者
Share with you.(write as JavaScript)
var target = UIATarget.localTarget();
var application = target.frontMostApp();
var mainWindow = application.mainWindow();
mainWindow.dragInsideWithOptions({startOffset:{x:0.0, y:0.0}, endOffset:{x:0.8, y:0.10}, duration:1});
The method that used to swipe the page is dragInsideWithOptions, Here are description from apple
dragInsideWithOptions
Drags within the bounds of an element.
(undefined) dragInsideWithOptions(Object options)
Parameters
options
A dictionary that specifies characteristics of the gesture. Valid keys are as follows:
touchCount The number of touches to use in the specified gesture. (Effectively, the number of fingers a user would use to make the specified gesture.) The default touch count value is 1.
duration The length of hold time for the specified gesture. The default duration value for a tap is 0. The default value for touch-and-hold gestures (such as drag, pinch open, and pinch close) is 1.
startOffset The first offset to use for a multiple-point gesture. The default value is {x:0.0, y:0.0}. See the discussion for details.
endOffset The last offset to use for a multiple-point gesture. The default value is {x:0.0, y:0.0}. See the discussion for details.
Discussion
You can use offsets to achieve finer precision in specifying the hitpoint within the rect for the specified element. The offset comprises a pair of x and y values, each ranging from 0.0 to 1.0. These values represent, respectively, relative horizontal and vertical positions within the rect, with {x:0.0, y:0.0} as the top left and {x:1.0, y:1.0} as the bottom right. Thus, {x:0.3, y:0.6} specifies a position just below and to the left of center, and {x:1.0, y:0.5} specifies a position centered vertically at the far right.
This example performs a slow drag within the target element from left edge to right edge, just below the top:
target.dragInsideWithOptions({startOffset:{x:0.0, y:0.1}, endOffset:{x:1.0, y:0.1}, duration:1.5}); |
|