fix(clickblock): clickblock applies longer

references #9531
This commit is contained in:
Manu Mtz.-Almeida
2016-12-07 16:49:13 +01:00
committed by Adam Bradley
parent e84f2e2fbb
commit e0d876e9f0
6 changed files with 41 additions and 38 deletions

View File

@@ -19,6 +19,7 @@ import { MenuController } from '../menu/menu-controller';
*/
@Injectable()
export class App {
private _disTime: number = 0;
private _scrollTime: number = 0;
private _title: string = '';
@@ -122,9 +123,9 @@ export class App {
this._disTime = (isEnabled ? 0 : Date.now() + duration);
if (this._clickBlock) {
if (isEnabled || duration <= 32) {
if (isEnabled) {
// disable the click block if it's enabled, or the duration is tiny
this._clickBlock.activate(false, 0);
this._clickBlock.activate(false, CLICK_BLOCK_BUFFER_IN_MILLIS);
} else {
// show the click block for duration + some number

View File

@@ -354,7 +354,7 @@ describe('App', () => {
});
describe('setEnabled', () => {
it('should disable click block when app is enabled', () => {
it('should disable click block when app is enabled', (done) => {
// arrange
let mockClickBlock: any = {
activate: () => {}
@@ -368,25 +368,14 @@ describe('App', () => {
app.setEnabled(true);
// assert
expect(mockClickBlock.activate).toHaveBeenCalledWith(false, 0);
});
expect(mockClickBlock.activate).not.toHaveBeenCalled();
it('should disable click block when app is disabled but duration of less than 32 passed', () => {
// arrange
let mockClickBlock: any = {
activate: () => {}
};
setTimeout(() => {
expect(mockClickBlock.activate).toHaveBeenCalledWith(false, 0);
done();
}, 120);
}, 1000);
spyOn(mockClickBlock, 'activate');
app._clickBlock = mockClickBlock;
// act
app.setEnabled(false, 20);
// assert
expect(mockClickBlock.activate).toHaveBeenCalledWith(false, 0);
});
it('should enable click block when false is passed with duration', () => {
// arrange

View File

@@ -508,6 +508,7 @@ export class Menu {
private _after(isOpen: boolean) {
assert(this._isAnimating, '_before() should be called while animating');
this._app.setEnabled(false, 100);
// keep opening/closing the menu disabled for a touch more yet
// only add listeners/css if it's enabled and isOpen
// and only remove listeners/css if it's not open