Skip to content

Conversation

@Jacky0299
Copy link
Contributor

closes #667

Copy link
Member

@prushforth prushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although layerAttribute is a pretty good name, unless you are planning to test the other attributes of the layer element in this same file, I would focus the name the test layerOpacityAttribute.test.js, to be clear.


test("Setting Opacity Attibute to Layer- Element", async () => {
let opacity_attribute_value = await page.$eval("body > mapml-viewer > layer-",(layer) => layer.getAttribute("opacity"));
if (opacity_attribute_value == null){
Copy link
Member

@prushforth prushforth Jan 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you want to use "===" mostly in JavaScript (strict equality). However, I believe that you can re-phrase the logic of this as:

if (opacity_attribute_value) {
...
}

let opacity = await page.$eval("body > mapml-viewer > layer-", (layer) => layer.opacity);
// console.log(opacity);
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to (try to) maintain one style of code block

Generally I prefer

if (something) {
...
} else if (something_else) {
...
} else {
...
}

Copy link
Member

@prushforth prushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions very well, AFAICT! Please make the style changes suggested! We can merge after that.

I think we could add an opacity attribute to the <map-extent> element now and you will be better able to understand what the impacts are, although we don't have a <map-extent> custom element yet (soon!).

@AliyanH AliyanH marked this pull request as ready for review January 31, 2023 18:46
@AliyanH
Copy link
Member

AliyanH commented Jan 31, 2023

Works very nicely! Since a new attribute has been added to the layer, you should also update the web-map-doc to document the change (https://maps4html.org/web-map-doc/docs/layers/layer/#attributes). The API for the layer's opacity has already been documented here.

@AliyanH
Copy link
Member

AliyanH commented Feb 1, 2023

Looks good @Jacky0299! Feel free to "Squash and merge" when ready. Good work! You can also merge the documentation, once this is merged.

@Jacky0299 Jacky0299 merged commit 738f280 into Maps4HTML:main Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<layer- style="opacity: 0.5"> does not set initial opacity

3 participants