Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions demo/VueRoughNotation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@
</div>
</div>

<div class="section" style="background-color: #f5f5f5;">
<div class="content">
<h3>
<RoughNotation
:is-show="true"
type="box"
:color="colorChanging"
:stroke-width="strokeWidthChanging"
:padding="paddingChanging"
>Reactive change</RoughNotation>
</h3>
<p>
Color, Stroke width, Padding will change reactively
</p>
</div>
</div>

<div class="content">
<p>
<a target="_blank" href="https://github.com/Leecason/vue-rough-notation/tree/master/demo">
Expand All @@ -109,6 +126,12 @@
</template>

<script>
Array.prototype.getNext = function () {
let el = this.shift();
this.push( el );
return el;
}

export default {
name: 'VueRoughNotation',

Expand Down Expand Up @@ -189,6 +212,20 @@ export default {
],
showGroup: false,
showNoAnim: false,
colorChanging: '#263238',
strokeWidthChanging: 1,
paddingChanging: 1
}),

mounted() {
let colors = ['#263238', '#b71c1c', '#4a148c', '#0d47a1', '#ffd54f', '#ffd54f', '#1b5e20', '#f57f17']
setInterval(() => {
this.colorChanging = colors.getNext()
if(this.strokeWidthChanging > 6) this.strokeWidthChanging = 0
this.strokeWidthChanging++
if(this.paddingChanging > 9) this.paddingChanging = 0
this.paddingChanging += 3
}, 500)
},
};
</script>
10 changes: 10 additions & 0 deletions src/components/RoughNotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ export default (options) => ({
this.hide();
}
}, { immediate: true });

this.$watch('color', (value) => {
this.annotation.color = value
});
this.$watch('strokeWidth', (value) => {
this.annotation.strokeWidth = value
});
this.$watch('padding', (value) => {
this.annotation.padding = value
});
},

beforeDestroy () {
Expand Down