@@ -42,7 +42,10 @@ function editLabel() {
4242
4343 byId ( "labelSizeShow" ) . on ( "click" , showSizeSection ) ;
4444 byId ( "labelSizeHide" ) . on ( "click" , hideSizeSection ) ;
45+ byId ( "labelOffsetShow" ) . on ( "click" , showOffsetSection ) ;
46+ byId ( "labelOffsetHide" ) . on ( "click" , hideOffsetSection ) ;
4547 byId ( "labelStartOffset" ) . on ( "input" , changeStartOffset ) ;
48+ byId ( "labelStartOffsetValue" ) . on ( "input" , changeStartOffsetFromValue ) ;
4649 byId ( "labelRelativeSize" ) . on ( "input" , changeRelativeSize ) ;
4750
4851 byId ( "labelLetterSpacingShow" ) . on ( "click" , showLetterSpacingSection ) ;
@@ -83,7 +86,9 @@ function editLabel() {
8386
8487 function updateValues ( textPath ) {
8588 byId ( "labelText" ) . value = [ ...textPath . querySelectorAll ( "tspan" ) ] . map ( tspan => tspan . textContent ) . join ( "|" ) ;
86- byId ( "labelStartOffset" ) . value = parseFloat ( textPath . getAttribute ( "startOffset" ) ) ;
89+ const startOffset = parseFloat ( textPath . getAttribute ( "startOffset" ) ) ;
90+ byId ( "labelStartOffset" ) . value = startOffset ;
91+ byId ( "labelStartOffsetValue" ) . value = startOffset ;
8792 byId ( "labelRelativeSize" ) . value = parseFloat ( textPath . getAttribute ( "font-size" ) ) ;
8893 let letterSpacingSize = textPath . getAttribute ( "letter-spacing" ) ? textPath . getAttribute ( "letter-spacing" ) : 0 ;
8994 byId ( "labelLetterSpacingSize" ) . value = parseFloat ( letterSpacingSize ) ;
@@ -346,6 +351,16 @@ function editLabel() {
346351 byId ( "labelSizeSection" ) . style . display = "none" ;
347352 }
348353
354+ function showOffsetSection ( ) {
355+ document . querySelectorAll ( "#labelEditor > button" ) . forEach ( el => ( el . style . display = "none" ) ) ;
356+ byId ( "labelOffsetSection" ) . style . display = "inline-block" ;
357+ }
358+
359+ function hideOffsetSection ( ) {
360+ document . querySelectorAll ( "#labelEditor > button" ) . forEach ( el => ( el . style . display = "inline-block" ) ) ;
361+ byId ( "labelOffsetSection" ) . style . display = "none" ;
362+ }
363+
349364 function showLetterSpacingSection ( ) {
350365 document . querySelectorAll ( "#labelEditor > button" ) . forEach ( el => ( el . style . display = "none" ) ) ;
351366 byId ( "labelLetterSpacingSection" ) . style . display = "inline-block" ;
@@ -357,8 +372,18 @@ function editLabel() {
357372 }
358373
359374 function changeStartOffset ( ) {
360- elSelected . select ( "textPath" ) . attr ( "startOffset" , this . value + "%" ) ;
361- tip ( "Label offset: " + this . value + "%" ) ;
375+ const value = this . value ;
376+ byId ( "labelStartOffsetValue" ) . value = value ;
377+ elSelected . select ( "textPath" ) . attr ( "startOffset" , value + "%" ) ;
378+ tip ( "Label offset: " + value + "%" ) ;
379+ }
380+
381+ function changeStartOffsetFromValue ( ) {
382+ const value = Math . min ( 80 , Math . max ( 20 , this . value ) ) ;
383+ byId ( "labelStartOffset" ) . value = value ;
384+ this . value = value ;
385+ elSelected . select ( "textPath" ) . attr ( "startOffset" , value + "%" ) ;
386+ tip ( "Label offset: " + value + "%" ) ;
362387 }
363388
364389 function changeRelativeSize ( ) {
0 commit comments