also restore collapsed state to last user setting

This commit is contained in:
mike-000
2020-09-30 10:36:53 +01:00
committed by GitHub
parent 09a1dd43c6
commit cb77784d2a

View File

@@ -66,6 +66,12 @@ class Attribution extends Control {
this.collapsed_ =
options.collapsed !== undefined ? options.collapsed : true;
/**
* @private
* @type {boolean}
*/
this.userCollapsed_ = this.collapsed_;
/**
* @private
* @type {boolean}
@@ -265,6 +271,7 @@ class Attribution extends Control {
handleClick_(event) {
event.preventDefault();
this.handleToggle_();
this.userCollapsed_ = this.collapsed_;
}
/**
@@ -300,7 +307,7 @@ class Attribution extends Control {
}
this.collapsible_ = collapsible;
this.element.classList.toggle('ol-uncollapsible');
if (!collapsible && this.collapsed_) {
if (this.userCollapsed_) {
this.handleToggle_();
}
}
@@ -313,6 +320,7 @@ class Attribution extends Control {
* @api
*/
setCollapsed(collapsed) {
this.userCollapsed_ = collapsed;
if (!this.collapsible_ || this.collapsed_ === collapsed) {
return;
}