Skip to content

Commit 532c62c

Browse files
authored
Fix types and documentation for scrollTo() alignment options (#2703)
* Fix types and documentation for scrollTo() alignment options Signed-off-by: Bart van Oort <[email protected]> * Bump package version to 1.3.10 Signed-off-by: Bart van Oort <[email protected]> --------- Signed-off-by: Bart van Oort <[email protected]>
1 parent d831a72 commit 532c62c

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

lib/taiko.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,24 +1246,23 @@ async function mouseAction(selector, action, coordinates, options = {}) {
12461246
/**
12471247
* Scrolls the page to the given element.
12481248
* The alignment parameters can be overridden, see below.
1249-
* Tthe possible values reference are available at the https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
1250-
*
1249+
* A reference of the possible values for the alignment parameters is available at https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
12511250
*
12521251
* @example
12531252
* await scrollTo('Get Started')
12541253
* @example
12551254
* await scrollTo(link('Get Started'))
12561255
* @example
1257-
* await scrollTo('Get Started',{ alignments: { block: 'center', inline: 'center' }})
1256+
* await scrollTo('Get Started', { blockAlignment: 'center', inlineAlignment: 'center' })
12581257
*
12591258
* @param {selector|string} selector - A selector of an element to scroll to.
12601259
* @param {Object} options
12611260
* @param {boolean} [options.waitForNavigation=true] - Wait for navigation after the goto. Default navigationTimeout is 30 seconds to override pass `{ navigationTimeout: 10000 }` in `options` parameter.
12621261
* @param {string[]} [options.waitForEvents = []] - Events available to wait for ['DOMContentLoaded', 'loadEventFired', 'networkAlmostIdle', 'networkIdle', 'firstPaint', 'firstContentfulPaint', 'firstMeaningfulPaint', 'targetNavigated']
12631262
* @param {number} [options.navigationTimeout=30000] - Navigation timeout value in milliseconds for navigation after click.
1264-
* @param {number} [options.waitForStart = 100] - time to wait for navigation to start. Accepts value in milliseconds.
1265-
* @param {string} [options.blockAlignment = 'nearest'] - Defines vertical alignment.
1266-
* @param {string} [options.inlineAligment = 'nearest'] - Defines horizontal alignment.
1263+
* @param {number} [options.waitForStart = 100] - Time to wait for navigation to start. Accepts value in milliseconds.
1264+
* @param {string} [options.blockAlignment = 'nearest'] - Defines vertical alignment. One of `start`, `center`, `end` or `nearest`.
1265+
* @param {string} [options.inlineAlignment = 'nearest'] - Defines horizontal alignment. One of `start`, `center`, `end` or `nearest`.
12671266
*
12681267
* @returns {Promise<void>}
12691268
*/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "http://json.schemastore.org/package",
33
"name": "taiko",
4-
"version": "1.3.9",
4+
"version": "1.3.10",
55
"description": "Taiko is a Node.js library for automating Chromium based browsers",
66
"main": "bin/taiko.js",
77
"bin": {

types/taiko/index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export interface NavigationOptions extends BasicNavigationOptions, EventOptions
4949
waitForStart?: number;
5050
}
5151

52+
export interface ScrollOptions extends NavigationOptions {
53+
blockAlignment?: 'start' | 'center' | 'end' | 'nearest';
54+
inlineAlignment?: 'start' | 'center' | 'end' | 'nearest';
55+
}
56+
5257
export interface ReloadOptions extends NavigationOptions {
5358
ignoreCache?: boolean;
5459
}
@@ -501,7 +506,7 @@ export function mouseAction(
501506
options?: ForcedNavigationOptions,
502507
): Promise<void>;
503508
// https://docs.taiko.dev/api/scrollto
504-
export function scrollTo(selector: SearchElement, options?: NavigationOptions): Promise<void>;
509+
export function scrollTo(selector: SearchElement, options?: ScrollOptions): Promise<void>;
505510
// https://docs.taiko.dev/api/scrollright
506511
export function scrollRight(selector?: SearchElement | number, px?: number): Promise<void>;
507512
// https://docs.taiko.dev/api/scrollleft

0 commit comments

Comments
 (0)