11import { h , Component } from 'preact' ;
22import angleToPoint from '../helpers/angle-to-point' ;
33import ProgressLine from './progress-line' ;
4+ import Pattern from './pattern' ;
45import Ruler from './ruler' ;
56import Point from './point' ;
67import mod from '../helpers/resize-mod' ;
@@ -19,58 +20,13 @@ class Curve extends Component {
1920 segments = this . _renderSegments ( state ) ,
2021 progressLines = this . _renderProgressLines ( state ) ;
2122
23+ const curveHeight = this . _getCurveHeight ( state ) ;
2224 return < div className = { CLASSES [ 'curve' ] } >
2325 < div id = "js-background"
24- className = { CLASSES [ 'curve__background' ] }
25- style = { styles . background } >
26- < svg preserveAspectRatio = "none" height = { `${ styles . height } px` } viewBox = { `0 0 ${ 350 + Math . random ( ) * 0.0001 } ${ styles . height } ` } >
27- < pattern id = "rect-paper" x = "0" y = { `${ - styles . svgTop } ` } height = "350" width = "350" patternUnits = "userSpaceOnUse" >
28- < g id = "Group" transform = "translate(-1.000000, 0.000000)" stroke = "#FFFFFF" stroke-width = "1" fill = "none" >
29- < path vector-effect = "non-scaling-stroke" d = "M333.497821,350.501088 L333.497821,0.501088302" opacity = "0.25" > </ path >
30- < path vector-effect = "non-scaling-stroke" d = "M315.997821,350.501088 L315.997821,0.501088302" opacity = "0.25" > </ path >
31- < path vector-effect = "non-scaling-stroke" d = "M298.497821,350.501088 L298.497821,0.501088302" opacity = "0.25" > </ path >
32- < path vector-effect = "non-scaling-stroke" d = "M280.997821,350.501088 L280.997821,0.501088302" opacity = "0.25" > </ path >
33- < path vector-effect = "non-scaling-stroke" d = "M245.997821,350.501088 L245.997821,0.501088302" opacity = "0.25" > </ path >
34- < path vector-effect = "non-scaling-stroke" d = "M228.497821,350.501088 L228.497821,0.501088302" opacity = "0.25" > </ path >
35- < path vector-effect = "non-scaling-stroke" d = "M210.997821,350.501088 L210.997821,0.501088302" opacity = "0.25" > </ path >
36- < path vector-effect = "non-scaling-stroke" d = "M193.497821,350.501088 L193.497821,0.501088302" opacity = "0.25" > </ path >
37- < path vector-effect = "non-scaling-stroke" d = "M159.372821,350.501088 L159.372821,0.501088302" opacity = "0.25" > </ path >
38- < path vector-effect = "non-scaling-stroke" d = "M141.872821,350.501088 L141.872821,0.501088302" opacity = "0.25" > </ path >
39- < path vector-effect = "non-scaling-stroke" d = "M124.372821,350.501088 L124.372821,0.501088302" opacity = "0.25" > </ path >
40- < path vector-effect = "non-scaling-stroke" d = "M106.872821,350.501088 L106.872821,0.501088302" opacity = "0.25" > </ path >
41- < path vector-effect = "non-scaling-stroke" d = "M71.8728207,350.501088 L71.8728207,0.501088302" opacity = "0.25" > </ path >
42- < path vector-effect = "non-scaling-stroke" d = "M54.3728207,350.501088 L54.3728207,0.501088302" opacity = "0.25" > </ path >
43- < path vector-effect = "non-scaling-stroke" d = "M36.8728207,350.501088 L36.8728207,0.501088302" opacity = "0.25" > </ path >
44- < path vector-effect = "non-scaling-stroke" d = "M19.3728207,350.501088 L19.3728207,0.501088302" opacity = "0.25" > </ path >
45- < path vector-effect = "non-scaling-stroke" d = "M351.001088,19.0021793 L1.0010883,19.0021793" opacity = "0.25" > </ path >
46- < path vector-effect = "non-scaling-stroke" d = "M351.001088,36.5021793 L1.0010883,36.5021793" opacity = "0.25" > </ path >
47- < path vector-effect = "non-scaling-stroke" d = "M351.001088,54.0021793 L1.0010883,54.0021793" opacity = "0.25" > </ path >
48- < path vector-effect = "non-scaling-stroke" d = "M351.001088,71.5021793 L1.0010883,71.5021793" opacity = "0.25" > </ path >
49- < path vector-effect = "non-scaling-stroke" d = "M351.001088,106.502179 L1.0010883,106.502179" opacity = "0.25" > </ path >
50- < path vector-effect = "non-scaling-stroke" d = "M351.001088,124.002179 L1.0010883,124.002179" opacity = "0.25" > </ path >
51- < path vector-effect = "non-scaling-stroke" d = "M351.001088,141.502179 L1.0010883,141.502179" opacity = "0.25" > </ path >
52- < path vector-effect = "non-scaling-stroke" d = "M351.001088,159.002179 L1.0010883,159.002179" opacity = "0.25" > </ path >
53- < path vector-effect = "non-scaling-stroke" d = "M351.001088,193.127179 L1.0010883,193.127179" opacity = "0.25" > </ path >
54- < path vector-effect = "non-scaling-stroke" d = "M351.001088,210.627179 L1.0010883,210.627179" opacity = "0.25" > </ path >
55- < path vector-effect = "non-scaling-stroke" d = "M351.001088,228.127179 L1.0010883,228.127179" opacity = "0.25" > </ path >
56- < path vector-effect = "non-scaling-stroke" d = "M351.001088,245.627179 L1.0010883,245.627179" opacity = "0.25" > </ path >
57- < path vector-effect = "non-scaling-stroke" d = "M351.001088,280.627179 L1.0010883,280.627179" opacity = "0.25" > </ path >
58- < path vector-effect = "non-scaling-stroke" d = "M351.001088,298.127179 L1.0010883,298.127179" opacity = "0.25" > </ path >
59- < path vector-effect = "non-scaling-stroke" d = "M351.001088,315.627179 L1.0010883,315.627179" opacity = "0.25" > </ path >
60- < path vector-effect = "non-scaling-stroke" d = "M351.001088,333.127179 L1.0010883,333.127179" opacity = "0.25" > </ path >
61- < path vector-effect = "non-scaling-stroke" d = "M88.0641352,1 L88.0641352,351" id = "path8215" opacity = "0.5" > </ path >
62- < path vector-effect = "non-scaling-stroke" d = "M175.12827,1 L175.12827,351" id = "path8215" opacity = "0.5" > </ path >
63- < path vector-effect = "non-scaling-stroke" d = "M262.192406,1 L262.192406,351" id = "path8215" opacity = "0.5" > </ path >
64- < path vector-effect = "non-scaling-stroke" d = "M350.563591,88.0646793 L0.563591022,88.0646793" id = "path8215" opacity = "0.5" > </ path >
65- < path vector-effect = "non-scaling-stroke" d = "M350.563591,175.564679 L0.563591022,175.564679" id = "path8215" opacity = "0.5" > </ path >
66- < path vector-effect = "non-scaling-stroke" d = "M350.563591,263.064679 L0.563591022,263.064679" id = "path8215" opacity = "0.5" > </ path >
67- < rect id = "rect10078" opacity = "0.75" x = "0.872817955" y = "1" width = "350" height = "350" > </ rect >
68- </ g >
69- </ pattern >
70-
71- < rect width = "350" height = { styles . height } fill = "url(#rect-paper)" />
72- </ svg >
73-
26+ className = { CLASSES [ 'curve__background' ] } >
27+
28+ < Pattern styles = { styles } />
29+
7430 </ div >
7531
7632 { progressLines }
@@ -84,7 +40,7 @@ class Curve extends Component {
8440 { points }
8541
8642 < svg height = { C . CURVE_SIZE }
87- viewBox = " 0 0 100 100"
43+ viewBox = { ` 0 0 100 ${ curveHeight } ` }
8844 preserveAspectRatio = "none"
8945 id = "js-svg"
9046 class = { CLASSES [ 'curve__svg' ] } >
@@ -104,26 +60,36 @@ class Curve extends Component {
10460 </ div > ;
10561 }
10662
63+ _getCurveHeight ( state ) {
64+ const { resize} = state ;
65+ if ( ! state . controls . isMinimize ) { return 100 ; }
66+
67+ return C . CURVE_SIZE * 8 ;
68+ }
69+
10770 _getStyle ( state ) {
10871 const { resize} = state ;
10972 let { temp_top, temp_bottom, temp_right, panTempY} = resize ;
11073 let height = C . CURVE_SIZE - ( temp_top + resize . top )
11174 + ( temp_bottom + resize . bottom ) ;
11275
11376 panTempY += resize . panY ;
114-
11577 temp_top += resize . top - panTempY ;
11678 temp_right += resize . right ;
11779
80+ const yShift = ( state . controls . isMinimize )
81+ ? - ( temp_top / C . CURVE_SIZE ) * ( 20 / ( height / C . CURVE_SIZE ) )
82+ : - temp_top ;
83+
11884 const scaleX = ( C . CURVE_SIZE + Math . max ( temp_right , 0 ) ) / C . CURVE_SIZE ;
11985 const scale = `width: ${ C . CURVE_SIZE * scaleX } px` ,
12086 bgTransform = `${ scale } ;` ,
121- background = `background-position: 0 ${ - temp_top - 1 } px; ${ bgTransform } ` ,
122- transform = `transform: translate(0px, ${ - temp_top } px)` ;
87+ // background = `background-position: 0 ${-temp_top - 1}px; ${bgTransform}`,
88+ transform = `transform: translate(0px, ${ yShift } px)` ;
12389
12490 return {
12591 transform : `${ mojs . h . prefix . css } ${ transform } ; ${ transform } ;` ,
126- background,
92+ // background,
12793 height,
12894 svgTop : temp_top
12995 } ;
0 commit comments