1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-07-05 00:49:00 +02:00

Added scroll options (#471)

* Added scroll options

* Updated dependencies

* Updates after code review

* Updates after review

* Added comments
This commit is contained in:
Tim Voronov
2020-04-25 15:06:00 -04:00
committed by GitHub
parent 64fc010e6e
commit c9dfb79641
13 changed files with 419 additions and 100 deletions

View File

@ -13,8 +13,9 @@ import (
// @param doc (HTMLDocument) - HTML document.
// @param x (Int|Float) - X coordinate.
// @param y (Int|Float) - Y coordinate.
// @param options (ScrollOptions) - Scroll options. Optional.
func ScrollXY(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 3, 3)
err := core.ValidateArgs(args, 3, 4)
if err != nil {
return values.None, err
@ -41,5 +42,15 @@ func ScrollXY(ctx context.Context, args ...core.Value) (core.Value, error) {
x := values.ToFloat(args[1])
y := values.ToFloat(args[2])
return values.None, doc.ScrollByXY(ctx, x, y)
var opts drivers.ScrollOptions
if len(args) > 3 {
opts, err = toScrollOptions(args[3])
if err != nil {
return values.None, err
}
}
return values.None, doc.ScrollByXY(ctx, x, y, opts)
}