Skip to content

Commit 2c4f9b6

Browse files
committed
[feature] add controls for header position on scroll
1 parent c08934b commit 2c4f9b6

File tree

5 files changed

+47
-2
lines changed

5 files changed

+47
-2
lines changed

‎src/css/header.css‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.header{
2-
position: relative;
32
display: flex;
43
flex-direction: row;
54
z-index:var(--z-index-header);
@@ -22,11 +21,16 @@
2221
justify-content: flex-end;
2322
}
2423

25-
.is-link-show .header{
24+
.is-link-show.is-header-position-sticky .header{
2625
position: sticky;
2726
left:0;
2827
}
2928

29+
.is-link-show.is-header-position-inline .header{
30+
position: relative;
31+
left:0;
32+
}
33+
3034
.is-layout-order-headerlink.is-link-show .header{
3135
top:0;
3236
}

‎src/index.html‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,25 @@ <h1 class="menu-item-header-text">Border</h1>
728728
</div>
729729
</div>
730730
</div>
731+
<divclass="menu-item">
732+
<divclass="menu-item-header">
733+
<h1class="menu-item-header-text">Position when scrolling</h1>
734+
</div>
735+
<divclass="menu-item-form">
736+
<divclass="form-indent">
737+
<divclass="input-wrap">
738+
<inputid="control-header-position-sticky" class="control-header-position-sticky" type="radio" name="control-header-position" value="sticky" tabindex="-1">
739+
<labelfor="control-header-position-sticky">Sticky</label>
740+
</div>
741+
<pclass="control-header-position-sticky-helper form-helper small">Header sticks to the page when scrolling up or down.</p>
742+
<divclass="input-wrap">
743+
<inputid="control-header-position-inline" class="control-header-position-inline" type="radio" name="control-header-position" value="inline" tabindex="-1">
744+
<labelfor="control-header-position-inline">Inline</label>
745+
</div>
746+
<pclass="control-header-position-inline-helper form-helper small">Header moves inline with the content when scrolling up or down.</p>
747+
</div>
748+
</div>
749+
</div>
731750
<divclass="menu-item">
732751
<divclass="menu-item-header">
733752
<h1class="menu-item-header-text">Shade</h1>

‎src/js/control.js‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,6 +1747,20 @@ var control = (function(){
17471747
header.render.border();
17481748
render.class();
17491749
}
1750+
},{
1751+
element: helper.e(".control-header-position-sticky"),
1752+
path: "header.position",
1753+
type: "radio",
1754+
func: function(){
1755+
render.class();
1756+
}
1757+
},{
1758+
element: helper.e(".control-header-position-inline"),
1759+
path: "header.position",
1760+
type: "radio",
1761+
func: function(){
1762+
render.class();
1763+
}
17501764
},{
17511765
element: helper.e(".control-link-area-width"),
17521766
path: "link.area.width",
@@ -2649,6 +2663,11 @@ var control = (function(){
26492663
helper.addClass(html,"is-header-border-bottom");
26502664
};
26512665
};
2666+
var_position=function(){
2667+
helper.removeClass(html,"is-header-position-sticky");
2668+
helper.removeClass(html,"is-header-position-inline");
2669+
helper.addClass(html,"is-header-position-"+state.get().header.position);
2670+
};
26522671
_area();
26532672
_item();
26542673
_clock();
@@ -2658,6 +2677,7 @@ var control = (function(){
26582677
_shade();
26592678
_border();
26602679
_greeting();
2680+
_position();
26612681
_transitional();
26622682
};
26632683
var_group=function(){

‎src/js/state.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ var state = (function(){
130130
type: "timeanddate",
131131
size: 1
132132
},
133+
position: "sticky",
133134
radius: false
134135
},
135136
link: {

‎src/js/update.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ var update = (function(){
624624
name: "Group 1",
625625
items: data.bookmarks
626626
}];
627+
data.state.header.position="sticky";
627628
data.state.group={
628629
area: {
629630
alignment: "left"

0 commit comments

Comments
(0)