Skip to content

Commit 0325be1

Browse files
author
Guillaume Chau
committed
refactor(widget): zoom factor
1 parent e537ef2 commit 0325be1

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

packages/@vue/cli-ui/src/components/Widget.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ import WIDGET_CONFIG_OPEN from '../graphql/widgetConfigOpen.gql'
138138
import WIDGET_CONFIG_SAVE from '../graphql/widgetConfigSave.gql'
139139
140140
const GRID_SIZE = 200
141+
const ZOOM = 0.7
141142
142143
const state = new Vue({
143144
data: {
@@ -169,12 +170,14 @@ export default {
169170
170171
Movable({
171172
field: 'widget',
172-
gridSize: GRID_SIZE
173+
gridSize: GRID_SIZE,
174+
zoom: ZOOM
173175
}),
174176
175177
Resizable({
176178
field: 'widget',
177-
gridSize: GRID_SIZE
179+
gridSize: GRID_SIZE,
180+
zoom: ZOOM
178181
})
179182
],
180183
@@ -353,6 +356,8 @@ export default {
353356
<style lang="stylus" scoped>
354357
@import "~@/style/imports"
355358
359+
$zoom = .7
360+
356361
.shell,
357362
.move-ghost,
358363
.resize-ghost
@@ -461,15 +466,15 @@ export default {
461466
462467
.customizing
463468
.wrapper
464-
border-radius ($br / .7)
469+
border-radius ($br / $zoom)
465470
466471
.content-wrapper
467472
opacity .5
468473
filter blur(8px)
469474
470475
.customize-overlay
471476
/deep/ > *
472-
transform scale(1/.7)
477+
transform scale(1/$zoom)
473478
474479
.resize-handle
475480
position absolute
@@ -515,7 +520,7 @@ export default {
515520
z-index 10000
516521
.backdrop
517522
background rgba($vue-ui-color-accent, .2)
518-
border-radius ($br / .7)
523+
border-radius ($br / $zoom)
519524
.vue-ui-dark-mode &
520525
background rgba(lighten($vue-ui-color-accent, 60%), .2)
521526
@@ -551,6 +556,6 @@ export default {
551556
&.v-enter,
552557
&.v-leave-to
553558
.shell
554-
transform scale(.7)
559+
transform scale($zoom)
555560
opacity 0
556561
</style>

packages/@vue/cli-ui/src/mixins/Movable.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export default function movable ({
22
gridSize,
3-
field
3+
field,
4+
zoom
45
}) {
56
// @vue/component
67
return {
@@ -23,8 +24,8 @@ export default function movable ({
2324
updateMoveState (e) {
2425
const mouseDeltaX = e.clientX - this.$_initalMousePosition.x
2526
const mouseDeltaY = e.clientY - this.$_initalMousePosition.y
26-
const pxX = this[field].x * gridSize + mouseDeltaX / 0.7
27-
const pxY = this[field].y * gridSize + mouseDeltaY / 0.7
27+
const pxX = this[field].x * gridSize + mouseDeltaX / zoom
28+
const pxY = this[field].y * gridSize + mouseDeltaY / zoom
2829
let x = Math.round(pxX / gridSize)
2930
let y = Math.round(pxY / gridSize)
3031
if (x < 0) x = 0

packages/@vue/cli-ui/src/mixins/Resizable.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export default function ({
22
gridSize,
3-
field
3+
field,
4+
zoom
45
}) {
56
// @vue/component
67
return {
@@ -47,8 +48,8 @@ export default function ({
4748
},
4849

4950
updateResizeState (e) {
50-
const mouseDeltaX = (e.clientX - this.$_initalMousePosition.x) / 0.7
51-
const mouseDeltaY = (e.clientY - this.$_initalMousePosition.y) / 0.7
51+
const mouseDeltaX = (e.clientX - this.$_initalMousePosition.x) / zoom
52+
const mouseDeltaY = (e.clientY - this.$_initalMousePosition.y) / zoom
5253
const handle = this.$_resizeHandle
5354
let dX = 0
5455
let dY = 0

0 commit comments

Comments
 (0)