From 0b21a2d10f7864ffcdc911468d89dfa8cb716e88 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Tue, 23 Feb 2021 11:13:47 +0000 Subject: [PATCH 1/3] Draft of displaced center. --- src/components/Main.vue | 90 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 9 deletions(-) diff --git a/src/components/Main.vue b/src/components/Main.vue index 9d5dd0f..e9e2ee8 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -75,6 +75,26 @@ label="Second step" /> +
+
+ +
+
+
+
+ +
+
this.drawCanvas()); }, + paramX () { + this.$nextTick(() => this.drawCanvas()); + }, + + paramY () { + this.$nextTick(() => this.drawCanvas()); + }, + colorMode () { this.$nextTick(() => this.drawCanvas()); }, @@ -288,4 +360,4 @@ main { max-width: 100%; } } - \ No newline at end of file + From 886ed7f2a100fb82fed4884d1acab70f3fbe9bbe Mon Sep 17 00:00:00 2001 From: nicolau-manubens <79514543+nicolau-manubens@users.noreply.github.com> Date: Tue, 23 Feb 2021 11:19:18 +0000 Subject: [PATCH 2/3] Fix comments in Main.vue --- src/components/Main.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Main.vue b/src/components/Main.vue index e9e2ee8..38d9123 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -144,11 +144,11 @@ export default { computed: { circlePoints () { - # method: drawing two circles, the first centered in (0, 0) and - # the second centered at (x_offset, y_offset). - # For each point in the upper semicircle of the first circle, we draw - # a line joining that point with (0, 0), and intersect such line with the - # displaced circle + // method: drawing two circles, the first centered in (0, 0) and + // the second centered at (x_offset, y_offset). + // For each point in the upper semicircle of the first circle, we draw + // a line joining that point with (0, 0), and intersect such line with the + // displaced circle const n_points = this.paramN; const r = 1.0; From b3a4e60419963b1d414ca7c2edeccfe4104fe0d2 Mon Sep 17 00:00:00 2001 From: Dusan Vuckovic Date: Tue, 23 Feb 2021 11:51:52 +0000 Subject: [PATCH 3/3] Extended input range component so it can handle floats too. --- src/components/InputRange.vue | 18 ++++++++++++------ tests/unit/InputRange.spec.js | 14 +++++++++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/components/InputRange.vue b/src/components/InputRange.vue index 7842fd5..d4c61f1 100644 --- a/src/components/InputRange.vue +++ b/src/components/InputRange.vue @@ -79,14 +79,20 @@ export default { }, set (newValue) { - const integerValue = parseInt(newValue, 10); + let castValue = newValue; - // Emit only integers that fall within the configured range. - if (Number.isNaN(integerValue)) return; - if (integerValue < this.min) return; - if (integerValue > this.max) return; + if (Number.isInteger(this.step)) { + castValue = parseInt(newValue, 10); + } + else { + castValue = parseFloat(newValue); + } - this.$emit('update:modelValue', integerValue); + if (Number.isNaN(castValue)) return; + if (castValue < this.min) return; + if (castValue > this.max) return; + + this.$emit('update:modelValue', castValue); }, }, }, diff --git a/tests/unit/InputRange.spec.js b/tests/unit/InputRange.spec.js index 02b1adb..d96fb3a 100644 --- a/tests/unit/InputRange.spec.js +++ b/tests/unit/InputRange.spec.js @@ -48,7 +48,7 @@ describe('InputRange', () => { delete wrapper.emitted()['update:modelValue']; }); - it('does not emit invalid values', async () => { + it('does rudimentary validation of input values', async () => { wrapper.setProps({ max: 5, }); @@ -72,6 +72,18 @@ describe('InputRange', () => { wrapper.find('input[type="number"]').setValue(modelValue); expect(wrapper.emitted()).toEqual({}); + + wrapper.setProps({ + step: 0.01, + }); + + await wrapper.vm.$nextTick(() => {}); + + modelValue = 0.05; + + wrapper.find('input[type="number"]').setValue(modelValue); + + expect(wrapper.emitted()['update:modelValue'][0]).toEqual([modelValue]); }); it ('supports the label prop', async () => {