Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
feat(ink): add directive for applying ink to arbitrary elements
Browse files Browse the repository at this point in the history
 - not very sophisticated right now, just applies ink when clicked and emits "inked" event when the ink animation is done.
  • Loading branch information
justindujardin committed Jan 31, 2016
1 parent 9b5e355 commit 89819d5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ng2-material/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export * from './components/divider/divider';
import {MdIcon} from './components/icon/icon';
export * from './components/icon/icon';

import {MdInk} from './components/ink/ink';
export * from './components/ink/ink';

import {
MdPatternValidator, MdMaxLengthValidator,
MdMinValueValidator, MdMaxValueValidator,
Expand Down Expand Up @@ -63,9 +66,11 @@ import {MdToolbar} from './components/toolbar/toolbar';
export * from './components/toolbar/toolbar';

import {MdTabs, MdTab} from './components/tabs/tabs';
import {Media} from "./core/util/media";
export * from './components/tabs/tabs';

import {Media} from "./core/util/media";
export * from './core/util/media';

export * from './core/util/animate';

/**
Expand All @@ -77,6 +82,7 @@ export const MATERIAL_DIRECTIVES: Type[] = CONST_EXPR([
MdContent,
MdDivider,
MdIcon,
MdInk,
MdInput, MdInputContainer,
MdPatternValidator, MdMaxLengthValidator,
MdMinValueValidator, MdMaxValueValidator,
Expand Down
24 changes: 24 additions & 0 deletions ng2-material/components/ink/ink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {ElementRef, Directive, Output, EventEmitter} from "angular2/core";
import {Ink} from "../../core/util/ink";

@Directive({
selector: '[md-ink]',
host: {
'(mousedown)': 'onMousedown($event)'
},
})
export class MdInk {

@Output() inked:EventEmitter<MdInk> = new EventEmitter<MdInk>();

constructor(private _element: ElementRef) {
}

onMousedown(event) {
if (this._element && Ink.canApply(this._element.nativeElement)) {
Ink.rippleEvent(this._element.nativeElement, event).then(() => {
this.inked.emit(this);
});
}
}
}

0 comments on commit 89819d5

Please sign in to comment.