File tree Expand file tree Collapse file tree
advanced/case-studies/scroll-to-input
ui/ui-elements/forms/text-field Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <style
2+ id =" form-group"
3+ flex =" 1"
4+ marginLeft =" 24"
5+ marginRight =" 24"
6+ marginTop =" 24"
7+ />
8+ <style
9+ id="input"
10+ borderBottomColor="#E1E1E1"
11+ borderBottomWidth="1"
12+ borderColor="#4E4D4D "
13+ flex="1"
14+ fontSize="16"
15+ fontWeight="normal"
16+ paddingBottom="8"
17+ paddingTop="8"
18+ >
19+ <modifier focused="true">
20+ <style borderBottomColor="#4778FF " />
21+ </modifier>
22+ </style >
23+ <style id="input-error " borderBottomColor="#FF4847" color="#FF4847" >
24+ <modifier focused="true">
25+ <style borderBottomColor="#FF4847" />
26+ </modifier>
27+ </style >
28+ <style
29+ id="label"
30+ borderColor="#4E4D4D "
31+ fontSize="16"
32+ fontWeight="bold"
33+ lineHeight="24"
34+ marginBottom="8"
35+ />
36+ <style
37+ id="help"
38+ borderColor="#FF4847"
39+ fontSize="16"
40+ fontWeight="normal"
41+ lineHeight="24"
42+ marginTop="16"
43+ />
44+ <style id="help-error " color="#FF4847" />
45+ <style
46+ id="submit"
47+ color="#4778FF "
48+ fontSize="16"
49+ fontWeight="bold"
50+ lineHeight="24"
51+ marginLeft="24"
52+ marginTop="16"
53+ />
54+ <style id="spacer" height="200" />
Original file line number Diff line number Diff line change 1+ ---
2+ permalink: "/advanced/case-studies/scroll-to-input/index.xml"
3+ tags: "Advanced/Case Studies"
4+ hv_title: "Scroll to Input Offset"
5+ hv_button_behavior: "back"
6+ ---
7+ {% extends ' templates/base.xml.njk' %}
8+ {% from ' macros/description/index.xml.njk' import description %}
9+
10+ {% block styles %}
11+ {% include ' ./_styles.xml.njk' %}
12+ {% endblock %}
13+
14+ {% block container %}
15+ <form id =" myScrollForm" scroll =" true" scroll-to-input-offset =" 450" >
16+ {{ description (' Scroll to input offset is a property that can be used to scroll to an input field when it is focused.' ) }}
17+ <view style =" spacer " />
18+ <view style =" spacer " />
19+ <view style =" form-group " >
20+ <text style =" label " >Label line</text >
21+ <text-field
22+ name =" data"
23+ placeholder =" Placeholder"
24+ placeholderTextColor =" #8D9494"
25+ style =" input "
26+ />
27+ </view >
28+ <text
29+ action =" replace"
30+ href =" /hyperview/public/advanced/case-studies/scroll-to-input/submit.xml"
31+ show-during-load =" mySpinner"
32+ style =" submit "
33+ target =" myScrollForm"
34+ >
35+ Submit
36+ </text >
37+ <view style =" spacer " />
38+ <view style =" spacer " />
39+ <view style =" spacer " />
40+ <view style =" spacer " />
41+ {{ description (' Bottom of the form' ) }}
42+ </form >
43+ <spinner id =" mySpinner" hide =" true" />
44+ {% endblock %}
Original file line number Diff line number Diff line change 1+ <form
2+ id =" myScrollForm"
3+ scroll =" true"
4+ xmlns =" https://hyperview.org/hyperview"
5+ scroll-to-input-offset =" 512"
6+ >
7+ <view style =" form-group" >
8+ <text style =" label" >Label line</text >
9+ <text-field
10+ name =" data"
11+ placeholder =" Placeholder"
12+ placeholderTextColor =" #8D9494"
13+ style =" input"
14+ value =" "
15+ />
16+ </view >
17+ <text style =" submit" >Saved!</text >
18+ </form >
Original file line number Diff line number Diff line change @@ -23,6 +23,6 @@ hv_button_behavior: "back"
2323{% endblock %}
2424
2525{% block content %}
26- {{ about ('Text field are used in forms to collect textual data ') }}
26+ {{ about ('Text fields are used in forms to collect textual data ') }}
2727 {% include './_form .xml .njk ' %}
2828{% endblock %}
Original file line number Diff line number Diff line change @@ -111,9 +111,9 @@ An attribute indicating the direction in which the view will scroll.
111111
112112#### ` scroll-to-input-offset `
113113
114- | Type | Required |
115- | ------ | ----------------------- |
116- | number | No (defauls to ** 120** ) |
114+ | Type | Required |
115+ | ------ | ------------------------ |
116+ | number | No (defaults to ** 120** ) |
117117
118118An attribute defining an additional scroll offset to be applied to the view, when a ` <text-field> ` is focused. Only valid in combination with attribute ` scroll ` set to ` "true" ` .
119119
Original file line number Diff line number Diff line change 456456 <xs : attribute name =" safe-area" type =" xs:boolean" />
457457 <xs : attribute name =" value" type =" xs:string" />
458458 <xs : attribute name =" sticky" type =" xs:boolean" />
459+ <xs : attribute name =" scroll-to-input-offset" type =" xs:nonNegativeInteger" />
459460 <xs : attributeGroup ref =" hv:behaviorAttributes" />
460461 <xs : attributeGroup ref =" hv:scrollAttributes" />
461462 </xs : attributeGroup >
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ export default class HvView extends PureComponent<HvComponentProps> {
137137 const offsetStr = this . attributes [ ATTRIBUTES . SCROLL_TO_INPUT_OFFSET ] ;
138138 if ( offsetStr ) {
139139 const offset = parseInt ( offsetStr , 10 ) ;
140- return Number . isNaN ( offset ) ? 0 : defaultOffset ;
140+ return Number . isNaN ( offset ) ? defaultOffset : offset ;
141141 }
142142 return defaultOffset ;
143143 } ;
You can’t perform that action at this time.
0 commit comments