From 8d3347bcfbcdd1d307cfeba81af438c7f263e72f Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 17 Oct 2018 13:36:15 +0200 Subject: [PATCH] fix lint --- src/components/views/elements/ResizeHandle.js | 2 +- src/resizer/distributors.js | 5 ++--- src/resizer/resizer.js | 2 ++ src/resizer/sizer.js | 20 ++++++++++++++----- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/components/views/elements/ResizeHandle.js b/src/components/views/elements/ResizeHandle.js index ae324a752b..4c09278f84 100644 --- a/src/components/views/elements/ResizeHandle.js +++ b/src/components/views/elements/ResizeHandle.js @@ -14,7 +14,7 @@ const ResizeHandle = (props) => { classNames.push('mx_ResizeHandle_reverse'); } return ( -
+
); }; diff --git a/src/resizer/distributors.js b/src/resizer/distributors.js index 93a75d474e..a5ef48e571 100644 --- a/src/resizer/distributors.js +++ b/src/resizer/distributors.js @@ -46,15 +46,14 @@ class CollapseDistributor extends FixedDistributor { } resize(offset) { - let newSize = this.sizeFromOffset(offset); + const newSize = this.sizeFromOffset(offset); const isCollapsedSize = newSize < this.toggleSize; if (isCollapsedSize && !this.isCollapsed) { this.isCollapsed = true; if (this.onCollapsed) { this.onCollapsed(true, this.item); } - } - else if (!isCollapsedSize && this.isCollapsed) { + } else if (!isCollapsedSize && this.isCollapsed) { if (this.onCollapsed) { this.onCollapsed(false, this.item); } diff --git a/src/resizer/resizer.js b/src/resizer/resizer.js index 8888287b86..10f08aa546 100644 --- a/src/resizer/resizer.js +++ b/src/resizer/resizer.js @@ -101,6 +101,7 @@ export class Resizer { const vertical = resizeHandle.classList.contains(this.classNames.vertical); const reverse = resizeHandle.classList.contains(this.classNames.reverse); + // eslint-disable-next-line new-cap const sizer = new this.sizerCtor(this.container, vertical, reverse); const items = this._getResizableItems(); @@ -108,6 +109,7 @@ export class Resizer { // if reverse, resize the item after the handle instead of before, so + 1 const itemIndex = items.indexOf(prevItem) + (reverse ? 1 : 0); const item = items[itemIndex]; + // eslint-disable-next-line new-cap const distributor = new this.distributorCtor( sizer, item, this.distributorCfg, items, this.container); diff --git a/src/resizer/sizer.js b/src/resizer/sizer.js index b39aaea286..674ea1823c 100644 --- a/src/resizer/sizer.js +++ b/src/resizer/sizer.js @@ -39,7 +39,10 @@ class Sizer { item.style.flexGrow = Math.round(percent * 1000); } - /** returns how far the edge of the item is from the edge of the container */ + /** + @param {Element} item the dom element being resized + @return {number} how far the edge of the item is from the edge of the container + */ getItemOffset(item) { const offset = (this.vertical ? item.offsetTop : item.offsetLeft) - this._getOffset(); if (this.reverse) { @@ -49,17 +52,20 @@ class Sizer { } } - /** returns the width/height of an item in the container */ + /** + @param {Element} item the dom element being resized + @return {number} the width/height of an item in the container + */ getItemSize(item) { return this.vertical ? item.offsetHeight : item.offsetWidth; } - /** returns the width/height of the container */ + /** @return {number} the width/height of the container */ getTotalSize() { return this.vertical ? this.container.offsetHeight : this.container.offsetWidth; } - /** container offset to offsetParent */ + /** @return {number} container offset to offsetParent */ _getOffset() { return this.vertical ? this.container.offsetTop : this.container.offsetLeft; } @@ -72,7 +78,11 @@ class Sizer { } } - /** returns the position of cursor at event relative to the edge of the container */ + /** + @param {MouseEvent} event the mouse event + @return {number} the distance between the cursor and the edge of the container, + along the applicable axis (vertical or horizontal) + */ offsetFromEvent(event) { const pos = this.vertical ? event.pageY : event.pageX; if (this.reverse) {