2018-11-15 14:33:53 -05:00
|
|
|
package html
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2018-12-21 23:14:41 -05:00
|
|
|
|
2019-02-19 18:10:18 -05:00
|
|
|
"github.com/MontFerret/ferret/pkg/drivers"
|
2018-11-15 14:33:53 -05:00
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
|
|
|
)
|
|
|
|
|
2019-09-07 14:03:17 -04:00
|
|
|
// SCROLL_BOTTOM scrolls the document's window to its bottom.
|
2020-08-07 21:49:29 -04:00
|
|
|
// @param {HTMLDocument} document - HTML document.
|
|
|
|
// @param {Int | Float} x - X coordinate.
|
|
|
|
// @param {Int | Float} y - Y coordinate.
|
|
|
|
// @param {Object} [params] - Scroll params.
|
|
|
|
// @param {String} [params.behavior="instant"] - Scroll behavior
|
|
|
|
// @param {String} [params.block="center"] - Scroll vertical alignment.
|
|
|
|
// @param {String} [params.inline="center"] - Scroll horizontal alignment.
|
2019-02-20 21:24:05 -05:00
|
|
|
func ScrollBottom(ctx context.Context, args ...core.Value) (core.Value, error) {
|
2020-04-25 15:06:00 -04:00
|
|
|
err := core.ValidateArgs(args, 1, 2)
|
2018-11-15 14:33:53 -05:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return values.None, err
|
|
|
|
}
|
|
|
|
|
2019-06-19 17:58:56 -04:00
|
|
|
doc, err := drivers.ToDocument(args[0])
|
2018-11-15 14:33:53 -05:00
|
|
|
|
2019-02-19 18:10:18 -05:00
|
|
|
if err != nil {
|
|
|
|
return values.None, err
|
2018-11-15 14:33:53 -05:00
|
|
|
}
|
|
|
|
|
2020-04-25 15:06:00 -04:00
|
|
|
var opts drivers.ScrollOptions
|
|
|
|
|
|
|
|
if len(args) > 1 {
|
|
|
|
opts, err = toScrollOptions(args[1])
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return values.None, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return values.None, doc.ScrollBottom(ctx, opts)
|
2018-11-15 14:33:53 -05:00
|
|
|
}
|