mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 14:01:20 +08:00
chore(build): rename ionic directory to src and update all references in the build process.
This commit is contained in:
54
src/util/click-block.ts
Normal file
54
src/util/click-block.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import {nativeTimeout} from './dom';
|
||||
|
||||
|
||||
const CSS_CLICK_BLOCK = 'click-block-active';
|
||||
const DEFAULT_EXPIRE = 330;
|
||||
let cbEle, fallbackTimerId;
|
||||
let isShowing = false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export class ClickBlock {
|
||||
private _enabled: boolean = false;
|
||||
|
||||
enable() {
|
||||
cbEle = document.createElement('click-block');
|
||||
document.body.appendChild(cbEle);
|
||||
cbEle.addEventListener('touchmove', function(ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
});
|
||||
this._enabled = true;
|
||||
}
|
||||
|
||||
show(shouldShow, expire) {
|
||||
if (this._enabled) {
|
||||
if (shouldShow) {
|
||||
show(expire);
|
||||
|
||||
} else {
|
||||
hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function show(expire) {
|
||||
clearTimeout(fallbackTimerId);
|
||||
fallbackTimerId = nativeTimeout(hide, expire || DEFAULT_EXPIRE);
|
||||
|
||||
if (!isShowing) {
|
||||
cbEle.classList.add(CSS_CLICK_BLOCK);
|
||||
isShowing = true;
|
||||
}
|
||||
}
|
||||
|
||||
function hide() {
|
||||
clearTimeout(fallbackTimerId);
|
||||
if (isShowing) {
|
||||
cbEle.classList.remove(CSS_CLICK_BLOCK);
|
||||
isShowing = false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user