Skip to content

Commit

Permalink
Exposure of measuredWidth and measuredHeight in Component
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Apr 26, 2018
1 parent fe35f91 commit dba80fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions ui/js/src/main/scala/io/youi/component/Component.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,17 @@ trait Component extends TaskSupport with ComponentTheme {
}
}

protected def measuredWidth: Double
protected def measuredHeight: Double

override def toString: String = id()
}

object Component extends ComponentTheme {
def childrenFor(component: Component): Vector[Component] = component.childComponents

object measured {
def width(component: Component): Double = component.measuredWidth
def height(component: Component): Double = component.measuredHeight
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ trait HTMLComponent[E <: html.Element] extends Component {
size.measured.width := measuredWidth
size.measured.height := measuredHeight
}
protected def measuredWidth: Double = element.offsetWidth // + margin.left() + margin.right()
protected def measuredHeight: Double = element.offsetHeight // + margin.top() + margin.bottom()
override protected def measuredWidth: Double = element.offsetWidth // + margin.left() + margin.right()
override protected def measuredHeight: Double = element.offsetHeight // + margin.top() + margin.bottom()
}

object HTMLComponent {
Expand Down

0 comments on commit dba80fd

Please sign in to comment.