UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

196 lines (160 loc) 6.78 kB
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>The source code</title> <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="../resources/prettify/prettify.js"></script> <style type="text/css"> .highlight { display: block; background-color: #ddd; } </style> <script type="text/javascript"> function highlight() { document.getElementById(location.hash.replace(/#/, "")).className = "highlight"; } </script> </head> <body onload="prettyPrint(); highlight();"> <pre class="prettyprint lang-js">/* Siesta 5.6.1 Copyright(c) 2009-2022 Bryntum AB https://bryntum.com/contact https://bryntum.com/products/siesta/license */ <span id='Siesta-Test-Action-TouchDrag'>/** </span> @class Siesta.Test.Action.TouchDrag @extends Siesta.Test.Action This action can be included in the `t.chain` call with the &quot;touchDrag&quot; shortcut: t.chain( { action : &#39;touchDrag&#39;, target : someDOMElementOrArray, to : someDOMElementOrArray }, { action : &#39;touchDrag&#39;, target : someDOMElementOrArray, by : [ 10, 10 ] }, // or { touchDrag : someDOMElementOrArray, to : someDOMElementOrArray } ) This action will perform a {@link Siesta.Test.Browser#dragTo dragTo} or {@link Siesta.Test.Browser#dragBy dragBy} actions on the provided {@link #target}. */ Class(&#39;Siesta.Test.Action.TouchDrag&#39;, { isa : Siesta.Test.Action, does : Siesta.Test.Action.Role.HasTarget, has : { requiredTestMethod : &#39;touchDragTo&#39;, <span id='Siesta-Test-Action-TouchDrag-cfg-target'> /** </span> * @cfg {Siesta.Test.ActionTarget/Function} target * * The initial point of dragging operation. Can be provided as Siesta.Test.ActionTarget or the function returning it. * Will also be passed further to the next step. */ <span id='Siesta-Test-Action-TouchDrag-cfg-source'> /** </span> * @cfg {Siesta.Test.ActionTarget/Function} source * * Alias for {@link #target}. This may sound confusing, but &quot;target&quot; of &quot;drag&quot; action is its &quot;source&quot; in the same time. */ <span id='Siesta-Test-Action-TouchDrag-cfg-to'> /** </span> * @cfg {Siesta.Test.ActionTarget/Function} to * * The target point of dragging operation. Can be provided as the DOM element, the array with screen coordinates: `[ x, y ]`, or the function * returning one of those. * * Exactly one of the `to` and `by` configuration options should be provided for this action. */ to : null, <span id='Siesta-Test-Action-TouchDrag-cfg-fromOffset'> /** </span> * @cfg {Array} fromOffset * * An offset in X, Y coordinates from the source element. Can be also specified as `offset` config. */ fromOffset : null, <span id='Siesta-Test-Action-TouchDrag-cfg-toOffset'> /** </span> * @cfg {Array} toOffset * * An offset in X, Y coordinates from the targeted element */ toOffset : null, <span id='Siesta-Test-Action-TouchDrag-cfg-by'> /** </span> * @cfg {Array/Function} by * * The delta for dragging operation. Should be provided as the array with delta value for each coordinate: `[ dX, dY ]` or the function returning such. * * Exactly one of the `to` and `by` configuration options should be provided for this action. */ by : null, <span id='Siesta-Test-Action-TouchDrag-cfg-dragOnly'> /** </span> * @cfg {Boolean} dragOnly * * True to skip the mouseup and not finish the drop operation (one can start another drag operation, emulating the pause during drag-n-drop). */ dragOnly : false, byOrToMissingText : &#39;Either &quot;to&quot; or &quot;by&quot; configuration option is required for &quot;drag&quot; step&#39;, byAndToDefinedText : &#39;Exactly one of &quot;to&quot; or &quot;by&quot; configuration options is required for &quot;drag&quot; step, not both&#39; }, override : { BUILD : function (config) { // allow &quot;source&quot; as synonym for &quot;target&quot; // sounds weird, but &quot;target&quot; in action domain means source point for dragging if (config.source &amp;&amp; !config.target) config.target = config.source return this.SUPER(config) } }, methods : { initialize : function () { this.SUPER() if (!this.to &amp;&amp; !this.by) throw this.byOrToMissingText if (this.to &amp;&amp; this.by) throw this.byAndToDefinedText }, getTo : function () { if (this.test.typeOf(this.to) == &#39;Function&#39;) return this.to.call(this.test, this) else return this.to }, getBy : function () { if (this.test.typeOf(this.by) == &#39;Function&#39;) return this.by.call(this.test, this) else return this.by }, process : function () { var next = this.next; var test = this.test var target = this.getTarget(); var normalizedTarget = test.normalizeActionTarget(target, true) if (this.to) { test.touchDragTo( target, this.getTo(), function() { next(normalizedTarget || test.normalizeActionTarget(target)); }, null, this.options, this.dragOnly, this.fromOffset || this.offset, this.toOffset ) } else { test.touchDragBy( target, this.getBy(), function() { next(normalizedTarget || test.normalizeActionTarget(target)); }, null, this.options, this.dragOnly, this.fromOffset || this.offset ) } } } }); Siesta.Test.ActionRegistry().registerAction(&#39;touchdrag&#39;, Siesta.Test.Action.TouchDrag)</pre> </body> </html>