forked from newthuhole/hole_thu_frontend
fix ios pressure helper and android click handler
This commit is contained in:
23
src/App.js
23
src/App.js
@@ -9,29 +9,6 @@ import {load_config,bgimg_style} from './Config';
|
|||||||
import ImasuguApp from './imasugu/src/App';
|
import ImasuguApp from './imasugu/src/App';
|
||||||
|
|
||||||
function DeprecatedAlert(props) {
|
function DeprecatedAlert(props) {
|
||||||
if(['pkuhelper.pku.edu.cn','127.0.0.1','localhost'].indexOf(document.domain)===-1)
|
|
||||||
return (
|
|
||||||
<div className="flow-item-row">
|
|
||||||
<div className="box box-tip aux-margin">
|
|
||||||
<p><b>树洞又㕛叒换域名了!</b></p>
|
|
||||||
<br />
|
|
||||||
<p>记住树洞网页版新网址</p>
|
|
||||||
<p><a href="http://pkuhelper.pku.edu.cn/hole">pkuhelper.pku.edu.cn/hole</a></p>
|
|
||||||
<br />
|
|
||||||
<p><small>当前域名我也不清楚什么时候停止维护。</small></p>
|
|
||||||
<p><small>另外我们终于支持了 HTTPS 和 HTTP/2。</small></p>
|
|
||||||
<br />
|
|
||||||
<TokenCtx.Consumer>{(token)=>(
|
|
||||||
!!token.value && <div>
|
|
||||||
<p>*Tips: </p>
|
|
||||||
<p>点击右上角的 <span className="icon icon-about" /> ,复制 User Token,在新网址的登录页面输入,就不用重发验证码了。</p>
|
|
||||||
<br />
|
|
||||||
</div>
|
|
||||||
)}</TokenCtx.Consumer>
|
|
||||||
<p>@xmcp from PKUHelper Team</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ export class ClickHandler extends PureComponent {
|
|||||||
this.on_end_bound=this.on_end.bind(this);
|
this.on_end_bound=this.on_end.bind(this);
|
||||||
|
|
||||||
this.MOVE_THRESHOLD=3;
|
this.MOVE_THRESHOLD=3;
|
||||||
|
this.last_fire=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
on_begin(e) {
|
on_begin(e) {
|
||||||
@@ -178,12 +179,18 @@ export class ClickHandler extends PureComponent {
|
|||||||
on_end(event) {
|
on_end(event) {
|
||||||
//console.log('end');
|
//console.log('end');
|
||||||
if(!this.state.moved)
|
if(!this.state.moved)
|
||||||
this.props.callback(event);
|
this.do_callback(event);
|
||||||
this.setState({
|
this.setState({
|
||||||
moved: true,
|
moved: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_callback(event) {
|
||||||
|
if(this.last_fire+100>+new Date()) return;
|
||||||
|
this.last_fire=+new Date();
|
||||||
|
this.props.callback(event);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div onTouchStart={this.on_begin_bound} onMouseDown={this.on_begin_bound}
|
<div onTouchStart={this.on_begin_bound} onMouseDown={this.on_begin_bound}
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pressure-no-select * {
|
||||||
|
user-select: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
.pressure-box-fired {
|
.pressure-box-fired {
|
||||||
border-color: orangered;
|
border-color: orangered;
|
||||||
pointer-events: initial !important;
|
pointer-events: initial !important;
|
||||||
|
|||||||
@@ -41,8 +41,10 @@ export class PressureHelper extends Component {
|
|||||||
Pressure.set(document.body, {
|
Pressure.set(document.body, {
|
||||||
change: (force)=>{
|
change: (force)=>{
|
||||||
if(!this.state.fired) {
|
if(!this.state.fired) {
|
||||||
if(force>=.999)
|
if(force>=.999) {
|
||||||
|
document.body.classList.add('pressure-no-select');
|
||||||
this.do_fire();
|
this.do_fire();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
this.setState({
|
this.setState({
|
||||||
level: force,
|
level: force,
|
||||||
@@ -54,16 +56,13 @@ export class PressureHelper extends Component {
|
|||||||
level: 0,
|
level: 0,
|
||||||
fired: false,
|
fired: false,
|
||||||
});
|
});
|
||||||
|
document.body.classList.remove('pressure-no-select');
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
polyfill: false,
|
polyfill: false,
|
||||||
only: 'touch',
|
only: 'touch',
|
||||||
preventSelect: false,
|
preventSelect: false,
|
||||||
});
|
});
|
||||||
document.body.addEventListener('selectstart',(event)=>{
|
|
||||||
if(this.state.level>THRESHOLD)
|
|
||||||
event.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('keydown',(e)=>{
|
document.addEventListener('keydown',(e)=>{
|
||||||
if(!e.repeat && e.key==='Escape') {
|
if(!e.repeat && e.key==='Escape') {
|
||||||
|
|||||||
Reference in New Issue
Block a user