A platform for community discussion. Free, open, simple.
prettierjs formatting
Jeff Wongf4d77037d071
diff --git a/app/assets/javascripts/discourse/components/topic-navigation.js.es6 b/app/assets/javascripts/discourse/components/topic-navigation.js.es6index 6e41bacfff8..8bf68dc0993 100644--- a/app/assets/javascripts/discourse/components/topic-navigation.js.es6+++ b/app/assets/javascripts/discourse/components/topic-navigation.js.es6@@ -112,20 +112,20 @@ export default Ember.Component.extend(PanEvents, {},_panOpenClose(offset, velocity, direction) {-const $timelineContainer = $(".timeline-container");const maxOffset = parseInt($timelineContainer.css("height"));- direction === "close" ? offset += velocity : offset -= velocity;+ direction === "close" ? (offset += velocity) : (offset -= velocity);$timelineContainer.css("bottom", -offset);- if(offset > maxOffset) {+ if (offset > maxOffset) {this._collapseFullscreen();- }- else if(offset <= 0) {+ } else if (offset <= 0) {$timelineContainer.css("bottom", "");- }- else {- Ember.run.later(() => this._panOpenClose(offset, velocity, direction), 20);+ } else {+ Ember.run.later(+ () => this._panOpenClose(offset, velocity, direction),+ 20+ );}},@@ -138,27 +138,25 @@ export default Ember.Component.extend(PanEvents, {const $centeredElement = $(document.elementFromPoint(center.x, center.y));if ($centeredElement.parents(".timeline-scrollarea-wrapper").length) {this.set("isPanning", false);- }- else {+ } else {this.set("isPanning", true);}},panEnd(e) {- if(!this.get("isPanning")) {+ if (!this.get("isPanning")) {return;}this.set("isPanning", false);- if(this._shouldPanClose(e)) {+ if (this._shouldPanClose(e)) {this._panOpenClose(e.deltaY, 40, "close");- }- else {+ } else {this._panOpenClose(e.deltaY, 40, "open");}},panMove(e) {- if(!this.get("isPanning")) {+ if (!this.get("isPanning")) {return;}$(".timeline-container").css("bottom", Math.min(0, -e.deltaY));diff --git a/app/assets/javascripts/discourse/mixins/pan-events.js.es6 b/app/assets/javascripts/discourse/mixins/pan-events.js.es6index 8f9ce96351a..5188d8639d6 100644--- a/app/assets/javascripts/discourse/mixins/pan-events.js.es6+++ b/app/assets/javascripts/discourse/mixins/pan-events.js.es6@@ -1,45 +1,50 @@export default Ember.Mixin.create({-//velocity is pixels per ms_panState: null,didInsertElement() {- this.$().on("pointerdown", (e) => this._panStart(e))- .on("pointermove", (e) => this._panMove(e))- .on("pointerup", (e) => this._panMove(e))- .on("pointercancel", (e) => this._panMove(e));+ this.$()+ .on("pointerdown", e => this._panStart(e))+ .on("pointermove", e => this._panMove(e))+ .on("pointerup", e => this._panMove(e))+ .on("pointercancel", e => this._panMove(e));},willDestroyElement() {- this.$().off("pointerdown")+ this.$()+ .off("pointerdown").off("pointerup").off("pointermove").off("pointercancel");},_calculateNewPanState(oldState, e) {- if(e.type === "pointerup" || e.type === "pointercancel") {+ if (e.type === "pointerup" || e.type === "pointercancel") {return oldState;}const newTimestamp = new Date().getTime();- const timeDiffSeconds = (newTimestamp - oldState.timestamp);+ const timeDiffSeconds = newTimestamp - oldState.timestamp;//calculate delta x, y, distance from START locationconst deltaX = Math.round(e.clientX) - oldState.startLocation.x;const deltaY = Math.round(e.clientY) - oldState.startLocation.y;- const distance = Math.round(Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)));+ const distance = Math.round(+ Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2))+ );//calculate velocity from previous event center locationconst eventDeltaX = e.clientX - oldState.center.x;const eventDeltaY = e.clientY - oldState.center.y;const velocityX = eventDeltaX / timeDiffSeconds;const velocityY = eventDeltaY / timeDiffSeconds;- const deltaDistance = Math.sqrt(Math.pow(eventDeltaX, 2) + Math.pow(eventDeltaY, 2));+ const deltaDistance = Math.sqrt(+ Math.pow(eventDeltaX, 2) + Math.pow(eventDeltaY, 2)+ );const velocity = deltaDistance / timeDiffSeconds;return {startLocation: oldState.startLocation,- center: {x: Math.round(e.clientX), y: Math.round(e.clientY)},+ center: { x: Math.round(e.clientX), y: Math.round(e.clientY) },velocity,velocityX,velocityY,@@ -53,8 +58,8 @@ export default Ember.Mixin.create({_panStart(e) {const newState = {- center: {x: Math.round(e.clientX), y: Math.round(e.clientY)},- startLocation: {x: Math.round(e.clientX), y: Math.round(e.clientY)},+ center: { x: Math.round(e.clientX), y: Math.round(e.clientY) },+ startLocation: { x: Math.round(e.clientX), y: Math.round(e.clientY) },velocity: 0,velocityX: 0,velocityY: 0,@@ -71,14 +76,15 @@ export default Ember.Mixin.create({const previousState = this.get("_panState");const newState = this._calculateNewPanState(previousState, e);this.set("_panState", newState);- if(previousState.start && "panStart" in this) {+ if (previousState.start && "panStart" in this) {this.panStart(newState);- }- else if((e.type === "pointerup" || e.type === "pointercancel") && "panEnd" in this) {+ } else if (+ (e.type === "pointerup" || e.type === "pointercancel") &&+ "panEnd" in this+ ) {this.panEnd(newState);- }- else if(e.type === "pointermove" && "panMove" in this) {+ } else if (e.type === "pointermove" && "panMove" in this) {this.panMove(newState);}- },+ }});