Skip to content

Commit

Permalink
Merge pull request #14607 from ahocevar/icon-width-api
Browse files Browse the repository at this point in the history
Do not use non-API methods in example
  • Loading branch information
ahocevar committed Mar 25, 2023
2 parents 215acd0 + 58f7a1a commit 7613ce5
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions examples/icon-width.js
Expand Up @@ -34,24 +34,53 @@ image.addEventListener('load', () => {
});

widthInput.addEventListener('input', (event) => {
iconStyle.getImage().setWidth(event.target.value);
iconFeature.changed();
const currentIcon = iconStyle.getImage();
iconStyle.setImage(
new Icon({
src: 'data/icon.png',
width: event.target.value,
height: currentIcon.getHeight(),
})
);
iconFeature.setStyle(iconStyle);
scaleSpan.innerText = formatScale(iconStyle.getImage().getScale());
});
heightInput.addEventListener('input', (event) => {
iconStyle.getImage().setHeight(event.target.value);
iconFeature.changed();
const currentIcon = iconStyle.getImage();
iconStyle.setImage(
new Icon({
src: 'data/icon.png',
height: event.target.value,
width: currentIcon.getWidth(),
})
);
iconFeature.setStyle(iconStyle);
scaleSpan.innerText = formatScale(iconStyle.getImage().getScale());
});
clearWidthButton.addEventListener('click', () => {
widthInput.value = undefined;
iconStyle.getImage().setWidth(undefined);
const currentIcon = iconStyle.getImage();
iconStyle.setImage(
new Icon({
src: 'data/icon.png',
height: currentIcon.getHeight(),
})
);
iconFeature.setStyle(iconStyle);
scaleSpan.innerText = formatScale(iconStyle.getImage().getScale());
iconFeature.changed();
});
clearHeightButton.addEventListener('click', () => {
heightInput.value = undefined;
iconStyle.getImage().setHeight(undefined);
const currentIcon = iconStyle.getImage();
iconStyle.setImage(
new Icon({
src: 'data/icon.png',
width: currentIcon.getWidth(),
})
);
iconFeature.setStyle(iconStyle);

scaleSpan.innerText = formatScale(iconStyle.getImage().getScale());
iconFeature.changed();
});
Expand Down

0 comments on commit 7613ce5

Please sign in to comment.