Skip to content

Commit eccf764

Browse files
committed
docs: add tutorial to creates a cropper-viewer
1 parent ceec10e commit eccf764

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,16 @@ onMounted(async () => {
8181
cropper: { constructOptions: undefined },
8282
image: { attributes: { class: 'blur' } },
8383
canvas: { attributes: { background: false } },
84-
selection: { attributes: undefined },
84+
selection: { attributes: { id: 'cropper-selection-86' } },
8585
selections: { attributes: undefined },
8686
}"
8787
/>
88+
89+
// To creates a 'cropper-viewer' component
90+
<component
91+
v-if="cropper?.cropperMounted"
92+
:is="h('cropper-viewer', { selection: '#cropper-selection-86' })"
93+
/>
8894
...
8995

9096
```

docs/App.vue

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- eslint-disable no-console -->
22
<script lang="ts" setup>
3-
import { onMounted, ref, useTemplateRef } from 'vue'
3+
import { onMounted, ref, useTemplateRef, h } from 'vue'
44
import { ModernCropper } from '~/index'
55
import { isDark, toggleDarkmode } from '@/composables/useDarkmode'
66
@@ -69,10 +69,16 @@ onMounted(async () => {
6969
cropper: { constructOptions: undefined },
7070
image: { attributes: { class: 'blur' } },
7171
canvas: { attributes: { background: false } },
72-
selection: { attributes: undefined },
72+
selection: { attributes: { id: 'cropper-selection-86' } },
7373
selections: { attributes: undefined },
7474
}"
7575
/>
76+
77+
// To creates a 'cropper-viewer' component
78+
<component
79+
v-if="cropper?.cropperMounted"
80+
:is="h('cropper-viewer', { selection: '#cropper-selection-86' })"
81+
/>
7682
...
7783
`
7884
</script>
@@ -139,9 +145,12 @@ onMounted(async () => {
139145
<Highlight :autodetect="false" language="javascript" :code="demoCode0" />
140146
</main>
141147

142-
<div class="my-2 text-primary">
148+
<div class="my-2 text-primary flex flex-col gap-4">
143149
Check out cropperjs's document: <a href="https://fengyuanchen.github.io/cropperjs/" class="text-#3399ff">https://fengyuanchen.github.io/cropperjs/</a>
144-
<div class="flex items-center justify-center">
150+
151+
<hr>
152+
153+
<div class="flex items-center justify-center gap-10">
145154
<ModernCropper
146155
ref="cropper"
147156
class="h-40 w-80"
@@ -150,10 +159,17 @@ onMounted(async () => {
150159
cropper: { constructOptions: undefined },
151160
image: { attributes: { class: 'blur' } },
152161
canvas: { attributes: { background: false } },
153-
selection: { attributes: undefined },
162+
selection: { attributes: { id: 'cropper-selection-69' } },
154163
selections: { attributes: undefined },
155164
}"
156165
/>
166+
167+
<div class="w-80 h-40 overflow-hidden">
168+
<component
169+
v-if="cropper?.cropperMounted"
170+
:is="h('cropper-viewer', { selection: '#cropper-selection-69' })"
171+
/>
172+
</div>
157173
</div>
158174
</div>
159175

0 commit comments

Comments
 (0)