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

Commit5192c70

Browse files
committed
feat: use origin scroll on mobile
1 parent74c86ab commit5192c70

File tree

6 files changed

+24
-2
lines changed

6 files changed

+24
-2
lines changed

‎falco.config.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ if (NODE_ENV === 'docs') {
99
module.exports={
1010
registry:'https://registry.npm.taobao.org',
1111
mode:NODE_ENV ?'production' :'development',
12+
esModules:false,
1213
output,
1314
}

‎index.sample.html‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,5 @@
9999
</div>
100100
</div>
101101
<divid="loader"><div></div></div>
102-
<scriptnomodulesrc="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.2.5/polyfill.min.js"></script>
103102
</body>
104103
</html>

‎src/helper/mobile.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exportdefault()=>!!('ontouchstart'inwindow)

‎src/index.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Obeserver from './observer'
88
import{switchToHome,switchToPost}from'./switch'
99
importsleepfrom'./switch/sleep'
1010
importScrollerfrom'./scroller'
11+
importisMobilefrom'./helper/mobile'
1112

1213
consttopBar=document.querySelector('#bar')
1314
constmirror={
@@ -88,9 +89,12 @@ mirror.getPosts = async function getPosts(type, { cursor, e }) {
8889

8990
mirror.getPost=asyncfunctiongetPost(number){
9091
document.title='loading'
91-
topBar.style.width=0
9292
scroller.stop(0)
9393

94+
if(!isMobile()){
95+
topBar.style.width=0
96+
}
97+
9498
letpost=this.issue[number]
9599

96100
if(post){
@@ -166,6 +170,10 @@ router.init = (route) => {
166170
$('.home').addClass('page-current')
167171
scroller.start(document.querySelector('.home'))
168172
}
173+
174+
if(isMobile()){
175+
$('.page').addClass('scroll')
176+
}
169177
}
170178

171179
observer.watch({

‎src/scroller/index.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
importVirtualScrollfrom'virtual-scroll'// eslint-disable-line import/no-unresolved
22
importraffrom'raf'// eslint-disable-line import/no-unresolved
3+
importisMobilefrom'../helper/mobile'
34

45
raf.polyfill()
56

@@ -13,6 +14,10 @@ export default class extends VirtualScroll {
1314
}
1415

1516
start(ele){
17+
if(isMobile()){
18+
return
19+
}
20+
1621
[this.child]=ele.children
1722
this.el=ele
1823
this.on((e)=>{
@@ -29,6 +34,10 @@ export default class extends VirtualScroll {
2934
}
3035

3136
stop(y){
37+
if(isMobile()){
38+
return
39+
}
40+
3241
this.lastScrollY=this.scrollY
3342
this.el=window
3443
this.off()

‎src/style/transition.less‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
height:100%;
99
overflow:hidden;
1010
}
11+
.page.scroll {
12+
overflow-y:scroll;
13+
-webkit-overflow-scrolling:touch;
14+
}
1115

1216
.page-current {
1317
z-index:1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp