Answer the question
In order to leave comments, you need to log in
How to dynamically resize a block?
I'm trying to implement block resizing when scrolling the mouse wheel. When inspecting the element, I see that the transform property changes, but visually the block doesn't change.
https://jsfiddle.net/eo9L1452/
<div
class="workspase"
id="workspase"
@mousewheel.passive="handleZoom($event)"
>
<div
style="width: 100px; height: 100px; background: red;"
:transform="computedMatrix"
></div>
</div>
export default {
data () {
return {
matrix: { a: 1, b: 0, c: 0, d: 1, x: 0, y: 0 },
zoom: 1,
}
},
computed: {
computedMatrix () {
const { a, b, c, d, x, y } = this.matrix
return `matrix(${this.zoom}, ${b}, ${c}, ${this.zoom}, ${x}, ${y})`
},
},
methods: {
handleZoom ({ deltaY }) {
this.zoom = deltaY < 0 ? (this.zoom * 10 + 1) / 10 : (this.zoom * 10 - 1) / 10
},
},
}
.workspase {
width: 800px;
height: 500px;
border: 2px solid black;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question