Skip to content
Permalink
Browse files

Added features for scrollIntoView with options

  • Loading branch information
darkfrog26 committed Oct 21, 2019
1 parent ce0e1a2 commit d12b740cfb06423d9cdb710a24f939b88025f351
@@ -0,0 +1,8 @@
package io.youi

import scala.scalajs.js

@js.native
trait ElementFeatures extends js.Object {
def scrollIntoView(options: ScrollIntoViewOptions): Unit
}
@@ -0,0 +1,9 @@
package io.youi

import scala.scalajs.js

trait ScrollIntoViewOptions extends js.Object {
var behavior: js.UndefOr[String] = js.undefined
var block: js.UndefOr[String] = js.undefined
var inline: js.UndefOr[String] = js.undefined
}
@@ -9,6 +9,7 @@ import org.scalajs.dom.raw.HTMLElement
import scala.collection.mutable
import scala.concurrent.{Future, Promise}
import scala.language.implicitConversions
import scala.scalajs.js

object dom extends ExtendedElement(None) {
def bySelector[T <: Element](selectors: String, root: Option[Element] = None): Vector[T] = {
@@ -85,6 +86,9 @@ object dom extends ExtendedElement(None) {
}
}

// Existing HTML features that Scala.js doesn't already provide
implicit def element2Features(element: html.Element): ElementFeatures = element.asInstanceOf[ElementFeatures]

implicit class ElementExtras[E <: Element](e: E) extends ExtendedElement(Some(e)) {
def parentByTag[T <: HTMLElement](tagName: String): Option[T] = findParentRecursive[T](e.asInstanceOf[HTMLElement], (p: HTMLElement) => {
p.tagName == tagName

0 comments on commit d12b740

Please sign in to comment.
You can’t perform that action at this time.