Skip to content

Commit

Permalink
WIP: event -> evt
Browse files Browse the repository at this point in the history
  • Loading branch information
acdvorak committed Feb 9, 2019
1 parent 73aef50 commit b9e2f69
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/mdc-dialog/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface MDCDialogAdapter {

isContentScrollable(): boolean;
areButtonsStacked(): boolean;
getActionFromEvent(event: Event): string | null;
getActionFromEvent(evt: Event): string | null;

trapFocus(): void;
releaseFocus(): void;
Expand Down
6 changes: 3 additions & 3 deletions packages/mdc-dialog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ class MDCDialog extends MDCComponent<MDCDialogFoundation> {
areButtonsStacked: () => util.areTopsMisaligned(this.buttons_),
clickDefaultButton: () => this.defaultButton_ && this.defaultButton_.click(),
eventTargetMatches: (target, selector) => target ? matches(target as Element, selector) : false,
getActionFromEvent: (event: Event) => {
if (!event.target) {
getActionFromEvent: (evt: Event) => {
if (!evt.target) {
return '';
}
const element = closest(event.target as Element, `[${strings.ACTION_ATTRIBUTE}]`);
const element = closest(evt.target as Element, `[${strings.ACTION_ATTRIBUTE}]`);
return element && element.getAttribute(strings.ACTION_ATTRIBUTE);
},
hasClass: (className) => this.root_.classList.contains(className),
Expand Down
18 changes: 7 additions & 11 deletions packages/mdc-ripple/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,8 @@ export type VendorMatchesFunctionName = 'webkitMatchesSelector' | 'msMatchesSele
export type MatchesFunctionName = VendorMatchesFunctionName | 'matches';

export function getMatchesProperty(htmlElementPrototype: {}): MatchesFunctionName {
/**
* Order is important because we return the first existing method we find.
* Do not change the order of the items in the below array.
*/

// Order is important because we return the first existing method we find.
// Do not change the order of the items in the below array.
const matchesMethods: MatchesFunctionName[] = ['matches', 'webkitMatchesSelector', 'msMatchesSelector'];
let method: MatchesFunctionName = 'matches';
for (const matchesMethod of matchesMethods) {
Expand All @@ -128,9 +125,8 @@ export function getMatchesProperty(htmlElementPrototype: {}): MatchesFunctionNam
return method;
}

export function getNormalizedEventCoords(
ev: Event | undefined, pageOffset: Point, clientRect: ClientRect): Point {
if (!ev) {
export function getNormalizedEventCoords(evt: Event | undefined, pageOffset: Point, clientRect: ClientRect): Point {
if (!evt) {
return {x: 0, y: 0};
}
const {x, y} = pageOffset;
Expand All @@ -140,12 +136,12 @@ export function getNormalizedEventCoords(
let normalizedX;
let normalizedY;
// Determine touch point relative to the ripple container.
if (ev.type === 'touchstart') {
const touchEvent = ev as TouchEvent;
if (evt.type === 'touchstart') {
const touchEvent = evt as TouchEvent;
normalizedX = touchEvent.changedTouches[0].pageX - documentX;
normalizedY = touchEvent.changedTouches[0].pageY - documentY;
} else {
const mouseEvent = ev as MouseEvent;
const mouseEvent = evt as MouseEvent;
normalizedX = mouseEvent.pageX - documentX;
normalizedY = mouseEvent.pageY - documentY;
}
Expand Down

0 comments on commit b9e2f69

Please sign in to comment.