Fixed missing ellipsis in header if JavaScript is enabled

This commit is contained in:
squidfunk
2017-11-19 17:28:00 +01:00
committed by Martin Donath
parent 354c713e4f
commit e6a5e2e160
7 changed files with 51 additions and 47 deletions

View File

@@ -59,12 +59,31 @@ export default class Title {
}
/**
* Update title state
* Setup title state
*/
update() {
setup() {
Array.prototype.forEach.call(this.el_.children, node => { // TODO: use childNodes here for IE?
node.style.width = `${this.el_.offsetWidth - 20}px`
})
}
/**
* Update title state
*
* @param {Event} ev - Event
*/
update(ev) {
const active = window.pageYOffset >= this.header_.offsetTop
if (active !== this.active_)
this.el_.dataset.mdState = (this.active_ = active) ? "active" : ""
/* Hack: induce ellipsis on topics */
if (ev.type === "resize") {
Array.prototype.forEach.call(this.el_.children, node => {
node.style.width = `${this.el_.offsetWidth - 20}px`
})
}
}
/**
@@ -72,6 +91,7 @@ export default class Title {
*/
reset() {
this.el_.dataset.mdState = ""
this.el_.style.width = ""
this.active_ = false
}
}