99 <div class =" color" :style =" boxColorStyles" ></div >
1010 </div >
1111 </div >
12- <transition :name =" transition" >
13- <color-picker
14- class =" picker-popup"
15- :color =" this.color"
16- :position =" processedPosition"
17- :disable-alpha =" processedDisableAlpha"
18- :boxRect =" boxRect"
19- :disable-text-inputs =" disableTextInputs"
20- v-show =" active"
21- :style =" { visibility: hidePicker ? 'hidden' : '' }"
22- @ready =" hidePicker = false"
23- @updateColor =" emitUpdate"
24- @hueInputStart =" $emit('hueInputStart', $event)"
25- @hueInputEnd =" $emit('hueInputEnd', $event)"
26- @hueInput =" $emit('hueInput', $event)"
27- @alphaInputStart =" $emit('alphaInputStart', $event)"
28- @alphaInputEnd =" $emit('alphaInputEnd', $event)"
29- @alphaInput =" $emit('alphaInput', $event)"
30- @saturationInputStart =" $emit('saturationInputStart', $event)"
31- @saturationInputEnd =" $emit('saturationInputEnd', $event)"
32- @saturationInput =" $emit('saturationInput', $event)"
33- @change =" $emit('change', $event)"
34- ref =" picker" />
35- </transition >
12+
13+ <Teleport :to =" parent" v-if =" parent" >
14+ <transition :name =" transition" >
15+ <color-picker
16+ class =" picker-popup user"
17+ :color =" this.color"
18+ :position =" processedPosition"
19+ :disable-alpha =" processedDisableAlpha"
20+ :boxRect =" boxRect"
21+ :disable-text-inputs =" disableTextInputs"
22+ v-show =" active"
23+ :style =" { visibility: hidePicker ? 'hidden' : '' }"
24+ @ready =" hidePicker = false"
25+ @updateColor =" emitUpdate"
26+ @hueInputStart =" $emit('hueInputStart', $event)"
27+ @hueInputEnd =" $emit('hueInputEnd', $event)"
28+ @hueInput =" $emit('hueInput', $event)"
29+ @alphaInputStart =" $emit('alphaInputStart', $event)"
30+ @alphaInputEnd =" $emit('alphaInputEnd', $event)"
31+ @alphaInput =" $emit('alphaInput', $event)"
32+ @saturationInputStart =" $emit('saturationInputStart', $event)"
33+ @saturationInputEnd =" $emit('saturationInputEnd', $event)"
34+ @saturationInput =" $emit('saturationInput', $event)"
35+ @change =" $emit('change', $event)"
36+ ref =" picker" />
37+ </transition >
38+ </Teleport >
3639 </div >
3740</template >
3841
7780 default: false
7881 },
7982 format: String ,
83+ appendTo: [String , HTMLElement ]
8084 },
8185 emits: [
8286 ' mounted' ,
8387 ' beforeUnmount' ,
8488 ' update:modelValue' ,
8589 ' pickStart' ,
8690 ' pickEnd' ,
87- ' hueInputStart' ,
88- ' hueInputEnd' ,
89- ' hueInput' ,
90- ' alphaInputStart' ,
91- ' alphaInputEnd' ,
92- ' alphaInput' ,
93- ' saturationInputStart' ,
94- ' saturationInputEnd' ,
95- ' saturationInput' ,
96- ' change'
91+ ' hueInputStart' ,
92+ ' hueInputEnd' ,
93+ ' hueInput' ,
94+ ' alphaInputStart' ,
95+ ' alphaInputEnd' ,
96+ ' alphaInput' ,
97+ ' saturationInputStart' ,
98+ ' saturationInputEnd' ,
99+ ' saturationInput' ,
100+ ' change'
97101 ],
98102 components: { ColorPicker },
99103 provide: { tinycolor },
103107 active: false ,
104108 ready: false ,
105109 hidePicker: false ,
110+ parent: null ,
106111 boxRect: {},
107112 innerBoxRect: {},
108113 textInputsFormat: ' rgb' ,
250255 }
251256 this .$emit (' update:modelValue' , this .output );
252257 },
258+ getParent () {
259+ let parent;
260+ if (this .appendTo ) {
261+ if (typeof this .appendTo === ' string' ) {
262+ parent = document .querySelector (this .appendTo )
263+ } else {
264+ parent = this .appendTo
265+ }
266+ }
267+
268+
269+ this .parent = parent || this .$refs .root
270+ console .log (this .parent );
271+ },
253272 getBoxRect () {
254- this .boxRect = this .$refs . root .getBoundingClientRect ();
273+ this .boxRect = this .parent .getBoundingClientRect ();
255274 }
256275 },
257276 created () {
261280 };
262281 },
263282 mounted () {
283+ this .getParent ();
264284 this .$emit (' mounted' );
265285 },
266286 beforeUnmount () {
345365 cursor : not-allowed ;
346366 }
347367 }
368+ }
369+ .picker-popup {
370+ position : absolute ;
371+ z-index : 9999 ;
372+ width : auto ;
373+ min-width : 280px ;
374+ background-color : #fbfbfb ;
375+ box-shadow : 0px 5px 10px rgba (15 ,15 ,15 ,.4 );
376+ margin : 10px ;
377+ user-select : none ;
378+ color : #0f0f0f ;
379+ }
348380
349- .picker-popup {
350- position : absolute ;
351- z-index : 9999 ;
352- width : auto ;
353- min-width : 280px ;
354- background-color : #fbfbfb ;
355- box-shadow : 0px 5px 10px rgba (15 ,15 ,15 ,.4 );
356- margin : 10px ;
357- user-select : none ;
358- color : #0f0f0f ;
359- }
360-
361- .picker-popup-enter-from ,
362- .picker-popup-leave-to {
363- transform : translateY (-10px );
364- opacity : 0 ;
365- }
366- .picker-popup-enter-active ,
367- .picker-popup-leave-active {
368- transition : transform .3s , opacity .3s ;
369- }
381+ .picker-popup-enter-from ,
382+ .picker-popup-leave-to {
383+ transform : translateY (-10px );
384+ opacity : 0 ;
385+ }
386+ .picker-popup-enter-active ,
387+ .picker-popup-leave-active {
388+ transition : transform .3s , opacity .3s ;
370389 }
371390 </style >
0 commit comments