guides icon indicating copy to clipboard operation
guides copied to clipboard

Please need to know how to add initial guides as default value

Open musta-sd opened this issue 2 years ago • 16 comments

Environments

  • Framework name:
  • Framework version:
  • Component name:
  • Component version:
  • Testable Address(optional):

Description

I need to save the guides then with one click use them

musta-sd avatar Dec 08 '22 12:12 musta-sd

@musta-sd use defaultGuides prop.

daybrush avatar Dec 08 '22 12:12 daybrush

Can you please show me how to use it

musta-sd avatar Dec 09 '22 10:12 musta-sd

@musta-sd

Based on react, it is as follows.

defaultGuides={useMemo(() => [0, 100, 200], [])}

When the defaultGuides change, the guides are updated.

daybrush avatar Dec 09 '22 10:12 daybrush

What about vue ?

musta-sd avatar Dec 09 '22 10:12 musta-sd

@musta-sd

Is it Vue3? Is it Vue2?

<template>
<Guides :defaultGuides="guides" />
</template>
<script>
setup() {
const guides = [0, 100, 200];

return {
   guides,
};
}

// or
data() {
   return { guides: [0, 100, 200] };
}
</script>

daybrush avatar Dec 09 '22 10:12 daybrush

Vue3 With composition API , I used this example and it is showing me an error Uncaught TypeError: guides.map is not a function at __proto.renderGuides

musta-sd avatar Dec 09 '22 10:12 musta-sd

@musta-sd

Can you show the code you used Guides on?

daybrush avatar Dec 09 '22 10:12 daybrush

musta-sd avatar Dec 09 '22 10:12 musta-sd

@musta-sd

guides1 and guides2 are used in ref.

ref="guides1", ref="guides2"

Try below code:

:defaultGuides="defaultGuides1"
:defaultGuides="defaultGuides2"
const defaultGuides1 = ref([0, 100, 200]);
const defaultGuides2 = ref([0, 100, 200]);

daybrush avatar Dec 09 '22 10:12 daybrush

It is working Thank you so much. last question: I need to customize the lines color based on picker , i tried with css but it is not working

musta-sd avatar Dec 09 '22 10:12 musta-sd

@musta-sd

https://daybrush.com/guides/release/latest/doc/Guides.html#.GuideOptions

daybrush avatar Dec 09 '22 10:12 daybrush

@musta-sd What you're looking for is like lineColor. lineColor="#f55"

daybrush avatar Dec 09 '22 10:12 daybrush

lineColor is for the ruler not the lines , i am using this for ruler

musta-sd avatar Dec 09 '22 11:12 musta-sd

        v-if="mediaStore.isReviewImageLineGuiding"
        ref="guides2"
        type="vertical"
        displayDragPos="true"
        :defaultGuides="defaultGuides1"
        backgroundColor="#ca3639"
        lineColor="#ffffff"
        v-bind:rulerStyle="{
          top: '30px',
          height: 'calc(100% - 30px)',
          width: '30px',
        }"
        v-on:changeGuides="onChange"
        v-on:clickRuler="clickRuler"

musta-sd avatar Dec 09 '22 11:12 musta-sd

@musta-sd

Are you talking about the color of the guidelines?

https://codesandbox.io/s/intelligent-heisenberg-9xn421?file=/src/App.vue

I updated the new version (0.3.4) of vue3-guides. Try updating the version and adding the following properties:

:guideStyle="{ backgroundColor: '#333' }"

daybrush avatar Dec 09 '22 11:12 daybrush

Thank you brother

musta-sd avatar Dec 09 '22 11:12 musta-sd