Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Polymer gestures library safe for Closure property renaming (take 2). #5314

Merged
merged 4 commits into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions externs/polymer-internal-shared-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,51 @@ function AsyncInterface(){}
AsyncInterface.prototype.run;
/** @type {function(number): void} */
AsyncInterface.prototype.cancel;

/** @record */
let GestureInfo = function(){};
/** @type {string|undefined} */
GestureInfo.prototype.state;
/** @type {boolean|undefined} */
GestureInfo.prototype.started;
/** @type {!Array<?>|undefined} */
GestureInfo.prototype.moves;
/** @type {number|undefined} */
GestureInfo.prototype.x;
/** @type {number|undefined} */
GestureInfo.prototype.y;
/** @type {boolean|undefined} */
GestureInfo.prototype.prevent;
/** @type {function(?): void|undefined} */
GestureInfo.prototype.addMove;
/** @type {null|undefined} */
GestureInfo.prototype.movefn;
/** @type {null|undefined} */
GestureInfo.prototype.upFn;

/** @record */
let GestureRecognizer = function(){};
/** @type {string} */
GestureRecognizer.prototype.name;
/** @type {!Array<string>} */
GestureRecognizer.prototype.deps;
/** @type {function(): void} */
GestureRecognizer.prototype.reset;
/** @type {function(MouseEvent): void | undefined} */
GestureRecognizer.prototype.mousedown;
/** @type {(function(MouseEvent): void | undefined)} */
GestureRecognizer.prototype.mousemove;
/** @type {(function(MouseEvent): void | undefined)} */
GestureRecognizer.prototype.mouseup;
/** @type {(function(TouchEvent): void | undefined)} */
GestureRecognizer.prototype.touchstart;
/** @type {(function(TouchEvent): void | undefined)} */
GestureRecognizer.prototype.touchmove;
/** @type {(function(TouchEvent): void | undefined)} */
GestureRecognizer.prototype.touchend;
/** @type {(function(MouseEvent): void | undefined)} */
GestureRecognizer.prototype.click;
/** @type {!GestureInfo} */
GestureRecognizer.prototype.info;
/** @type {!Array<string>} */
GestureRecognizer.prototype.emits;
47 changes: 3 additions & 44 deletions lib/utils/gestures.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,50 +92,6 @@ function PASSIVE_TOUCH(eventName) {
// Check for touch-only devices
let IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);

/** @record */
const GestureInfo = function(){}; // eslint-disable-line no-unused-vars
/** @type {string|undefined} */
GestureInfo.prototype.state;
/** @type {boolean|undefined} */
GestureInfo.prototype.started;
/** @type {!Array<?>|undefined} */
GestureInfo.prototype.moves;
/** @type {number|undefined} */
GestureInfo.prototype.x;
/** @type {number|undefined} */
GestureInfo.prototype.y;
/** @type {boolean|undefined} */
GestureInfo.prototype.prevent;
/** @type {function(?): void|undefined} */
GestureInfo.prototype.addMove;
/** @type {null|undefined} */
GestureInfo.prototype.movefn;
/** @type {null|undefined} */
GestureInfo.prototype.upFn;

/** @record */
const GestureRecognizer = function(){}; // eslint-disable-line no-unused-vars
/** @type {function(): void} */
GestureRecognizer.prototype.reset;
/** @type {function(MouseEvent): void | undefined} */
GestureRecognizer.prototype.mousedown;
/** @type {(function(MouseEvent): void | undefined)} */
GestureRecognizer.prototype.mousemove;
/** @type {(function(MouseEvent): void | undefined)} */
GestureRecognizer.prototype.mouseup;
/** @type {(function(TouchEvent): void | undefined)} */
GestureRecognizer.prototype.touchstart;
/** @type {(function(TouchEvent): void | undefined)} */
GestureRecognizer.prototype.touchmove;
/** @type {(function(TouchEvent): void | undefined)} */
GestureRecognizer.prototype.touchend;
/** @type {(function(MouseEvent): void | undefined)} */
GestureRecognizer.prototype.click;
/** @type {!GestureInfo} */
GestureRecognizer.prototype.info;
/** @type {!Array<string>} */
GestureRecognizer.prototype.emits;

// keep track of any labels hit by the mouseCanceller
/** @type {!Array<!HTMLLabelElement>} */
const clickedLabels = [];
Expand Down Expand Up @@ -378,7 +334,10 @@ function untrackDocument(stateObj) {
// Use passive event listeners, if supported, to not affect scrolling performance
document.addEventListener('touchend', ignoreMouse, SUPPORTS_PASSIVE ? {passive: true} : false);

/** @type {!Object<string, !GestureRecognizer>} */
export const gestures = {};

/** @type {!Array<!GestureRecognizer>} */
export const recognizers = [];

/**
Expand Down