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