diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-12-22 11:10:36 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-22 11:10:36 +0900 |
commit | b1a6f374dca078dee2406ebe049715b826e37ca2 (patch) | |
tree | 5367c48648e2018f55f12d847baba94559e10040 /src/shared/utils | |
parent | b2dcdedad729ff7087867da50e20578f9fc8fb29 (diff) | |
parent | da72c2ddd916d79d134662e3985b53a4ac78af7a (diff) |
Merge pull request #690 from ueokande/eslint-and-prettier
Eslint and prettier
Diffstat (limited to 'src/shared/utils')
-rw-r--r-- | src/shared/utils/dom.ts | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/shared/utils/dom.ts b/src/shared/utils/dom.ts index c1f2190..a6186cb 100644 --- a/src/shared/utils/dom.ts +++ b/src/shared/utils/dom.ts @@ -1,5 +1,5 @@ const isContentEditable = (element: Element): boolean => { - let value = element.getAttribute('contenteditable'); + const value = element.getAttribute('contenteditable'); if (value === null) { return false; } @@ -14,12 +14,12 @@ interface Rect { } const rectangleCoordsRect = (coords: string): Rect => { - let [left, top, right, bottom] = coords.split(',').map(n => Number(n)); + const [left, top, right, bottom] = coords.split(',').map(n => Number(n)); return { left, top, right, bottom }; }; const circleCoordsRect = (coords: string): Rect => { - let [x, y, r] = coords.split(',').map(n => Number(n)); + const [x, y, r] = coords.split(',').map(n => Number(n)); return { left: x - r, top: y - r, @@ -29,14 +29,14 @@ const circleCoordsRect = (coords: string): Rect => { }; const polygonCoordsRect = (coords: string): Rect => { - let params = coords.split(','); + const params = coords.split(','); let minx = Number(params[0]), maxx = Number(params[0]), miny = Number(params[1]), maxy = Number(params[1]); - let len = Math.floor(params.length / 2); + const len = Math.floor(params.length / 2); for (let i = 2; i < len; i += 2) { - let x = Number(params[i]), + const x = Number(params[i]), y = Number(params[i + 1]); if (x < minx) { minx = x; @@ -59,15 +59,15 @@ const viewportRect = (e: Element): Rect => { return e.getBoundingClientRect(); } - let mapElement = e.parentNode as HTMLMapElement; - let imgElement = document.querySelector( + const mapElement = e.parentNode as HTMLMapElement; + const imgElement = document.querySelector( `img[usemap="#${mapElement.name}"]` ) as HTMLImageElement; - let { + const { left: mapLeft, top: mapTop } = imgElement.getBoundingClientRect(); - let coords = e.getAttribute('coords'); + const coords = e.getAttribute('coords'); if (!coords) { return e.getBoundingClientRect(); } @@ -96,8 +96,8 @@ const viewportRect = (e: Element): Rect => { }; const isVisible = (element: Element): boolean => { - let rect = element.getBoundingClientRect(); - let style = window.getComputedStyle(element); + const rect = element.getBoundingClientRect(); + const style = window.getComputedStyle(element); if (style.overflow !== 'visible' && (rect.width === 0 || rect.height === 0)) { return false; @@ -113,7 +113,7 @@ const isVisible = (element: Element): boolean => { return false; } - let { display, visibility } = window.getComputedStyle(element); + const { display, visibility } = window.getComputedStyle(element); if (display === 'none' || visibility === 'hidden') { return false; } |