Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit71e3162

Browse files
committed
Improve sidebar responsiveness and resizability
1 parent55754b6 commit71e3162

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

‎python_docs_theme/layout.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ <h3>{{ _('Navigation') }}</h3>
7878
<scripttype="text/javascript"src="{{ pathto('_static/menu.js', 1) }}"></script>
7979
<scripttype="text/javascript"src="{{ pathto('_static/search-focus.js', 1) }}"></script>
8080
<scripttype="text/javascript"src="{{ pathto('_static/themetoggle.js', 1) }}"></script>
81+
<scripttype="text/javascript"src="{{ pathto('_static/sidebar-resizer.js', 1) }}"></script>
8182
{%- endif -%}
8283
{%- endif -%}
8384
{{ super() }}

‎python_docs_theme/static/pydoctheme.css‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ div.sphinxsidebar {
149149
border-radius:5px;
150150
line-height:130%;
151151
font-size: smaller;
152+
width:300px;
153+
resize: horizontal;
154+
overflow: auto;
152155
}
153156

154157
div.sphinxsidebarh3,
@@ -157,7 +160,7 @@ div.sphinxsidebar h4 {
157160
}
158161

159162
div.sphinxsidebarwrapper {
160-
width:217px;
163+
width:100%;
161164
box-sizing: border-box;
162165
height:100%;
163166
overflow-x: hidden;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
document.addEventListener('DOMContentLoaded',function(){
2+
constsidebar=document.querySelector('.sphinxsidebar');
3+
constresizer=document.createElement('div');
4+
resizer.className='sidebar-resizer';
5+
sidebar.appendChild(resizer);
6+
7+
resizer.addEventListener('mousedown',function(e){
8+
document.addEventListener('mousemove',resizeSidebar);
9+
document.addEventListener('mouseup',stopResize);
10+
});
11+
12+
functionresizeSidebar(e){
13+
constnewWidth=e.clientX-sidebar.getBoundingClientRect().left;
14+
if(newWidth>150&&newWidth<window.innerWidth-100){
15+
sidebar.style.width=newWidth+'px';
16+
}
17+
}
18+
19+
functionstopResize(){
20+
document.removeEventListener('mousemove',resizeSidebar);
21+
document.removeEventListener('mouseup',stopResize);
22+
}
23+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp