mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
chore(noImplicitAny): add noImplicitAny to tsconfig
This commit is contained in:
@ -40,32 +40,32 @@ export class App {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
viewDidLoad: EventEmitter<any> = new EventEmitter();
|
viewDidLoad: EventEmitter<ViewController> = new EventEmitter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
viewWillEnter: EventEmitter<any> = new EventEmitter();
|
viewWillEnter: EventEmitter<ViewController> = new EventEmitter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
viewDidEnter: EventEmitter<any> = new EventEmitter();
|
viewDidEnter: EventEmitter<ViewController> = new EventEmitter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
viewWillLeave: EventEmitter<any> = new EventEmitter();
|
viewWillLeave: EventEmitter<ViewController> = new EventEmitter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
viewDidLeave: EventEmitter<any> = new EventEmitter();
|
viewDidLeave: EventEmitter<ViewController> = new EventEmitter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
viewWillUnload: EventEmitter<any> = new EventEmitter();
|
viewWillUnload: EventEmitter<ViewController> = new EventEmitter();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _config: Config,
|
private _config: Config,
|
||||||
|
@ -259,6 +259,6 @@ function mockButton(config?: Config, ionButton?: string) {
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasClass(button, className) {
|
function hasClass(button: any, className: string) {
|
||||||
return button._elementRef.nativeElement.classList.contains(className);
|
return button._elementRef.nativeElement.classList.contains(className);
|
||||||
}
|
}
|
||||||
|
@ -814,7 +814,7 @@ export class DateTime extends Ion implements AfterContentInit, ControlValueAcces
|
|||||||
// then check to see if they're in the config
|
// then check to see if they're in the config
|
||||||
// if neither were provided then it will use default English names
|
// if neither were provided then it will use default English names
|
||||||
['monthNames', 'monthShortNames', 'dayNames', 'dayShortNames'].forEach(type => {
|
['monthNames', 'monthShortNames', 'dayNames', 'dayShortNames'].forEach(type => {
|
||||||
this._locale[type] = convertToArrayOfStrings(isPresent(this[type]) ? this[type] : this._config.get(type), type);
|
(<any>this)._locale[type] = convertToArrayOfStrings(isPresent((<any>this)[type]) ? (<any>this)[type] : this._config.get(type), type);
|
||||||
});
|
});
|
||||||
|
|
||||||
// update how the datetime value is displayed as formatted text
|
// update how the datetime value is displayed as formatted text
|
||||||
|
@ -161,29 +161,30 @@ export class Icon extends Ion {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
update() {
|
update() {
|
||||||
let name;
|
let iconName: string;
|
||||||
|
|
||||||
if (this._ios && this._iconMode === 'ios') {
|
if (this._ios && this._iconMode === 'ios') {
|
||||||
name = this._ios;
|
iconName = this._ios;
|
||||||
} else if (this._md && this._iconMode === 'md') {
|
} else if (this._md && this._iconMode === 'md') {
|
||||||
name = this._md;
|
iconName = this._md;
|
||||||
} else {
|
} else {
|
||||||
name = this._name;
|
iconName = this._name;
|
||||||
}
|
}
|
||||||
let hidden = this._hidden = (name === null);
|
let hidden = this._hidden = (iconName === null);
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let iconMode = name.split('-', 2)[0];
|
let iconMode = iconName.split('-', 2)[0];
|
||||||
if (
|
if (
|
||||||
iconMode === 'ios' &&
|
iconMode === 'ios' &&
|
||||||
!this._isActive &&
|
!this._isActive &&
|
||||||
name.indexOf('logo-') < 0 &&
|
iconName.indexOf('logo-') < 0 &&
|
||||||
name.indexOf('-outline') < 0) {
|
iconName.indexOf('-outline') < 0) {
|
||||||
name += '-outline';
|
iconName += '-outline';
|
||||||
}
|
}
|
||||||
|
|
||||||
let css = 'ion-' + name;
|
let css = 'ion-' + iconName;
|
||||||
if (this._css === css) {
|
if (this._css === css) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -193,7 +194,7 @@ export class Icon extends Ion {
|
|||||||
this._css = css;
|
this._css = css;
|
||||||
this.setElementClass(css, true);
|
this.setElementClass(css, true);
|
||||||
|
|
||||||
let label = name
|
let label = iconName
|
||||||
.replace('ios-', '')
|
.replace('ios-', '')
|
||||||
.replace('md-', '')
|
.replace('md-', '')
|
||||||
.replace('-', ' ');
|
.replace('-', ' ');
|
||||||
|
@ -48,7 +48,7 @@ describe('Img', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let contentElementRef;
|
let contentElementRef: any;
|
||||||
let img: Img;
|
let img: Img;
|
||||||
let elementRef: ElementRef;
|
let elementRef: ElementRef;
|
||||||
let renderer: Renderer;
|
let renderer: Renderer;
|
||||||
|
@ -95,8 +95,8 @@ describe('Infinite Scroll', () => {
|
|||||||
let config = mockConfig();
|
let config = mockConfig();
|
||||||
let inf: InfiniteScroll;
|
let inf: InfiniteScroll;
|
||||||
let content: Content;
|
let content: Content;
|
||||||
let contentElementRef;
|
let contentElementRef: any;
|
||||||
let infiniteElementRef;
|
let infiniteElementRef: any;
|
||||||
let ev: ScrollEvent = (<any>{});
|
let ev: ScrollEvent = (<any>{});
|
||||||
let dom: DomController;
|
let dom: DomController;
|
||||||
|
|
||||||
@ -112,15 +112,15 @@ describe('Infinite Scroll', () => {
|
|||||||
inf = new InfiniteScroll(content, mockZone(), infiniteElementRef, dom);
|
inf = new InfiniteScroll(content, mockZone(), infiniteElementRef, dom);
|
||||||
});
|
});
|
||||||
|
|
||||||
function setInfiniteScrollTop(scrollTop) {
|
function setInfiniteScrollTop(scrollTop: any) {
|
||||||
infiniteElementRef.nativeElement.scrollTop = scrollTop;
|
infiniteElementRef.nativeElement.scrollTop = scrollTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setInfiniteScrollHeight(scrollHeight) {
|
function setInfiniteScrollHeight(scrollHeight: any) {
|
||||||
infiniteElementRef.nativeElement.scrollHeight = scrollHeight;
|
infiniteElementRef.nativeElement.scrollHeight = scrollHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mockGetContentDimensions(scrollHeight, scrollTop, contentHeight) {
|
function mockGetContentDimensions(scrollHeight: any, scrollTop: any, contentHeight: any): any {
|
||||||
return {
|
return {
|
||||||
scrollHeight: scrollHeight,
|
scrollHeight: scrollHeight,
|
||||||
scrollTop: scrollTop,
|
scrollTop: scrollTop,
|
||||||
|
@ -39,7 +39,7 @@ export class OverlayPortal extends NavControllerBase {
|
|||||||
|
|
||||||
// on every page change make sure the portal has
|
// on every page change make sure the portal has
|
||||||
// dismissed any views that should be auto dismissed on page change
|
// dismissed any views that should be auto dismissed on page change
|
||||||
app.viewDidLeave.subscribe((ev) => {
|
app.viewDidLeave.subscribe((ev: any) => {
|
||||||
!ev.isOverlay && this.dismissPageChangeViews();
|
!ev.isOverlay && this.dismissPageChangeViews();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,18 @@ export class PickerColumnCmp {
|
|||||||
// ensure we've got a good round number :)
|
// ensure we've got a good round number :)
|
||||||
y = Math.round(y);
|
y = Math.round(y);
|
||||||
|
|
||||||
let i, button, opt, optOffset, visible, translateX, translateY, translateZ, rotateX, transform, selected;
|
let i: number;
|
||||||
|
let button: any;
|
||||||
|
let opt: any;
|
||||||
|
let optOffset: number;
|
||||||
|
let visible: boolean;
|
||||||
|
let translateX: number;
|
||||||
|
let translateY: number;
|
||||||
|
let translateZ: number;
|
||||||
|
let rotateX: number;
|
||||||
|
let transform: string;
|
||||||
|
let selected: boolean;
|
||||||
|
|
||||||
const parent = this.colEle.nativeElement;
|
const parent = this.colEle.nativeElement;
|
||||||
const children = parent.children;
|
const children = parent.children;
|
||||||
const length = children.length;
|
const length = children.length;
|
||||||
|
@ -225,7 +225,7 @@ describe('Refresher', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let contentElementRef;
|
let contentElementRef: any;
|
||||||
let refresher: Refresher;
|
let refresher: Refresher;
|
||||||
let content: Content;
|
let content: Content;
|
||||||
let dom: any;
|
let dom: any;
|
||||||
@ -251,7 +251,7 @@ describe('Refresher', () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function setContentScrollTop(scrollTop) {
|
function setContentScrollTop(scrollTop: any) {
|
||||||
content.getContentDimensions = function() {
|
content.getContentDimensions = function() {
|
||||||
return {
|
return {
|
||||||
scrollTop: scrollTop,
|
scrollTop: scrollTop,
|
||||||
|
@ -499,13 +499,13 @@ export class Slides extends Ion {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
loopedSlides = null;
|
loopedSlides: number = null;
|
||||||
|
|
||||||
// Swiping/no swiping
|
// Swiping/no swiping
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
swipeHandler = null;
|
swipeHandler: any = null;
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -53,7 +53,7 @@ export function addRole(ele: HTMLElement, role: string) {
|
|||||||
ele.setAttribute('role', role);
|
ele.setAttribute('role', role);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addLabel(ele: HTMLElement, label) {
|
export function addLabel(ele: HTMLElement, label: string) {
|
||||||
ele.setAttribute('aria-label', label);
|
ele.setAttribute('aria-label', label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import { updatePaginationClasses } from './swiper-pagination';
|
|||||||
Classes
|
Classes
|
||||||
===========================*/
|
===========================*/
|
||||||
export function updateClasses(s: Slides) {
|
export function updateClasses(s: Slides) {
|
||||||
var childElements;
|
var childElements: HTMLElement[];
|
||||||
|
|
||||||
removeClass(s._slides, [CLS.slideActive, CLS.slideNext, CLS.slidePrev, CLS.slideDuplicateActive, CLS.slideDuplicateNext, CLS.slideDuplicatePrev]);
|
removeClass(s._slides, [CLS.slideActive, CLS.slideNext, CLS.slidePrev, CLS.slideDuplicateActive, CLS.slideDuplicateNext, CLS.slideDuplicatePrev]);
|
||||||
for (var i = 0; i < s._slides.length; i++) {
|
for (var i = 0; i < s._slides.length; i++) {
|
||||||
|
@ -220,7 +220,7 @@ function updateClickedSlide(s: Slides, plt: Platform, e: SlideUIEvent) {
|
|||||||
|
|
||||||
if (s.slideToClickedSlide && s.clickedIndex !== undefined && s.clickedIndex !== s._activeIndex) {
|
if (s.slideToClickedSlide && s.clickedIndex !== undefined && s.clickedIndex !== s._activeIndex) {
|
||||||
var slideToIndex = s.clickedIndex;
|
var slideToIndex = s.clickedIndex;
|
||||||
var realIndex;
|
var realIndex: number;
|
||||||
var slidesPerView = s.slidesPerView === 'auto' ? currentSlidesPerView(s) : <number>s.slidesPerView;
|
var slidesPerView = s.slidesPerView === 'auto' ? currentSlidesPerView(s) : <number>s.slidesPerView;
|
||||||
|
|
||||||
if (s.loop) {
|
if (s.loop) {
|
||||||
@ -263,23 +263,27 @@ function updateClickedSlide(s: Slides, plt: Platform, e: SlideUIEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var isTouched,
|
var isTouched: boolean;
|
||||||
isMoved,
|
var isMoved: boolean;
|
||||||
allowTouchCallbacks,
|
var allowTouchCallbacks: boolean;
|
||||||
touchStartTime,
|
var touchStartTime: number;
|
||||||
isScrolling,
|
var isScrolling: boolean;
|
||||||
currentTranslate,
|
var currentTranslate: number;
|
||||||
startTranslate,
|
var startTranslate: any;
|
||||||
allowThresholdMove,
|
var allowThresholdMove: any;
|
||||||
// Last click time
|
|
||||||
lastClickTime = Date.now(), clickTimeout,
|
// Last click time
|
||||||
// Velocities
|
var lastClickTime = Date.now();
|
||||||
velocities = [],
|
var clickTimeout: any;
|
||||||
allowMomentumBounce;
|
|
||||||
|
// Velocities
|
||||||
|
var velocities: any[] = [];
|
||||||
|
var allowMomentumBounce: boolean;
|
||||||
|
|
||||||
|
|
||||||
// Touch handlers
|
// Touch handlers
|
||||||
var isTouchEvent, startMoving;
|
var isTouchEvent: boolean;
|
||||||
|
var startMoving: boolean;
|
||||||
|
|
||||||
function onTouchStart(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
function onTouchStart(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
||||||
console.debug(`ion-slide, onTouchStart: ${ev.type}`);
|
console.debug(`ion-slide, onTouchStart: ${ev.type}`);
|
||||||
@ -408,7 +412,7 @@ function onTouchMove(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
|||||||
s._touches.currentY = ev.type === 'touchmove' ? ev.targetTouches[0].pageY : ev.pageY;
|
s._touches.currentY = ev.type === 'touchmove' ? ev.targetTouches[0].pageY : ev.pageY;
|
||||||
|
|
||||||
if (typeof isScrolling === 'undefined') {
|
if (typeof isScrolling === 'undefined') {
|
||||||
var touchAngle;
|
var touchAngle: number;
|
||||||
if (isHorizontal(s) && s._touches.currentY === s._touches.startY || !isHorizontal(s) && s._touches.currentX === s._touches.startX) {
|
if (isHorizontal(s) && s._touches.currentY === s._touches.startY || !isHorizontal(s) && s._touches.currentX === s._touches.startX) {
|
||||||
isScrolling = false;
|
isScrolling = false;
|
||||||
} else {
|
} else {
|
||||||
@ -516,12 +520,12 @@ function onTouchMove(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
|||||||
// Velocity
|
// Velocity
|
||||||
if (velocities.length === 0) {
|
if (velocities.length === 0) {
|
||||||
velocities.push({
|
velocities.push({
|
||||||
position: s._touches[isHorizontal(s) ? 'startX' : 'startY'],
|
position: (<any>s._touches)[isHorizontal(s) ? 'startX' : 'startY'],
|
||||||
time: touchStartTime
|
time: touchStartTime
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
velocities.push({
|
velocities.push({
|
||||||
position: s._touches[isHorizontal(s) ? 'currentX' : 'currentY'],
|
position: (<any>s._touches)[isHorizontal(s) ? 'currentX' : 'currentY'],
|
||||||
time: (new Date()).getTime()
|
time: (new Date()).getTime()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -592,7 +596,7 @@ function onTouchEnd(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
|||||||
}
|
}
|
||||||
isTouched = isMoved = false;
|
isTouched = isMoved = false;
|
||||||
|
|
||||||
var currentPos;
|
var currentPos: number;
|
||||||
if (s.followFinger) {
|
if (s.followFinger) {
|
||||||
currentPos = s._rtl ? s._translate : -s._translate;
|
currentPos = s._rtl ? s._translate : -s._translate;
|
||||||
} else {
|
} else {
|
||||||
@ -642,7 +646,7 @@ function onTouchEnd(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
|||||||
var newPosition = s._translate + momentumDistance;
|
var newPosition = s._translate + momentumDistance;
|
||||||
if (s._rtl) newPosition = - newPosition;
|
if (s._rtl) newPosition = - newPosition;
|
||||||
var doBounce = false;
|
var doBounce = false;
|
||||||
var afterBouncePosition;
|
var afterBouncePosition: number;
|
||||||
var bounceAmount = Math.abs(s.velocity) * 20 * s.freeModeMomentumBounceRatio;
|
var bounceAmount = Math.abs(s.velocity) * 20 * s.freeModeMomentumBounceRatio;
|
||||||
|
|
||||||
if (newPosition < maxTranslate(s)) {
|
if (newPosition < maxTranslate(s)) {
|
||||||
@ -670,8 +674,8 @@ function onTouchEnd(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (s.freeModeSticky) {
|
} else if (s.freeModeSticky) {
|
||||||
var j = 0,
|
var j = 0;
|
||||||
nextSlide;
|
var nextSlide: number;
|
||||||
for (j = 0; j < s._snapGrid.length; j += 1) {
|
for (j = 0; j < s._snapGrid.length; j += 1) {
|
||||||
if (s._snapGrid[j] > -newPosition) {
|
if (s._snapGrid[j] > -newPosition) {
|
||||||
nextSlide = j;
|
nextSlide = j;
|
||||||
|
@ -4,7 +4,10 @@ import { updateClasses } from './swiper-classes';
|
|||||||
|
|
||||||
export function updateActiveIndex(s: Slides) {
|
export function updateActiveIndex(s: Slides) {
|
||||||
var translate = s._rtl ? s._translate : -s._translate;
|
var translate = s._rtl ? s._translate : -s._translate;
|
||||||
var newActiveIndex, i, snapIndex;
|
var newActiveIndex: number;
|
||||||
|
var i: number;
|
||||||
|
var snapIndex: number;
|
||||||
|
|
||||||
for (i = 0; i < s._slidesGrid.length; i ++) {
|
for (i = 0; i < s._slidesGrid.length; i ++) {
|
||||||
if (typeof s._slidesGrid[i + 1] !== 'undefined') {
|
if (typeof s._slidesGrid[i + 1] !== 'undefined') {
|
||||||
if (translate >= s._slidesGrid[i] && translate < s._slidesGrid[i + 1] - (s._slidesGrid[i + 1] - s._slidesGrid[i]) / 2) {
|
if (translate >= s._slidesGrid[i] && translate < s._slidesGrid[i + 1] - (s._slidesGrid[i + 1] - s._slidesGrid[i]) / 2) {
|
||||||
|
@ -44,7 +44,7 @@ function handleKeyboard(s: Slides, plt: Platform, e: KeyboardEvent) {
|
|||||||
var swiperOffset = offset(s.container, plt);
|
var swiperOffset = offset(s.container, plt);
|
||||||
|
|
||||||
if (s._rtl) {
|
if (s._rtl) {
|
||||||
swiperOffset.left = swiperOffset.left - s.container[0].scrollLeft;
|
swiperOffset.left = swiperOffset.left - s.container.scrollLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
var swiperCoord = [
|
var swiperCoord = [
|
||||||
|
@ -5,8 +5,10 @@ import { eachChild, isHorizontal, transform, transition } from './swiper-utils';
|
|||||||
/*=========================
|
/*=========================
|
||||||
Parallax
|
Parallax
|
||||||
===========================*/
|
===========================*/
|
||||||
function setParallaxTransform(s: Slides, el: HTMLElement, progress) {
|
function setParallaxTransform(s: Slides, el: HTMLElement, progress: number) {
|
||||||
var p, pX, pY;
|
var p: string;
|
||||||
|
var pX: string;
|
||||||
|
var pY: string;
|
||||||
var rtlFactor = s._rtl ? -1 : 1;
|
var rtlFactor = s._rtl ? -1 : 1;
|
||||||
|
|
||||||
p = el.getAttribute('data-swiper-parallax') || '0';
|
p = el.getAttribute('data-swiper-parallax') || '0';
|
||||||
@ -30,13 +32,13 @@ function setParallaxTransform(s: Slides, el: HTMLElement, progress) {
|
|||||||
if ((pX).indexOf('%') >= 0) {
|
if ((pX).indexOf('%') >= 0) {
|
||||||
pX = parseInt(pX, 10) * progress * rtlFactor + '%';
|
pX = parseInt(pX, 10) * progress * rtlFactor + '%';
|
||||||
} else {
|
} else {
|
||||||
pX = pX * progress * rtlFactor + 'px' ;
|
pX = <any>pX * progress * rtlFactor + 'px' ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pY).indexOf('%') >= 0) {
|
if ((pY).indexOf('%') >= 0) {
|
||||||
pY = parseInt(pY, 10) * progress + '%';
|
pY = parseInt(pY, 10) * progress + '%';
|
||||||
} else {
|
} else {
|
||||||
pY = pY * progress + 'px' ;
|
pY = <any>pY * progress + 'px' ;
|
||||||
}
|
}
|
||||||
|
|
||||||
transform(el, 'translate3d(' + pX + ', ' + pY + ',0px)');
|
transform(el, 'translate3d(' + pX + ', ' + pY + ',0px)');
|
||||||
@ -51,7 +53,7 @@ export function parallaxSetTranslate(s: Slides) {
|
|||||||
for (var i = 0; i < s._slides.length; i++) {
|
for (var i = 0; i < s._slides.length; i++) {
|
||||||
var slide = s._slides[i];
|
var slide = s._slides[i];
|
||||||
eachChild(slide, '[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]', (el) => {
|
eachChild(slide, '[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]', (el) => {
|
||||||
var progress = Math.min(Math.max(slide[0].progress, -1), 1);
|
var progress = Math.min(Math.max(slide.progress, -1), 1);
|
||||||
setParallaxTransform(s, slide, progress);
|
setParallaxTransform(s, slide, progress);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ export function setWrapperTranslate(s: Slides, plt: Platform, translate: any, sh
|
|||||||
s._translate = isHorizontal(s) ? x : y;
|
s._translate = isHorizontal(s) ? x : y;
|
||||||
|
|
||||||
// Check if we need to update progress
|
// Check if we need to update progress
|
||||||
var progress;
|
var progress: number;
|
||||||
var translatesDiff = maxTranslate(s) - minTranslate(s);
|
var translatesDiff = maxTranslate(s) - minTranslate(s);
|
||||||
|
|
||||||
if (translatesDiff === 0) {
|
if (translatesDiff === 0) {
|
||||||
@ -56,7 +56,10 @@ export function setWrapperTranslate(s: Slides, plt: Platform, translate: any, sh
|
|||||||
|
|
||||||
export function getTranslate(s: Slides, plt: Platform, el: HTMLElement, axis: string) {
|
export function getTranslate(s: Slides, plt: Platform, el: HTMLElement, axis: string) {
|
||||||
var win: any = plt.win();
|
var win: any = plt.win();
|
||||||
var matrix, curTransform, curStyle, transformMatrix;
|
var matrix: string[];
|
||||||
|
var curTransform: any;
|
||||||
|
var curStyle: CSSStyleDeclaration;
|
||||||
|
var transformMatrix: any;
|
||||||
|
|
||||||
// automatic axis detection
|
// automatic axis detection
|
||||||
if (typeof axis === 'undefined') {
|
if (typeof axis === 'undefined') {
|
||||||
@ -71,7 +74,7 @@ export function getTranslate(s: Slides, plt: Platform, el: HTMLElement, axis: st
|
|||||||
if (win.WebKitCSSMatrix) {
|
if (win.WebKitCSSMatrix) {
|
||||||
curTransform = curStyle.transform || curStyle.webkitTransform;
|
curTransform = curStyle.transform || curStyle.webkitTransform;
|
||||||
if (curTransform.split(',').length > 6) {
|
if (curTransform.split(',').length > 6) {
|
||||||
curTransform = curTransform.split(', ').map(function(a){
|
curTransform = curTransform.split(', ').map(function(a: any){
|
||||||
return a.replace(',', '.');
|
return a.replace(',', '.');
|
||||||
}).join(', ');
|
}).join(', ');
|
||||||
}
|
}
|
||||||
@ -80,14 +83,14 @@ export function getTranslate(s: Slides, plt: Platform, el: HTMLElement, axis: st
|
|||||||
transformMatrix = new win.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
|
transformMatrix = new win.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
|
transformMatrix = (<any>curStyle).MozTransform || (<any>curStyle).OTransform || (<any>curStyle).MsTransform || (<any>curStyle).msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
|
||||||
matrix = transformMatrix.toString().split(',');
|
matrix = transformMatrix.toString().split(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (axis === 'x') {
|
if (axis === 'x') {
|
||||||
if (win.WebKitCSSMatrix) {
|
if (win.WebKitCSSMatrix) {
|
||||||
// Latest Chrome and webkits Fix
|
// Latest Chrome and webkits Fix
|
||||||
curTransform = transformMatrix.m41;
|
curTransform = <any>transformMatrix.m41;
|
||||||
} else if (matrix.length === 16) {
|
} else if (matrix.length === 16) {
|
||||||
// Crazy IE10 Matrix
|
// Crazy IE10 Matrix
|
||||||
curTransform = parseFloat(matrix[12]);
|
curTransform = parseFloat(matrix[12]);
|
||||||
|
@ -2,7 +2,7 @@ import { Slides } from '../slides';
|
|||||||
import { Platform } from '../../../platform/platform';
|
import { Platform } from '../../../platform/platform';
|
||||||
|
|
||||||
|
|
||||||
export function round(a) {
|
export function round(a: any) {
|
||||||
return Math.floor(a);
|
return Math.floor(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ export function queryChildren(parentEle: HTMLElement, query: string): HTMLElemen
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function eachChild(parentEle: HTMLElement, query: string, callback: {(foundEle: HTMLElement)}): void {
|
export function eachChild(parentEle: HTMLElement, query: string, callback: {(foundEle: HTMLElement): void}): void {
|
||||||
if (parentEle) {
|
if (parentEle) {
|
||||||
var nodes = parentEle.querySelectorAll(query);
|
var nodes = parentEle.querySelectorAll(query);
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
|
@ -354,7 +354,24 @@ function toggleZoom(s: Slides, plt: Platform) {
|
|||||||
|
|
||||||
if (!z.gesture.image) return;
|
if (!z.gesture.image) return;
|
||||||
|
|
||||||
var touchX, touchY, offsetX, offsetY, diffX, diffY, translateX, translateY, imageWidth, imageHeight, scaledWidth, scaledHeight, translateMinX, translateMinY, translateMaxX, translateMaxY, slideWidth, slideHeight;
|
var touchX: number;
|
||||||
|
var touchY: number;
|
||||||
|
var offsetX: number;
|
||||||
|
var offsetY: number;
|
||||||
|
var diffX: number;
|
||||||
|
var diffY: number;
|
||||||
|
var translateX: number;
|
||||||
|
var translateY: number;
|
||||||
|
var imageWidth: number;
|
||||||
|
var imageHeight: number;
|
||||||
|
var scaledWidth: number;
|
||||||
|
var scaledHeight: number;
|
||||||
|
var translateMinX: number;
|
||||||
|
var translateMinY: number;
|
||||||
|
var translateMaxX: number;
|
||||||
|
var translateMaxY: number;
|
||||||
|
var slideWidth: number;
|
||||||
|
var slideHeight: number;
|
||||||
|
|
||||||
if (typeof z.image.touchesStart.x === 'undefined' && ev) {
|
if (typeof z.image.touchesStart.x === 'undefined' && ev) {
|
||||||
touchX = ev.type === 'touchend' ? ev.changedTouches[0].pageX : (<any>ev).pageX;
|
touchX = ev.type === 'touchend' ? ev.changedTouches[0].pageX : (<any>ev).pageX;
|
||||||
|
@ -290,9 +290,9 @@ export function pauseAutoplay(s: Slides, plt: Platform, speed?: number) {
|
|||||||
Slider/slides sizes
|
Slider/slides sizes
|
||||||
===========================*/
|
===========================*/
|
||||||
export function updateAutoHeight(s: Slides) {
|
export function updateAutoHeight(s: Slides) {
|
||||||
var activeSlides = [];
|
var activeSlides: SlideElement[] = [];
|
||||||
var newHeight = 0;
|
var newHeight = 0;
|
||||||
var i;
|
var i: number;
|
||||||
|
|
||||||
// Find slides currently in view
|
// Find slides currently in view
|
||||||
if (s.slidesPerView !== 'auto' && s.slidesPerView > 1) {
|
if (s.slidesPerView !== 'auto' && s.slidesPerView > 1) {
|
||||||
@ -378,7 +378,7 @@ export function updateSlidesSize(s: Slides, plt: Platform) {
|
|||||||
inlineStyle(s._slides, { marginRight: '', marginBottom: '' });
|
inlineStyle(s._slides, { marginRight: '', marginBottom: '' });
|
||||||
}
|
}
|
||||||
|
|
||||||
var slidesNumberEvenToRows;
|
var slidesNumberEvenToRows: number;
|
||||||
if (s.slidesPerColumn > 1) {
|
if (s.slidesPerColumn > 1) {
|
||||||
if (Math.floor(s._slides.length / s.slidesPerColumn) === s._slides.length / s.slidesPerColumn) {
|
if (Math.floor(s._slides.length / s.slidesPerColumn) === s._slides.length / s.slidesPerColumn) {
|
||||||
slidesNumberEvenToRows = s._slides.length;
|
slidesNumberEvenToRows = s._slides.length;
|
||||||
@ -401,8 +401,10 @@ export function updateSlidesSize(s: Slides, plt: Platform) {
|
|||||||
var slide = s._slides[i];
|
var slide = s._slides[i];
|
||||||
if (s.slidesPerColumn > 1) {
|
if (s.slidesPerColumn > 1) {
|
||||||
// Set slides order
|
// Set slides order
|
||||||
var newSlideOrderIndex;
|
var newSlideOrderIndex: number;
|
||||||
var column, row;
|
var column: number;
|
||||||
|
var row: number;
|
||||||
|
|
||||||
if (s.slidesPerColumnFill === 'column') {
|
if (s.slidesPerColumnFill === 'column') {
|
||||||
column = Math.floor(i / slidesPerColumn);
|
column = Math.floor(i / slidesPerColumn);
|
||||||
row = i - column * slidesPerColumn;
|
row = i - column * slidesPerColumn;
|
||||||
@ -427,7 +429,7 @@ export function updateSlidesSize(s: Slides, plt: Platform) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var cssVal = (row !== 0 && s.spaceBetween) && (s.spaceBetween + 'px');
|
var cssVal = (row !== 0 && s.spaceBetween) && (s.spaceBetween + 'px');
|
||||||
var cssObj = {};
|
var cssObj: {[key: string]: string} = {};
|
||||||
|
|
||||||
if (isHorizontal(s)) {
|
if (isHorizontal(s)) {
|
||||||
cssObj['marginTop'] = cssVal;
|
cssObj['marginTop'] = cssVal;
|
||||||
@ -436,8 +438,8 @@ export function updateSlidesSize(s: Slides, plt: Platform) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inlineStyle(slide, cssObj);
|
inlineStyle(slide, cssObj);
|
||||||
slide.setAttribute('data-swiper-column', column);
|
slide.setAttribute('data-swiper-column', <any>column);
|
||||||
slide.setAttribute('data-swiper-row', row);
|
slide.setAttribute('data-swiper-row', <any>row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slide.style.display === 'none') {
|
if (slide.style.display === 'none') {
|
||||||
@ -487,7 +489,7 @@ export function updateSlidesSize(s: Slides, plt: Platform) {
|
|||||||
index ++;
|
index ++;
|
||||||
}
|
}
|
||||||
s._virtualSize = Math.max(s._virtualSize, s._renderedSize) + s.slidesOffsetAfter;
|
s._virtualSize = Math.max(s._virtualSize, s._renderedSize) + s.slidesOffsetAfter;
|
||||||
var newSlidesGrid;
|
var newSlidesGrid: any[];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
s._rtl && (s.effect === 'slide' || s.effect === 'coverflow')) {
|
s._rtl && (s.effect === 'slide' || s.effect === 'coverflow')) {
|
||||||
@ -554,10 +556,14 @@ export function updateSlidesSize(s: Slides, plt: Platform) {
|
|||||||
Dynamic Slides Per View
|
Dynamic Slides Per View
|
||||||
===========================*/
|
===========================*/
|
||||||
export function currentSlidesPerView(s: Slides) {
|
export function currentSlidesPerView(s: Slides) {
|
||||||
var spv = 1, i, j;
|
var spv = 1;
|
||||||
|
var i: number;
|
||||||
|
var j: number;
|
||||||
|
|
||||||
if (s.centeredSlides) {
|
if (s.centeredSlides) {
|
||||||
var size = s._slides[s._activeIndex].swiperSlideSize;
|
var size = s._slides[s._activeIndex].swiperSlideSize;
|
||||||
var breakLoop;
|
var breakLoop: boolean;
|
||||||
|
|
||||||
for (i = s._activeIndex + 1; i < s._slides.length; i++) {
|
for (i = s._activeIndex + 1; i < s._slides.length; i++) {
|
||||||
if (s._slides[i] && !breakLoop) {
|
if (s._slides[i] && !breakLoop) {
|
||||||
size += s._slides[i].swiperSlideSize;
|
size += s._slides[i].swiperSlideSize;
|
||||||
@ -565,6 +571,7 @@ export function currentSlidesPerView(s: Slides) {
|
|||||||
if (size > s._renderedSize) breakLoop = true;
|
if (size > s._renderedSize) breakLoop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = s._activeIndex - 1; j >= 0; j--) {
|
for (j = s._activeIndex - 1; j >= 0; j--) {
|
||||||
if (s._slides[j] && !breakLoop) {
|
if (s._slides[j] && !breakLoop) {
|
||||||
size += s._slides[j].swiperSlideSize;
|
size += s._slides[j].swiperSlideSize;
|
||||||
@ -572,6 +579,7 @@ export function currentSlidesPerView(s: Slides) {
|
|||||||
if (size > s._renderedSize) breakLoop = true;
|
if (size > s._renderedSize) breakLoop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (i = s._activeIndex + 1; i < s._slides.length; i++) {
|
for (i = s._activeIndex + 1; i < s._slides.length; i++) {
|
||||||
if (s._slidesGrid[i] - s._slidesGrid[s._activeIndex] < s._renderedSize) {
|
if (s._slidesGrid[i] - s._slidesGrid[s._activeIndex] < s._renderedSize) {
|
||||||
@ -599,7 +607,9 @@ export function update(s: Slides, plt: Platform, updateTranslate?: boolean) {
|
|||||||
resetZoomEvents(s, plt);
|
resetZoomEvents(s, plt);
|
||||||
}
|
}
|
||||||
|
|
||||||
var translated, newTranslate;
|
var translated: boolean;
|
||||||
|
var newTranslate: number;
|
||||||
|
|
||||||
function forceSetTranslate() {
|
function forceSetTranslate() {
|
||||||
newTranslate = Math.min(Math.max(s._translate, maxTranslate(s)), minTranslate(s));
|
newTranslate = Math.min(Math.max(s._translate, maxTranslate(s)), minTranslate(s));
|
||||||
setWrapperTranslate(s, plt, newTranslate);
|
setWrapperTranslate(s, plt, newTranslate);
|
||||||
@ -654,8 +664,8 @@ function createLoop(s: Slides) {
|
|||||||
s.loopedSlides = slides.length;
|
s.loopedSlides = slides.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
var prependSlides = [];
|
var prependSlides: SlideElement[] = [];
|
||||||
var appendSlides = [];
|
var appendSlides: SlideElement[] = [];
|
||||||
|
|
||||||
for (var i = 0; i < slides.length; i++) {
|
for (var i = 0; i < slides.length; i++) {
|
||||||
var slide = slides[i];
|
var slide = slides[i];
|
||||||
@ -686,7 +696,8 @@ function destroyLoop(s: Slides) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function fixLoop(s: Slides, plt: Platform) {
|
export function fixLoop(s: Slides, plt: Platform) {
|
||||||
var newIndex;
|
var newIndex: number;
|
||||||
|
|
||||||
if (s._activeIndex < s.loopedSlides) {
|
if (s._activeIndex < s.loopedSlides) {
|
||||||
// Fix For Negative Oversliding
|
// Fix For Negative Oversliding
|
||||||
newIndex = s._slides.length - s.loopedSlides * 3 + s._activeIndex;
|
newIndex = s._slides.length - s.loopedSlides * 3 + s._activeIndex;
|
||||||
|
@ -26,7 +26,7 @@ var now = Date.now;
|
|||||||
* @param {Object} context
|
* @param {Object} context
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
function setTimeoutContext(fn, timeout, context) {
|
function setTimeoutContext(fn: any, timeout: any, context: any) {
|
||||||
return setTimeout(bindFn(fn, context), timeout);
|
return setTimeout(bindFn(fn, context), timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ function setTimeoutContext(fn, timeout, context) {
|
|||||||
* @param {Object} [context]
|
* @param {Object} [context]
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
function invokeArrayArg(arg, fn, context) {
|
function invokeArrayArg(arg: any, fn: any, context: any) {
|
||||||
if (Array.isArray(arg)) {
|
if (Array.isArray(arg)) {
|
||||||
each(arg, context[fn], context);
|
each(arg, context[fn], context);
|
||||||
return true;
|
return true;
|
||||||
@ -53,8 +53,8 @@ function invokeArrayArg(arg, fn, context) {
|
|||||||
* @param {Function} iterator
|
* @param {Function} iterator
|
||||||
* @param {Object} context
|
* @param {Object} context
|
||||||
*/
|
*/
|
||||||
function each(obj, iterator, context?) {
|
function each(obj: any, iterator: any, context?: any) {
|
||||||
var i;
|
var i: any;
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
return;
|
return;
|
||||||
@ -81,9 +81,9 @@ function each(obj, iterator, context?) {
|
|||||||
* @param {Function} base
|
* @param {Function} base
|
||||||
* @param {Object} [properties]
|
* @param {Object} [properties]
|
||||||
*/
|
*/
|
||||||
function inherit(child, base, properties) {
|
function inherit(child: any, base: any, properties: any) {
|
||||||
var baseP = base.prototype,
|
var baseP = base.prototype,
|
||||||
childP;
|
childP: any;
|
||||||
|
|
||||||
childP = child.prototype = Object.create(baseP);
|
childP = child.prototype = Object.create(baseP);
|
||||||
childP.constructor = child;
|
childP.constructor = child;
|
||||||
@ -100,7 +100,7 @@ function inherit(child, base, properties) {
|
|||||||
* @param {Object} context
|
* @param {Object} context
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
function bindFn(fn, context) {
|
function bindFn(fn: any, context: any) {
|
||||||
return function boundFn() {
|
return function boundFn() {
|
||||||
return fn.apply(context, arguments);
|
return fn.apply(context, arguments);
|
||||||
};
|
};
|
||||||
@ -113,7 +113,7 @@ function bindFn(fn, context) {
|
|||||||
* @param {Array} [args]
|
* @param {Array} [args]
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
function boolOrFn(val, args) {
|
function boolOrFn(val: any, args: any) {
|
||||||
if (typeof val == TYPE_FUNCTION) {
|
if (typeof val == TYPE_FUNCTION) {
|
||||||
return val.apply(args ? args[0] || undefined : undefined, args);
|
return val.apply(args ? args[0] || undefined : undefined, args);
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ function boolOrFn(val, args) {
|
|||||||
* @param {*} val2
|
* @param {*} val2
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function ifUndefined(val1, val2) {
|
function ifUndefined(val1: any, val2: any) {
|
||||||
return (val1 === undefined) ? val2 : val1;
|
return (val1 === undefined) ? val2 : val1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,8 +136,8 @@ function ifUndefined(val1, val2) {
|
|||||||
* @param {String} types
|
* @param {String} types
|
||||||
* @param {Function} handler
|
* @param {Function} handler
|
||||||
*/
|
*/
|
||||||
function addEventListeners(target, types, handler) {
|
function addEventListeners(target: any, types: any, handler: any) {
|
||||||
each(splitStr(types), function(type) {
|
each(splitStr(types), function(type: any) {
|
||||||
target.addEventListener(type, handler, false);
|
target.addEventListener(type, handler, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -148,8 +148,8 @@ function addEventListeners(target, types, handler) {
|
|||||||
* @param {String} types
|
* @param {String} types
|
||||||
* @param {Function} handler
|
* @param {Function} handler
|
||||||
*/
|
*/
|
||||||
function removeEventListeners(target, types, handler) {
|
function removeEventListeners(target: any, types: any, handler: any) {
|
||||||
each(splitStr(types), function(type) {
|
each(splitStr(types), function(type: any) {
|
||||||
target.removeEventListener(type, handler, false);
|
target.removeEventListener(type, handler, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ function removeEventListeners(target, types, handler) {
|
|||||||
* @param {HTMLElement} parent
|
* @param {HTMLElement} parent
|
||||||
* @return {Boolean} found
|
* @return {Boolean} found
|
||||||
*/
|
*/
|
||||||
function hasParent(node, parent) {
|
function hasParent(node: any, parent: any) {
|
||||||
while (node) {
|
while (node) {
|
||||||
if (node == parent) {
|
if (node == parent) {
|
||||||
return true;
|
return true;
|
||||||
@ -177,7 +177,7 @@ function hasParent(node, parent) {
|
|||||||
* @param {String} find
|
* @param {String} find
|
||||||
* @returns {Boolean} found
|
* @returns {Boolean} found
|
||||||
*/
|
*/
|
||||||
function inStr(str, find) {
|
function inStr(str: any, find: any) {
|
||||||
return str.indexOf(find) > -1;
|
return str.indexOf(find) > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ function inStr(str, find) {
|
|||||||
* @param {String} str
|
* @param {String} str
|
||||||
* @returns {Array} words
|
* @returns {Array} words
|
||||||
*/
|
*/
|
||||||
function splitStr(str) {
|
function splitStr(str: any) {
|
||||||
return str.trim().split(/\s+/g);
|
return str.trim().split(/\s+/g);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ function splitStr(str) {
|
|||||||
* @param {String} [findByKey]
|
* @param {String} [findByKey]
|
||||||
* @return {Boolean|Number} false when not found, or the index
|
* @return {Boolean|Number} false when not found, or the index
|
||||||
*/
|
*/
|
||||||
function inArray(src, find, findByKey?) {
|
function inArray(src: any, find: any, findByKey?: any) {
|
||||||
if (src.indexOf && !findByKey) {
|
if (src.indexOf && !findByKey) {
|
||||||
return src.indexOf(find);
|
return src.indexOf(find);
|
||||||
} else {
|
} else {
|
||||||
@ -217,7 +217,7 @@ function inArray(src, find, findByKey?) {
|
|||||||
* @param {Object} obj
|
* @param {Object} obj
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
function toArray(obj) {
|
function toArray(obj: any) {
|
||||||
return Array.prototype.slice.call(obj, 0);
|
return Array.prototype.slice.call(obj, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,9 +228,9 @@ function toArray(obj) {
|
|||||||
* @param {Boolean} [sort=False]
|
* @param {Boolean} [sort=False]
|
||||||
* @returns {Array} [{id:1},{id:2}]
|
* @returns {Array} [{id:1},{id:2}]
|
||||||
*/
|
*/
|
||||||
function uniqueArray(src, key, sort) {
|
function uniqueArray(src: any, key: any, sort: any) {
|
||||||
var results = [];
|
var results: any = [];
|
||||||
var values = [];
|
var values: any = [];
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
while (i < src.length) {
|
while (i < src.length) {
|
||||||
@ -246,7 +246,7 @@ function uniqueArray(src, key, sort) {
|
|||||||
if (!key) {
|
if (!key) {
|
||||||
results = results.sort();
|
results = results.sort();
|
||||||
} else {
|
} else {
|
||||||
results = results.sort(function sortUniqueArray(a, b) {
|
results = results.sort(function sortUniqueArray(a: any, b: any) {
|
||||||
return a[key] > b[key] ? 1 : 0;
|
return a[key] > b[key] ? 1 : 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -261,8 +261,8 @@ function uniqueArray(src, key, sort) {
|
|||||||
* @param {String} property
|
* @param {String} property
|
||||||
* @returns {String|Undefined} prefixed
|
* @returns {String|Undefined} prefixed
|
||||||
*/
|
*/
|
||||||
function prefixed(obj, property) {
|
function prefixed(obj: any, property: any) {
|
||||||
var prefix, prop;
|
var prefix: any, prop: any;
|
||||||
var camelProp = property[0].toUpperCase() + property.slice(1);
|
var camelProp = property[0].toUpperCase() + property.slice(1);
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
@ -292,7 +292,7 @@ function uniqueId() {
|
|||||||
* @param {HTMLElement} element
|
* @param {HTMLElement} element
|
||||||
* @returns {DocumentView|Window}
|
* @returns {DocumentView|Window}
|
||||||
*/
|
*/
|
||||||
function getWindowForElement(element) {
|
function getWindowForElement(element: any) {
|
||||||
var doc = element.ownerDocument || element;
|
var doc = element.ownerDocument || element;
|
||||||
return (doc.defaultView || doc.parentWindow || window);
|
return (doc.defaultView || doc.parentWindow || window);
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ var PROPS_CLIENT_XY = ['clientX', 'clientY'];
|
|||||||
* @returns {Input}
|
* @returns {Input}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Input(manager, callback) {
|
function Input(manager: any, callback: any) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
@ -344,7 +344,7 @@ function Input(manager, callback) {
|
|||||||
|
|
||||||
// smaller wrapper around the handler, for the scope and the enabled state of the manager,
|
// smaller wrapper around the handler, for the scope and the enabled state of the manager,
|
||||||
// so when disabled the input events are completely bypassed.
|
// so when disabled the input events are completely bypassed.
|
||||||
this.domHandler = function(ev) {
|
this.domHandler = function(ev: any) {
|
||||||
if (boolOrFn(manager.options.enable, [manager])) {
|
if (boolOrFn(manager.options.enable, [manager])) {
|
||||||
self.handler(ev);
|
self.handler(ev);
|
||||||
}
|
}
|
||||||
@ -386,8 +386,8 @@ Input.prototype = {
|
|||||||
* @param {Hammer} manager
|
* @param {Hammer} manager
|
||||||
* @returns {Input}
|
* @returns {Input}
|
||||||
*/
|
*/
|
||||||
function createInputInstance(manager) {
|
function createInputInstance(manager: any) {
|
||||||
var Type;
|
var Type: any;
|
||||||
var inputClass = manager.options.inputClass;
|
var inputClass = manager.options.inputClass;
|
||||||
|
|
||||||
if (inputClass) {
|
if (inputClass) {
|
||||||
@ -410,7 +410,7 @@ function createInputInstance(manager) {
|
|||||||
* @param {String} eventType
|
* @param {String} eventType
|
||||||
* @param {Object} input
|
* @param {Object} input
|
||||||
*/
|
*/
|
||||||
function inputHandler(manager, eventType, input) {
|
function inputHandler(manager: any, eventType: any, input: any) {
|
||||||
var pointersLen = input.pointers.length;
|
var pointersLen = input.pointers.length;
|
||||||
var changedPointersLen = input.changedPointers.length;
|
var changedPointersLen = input.changedPointers.length;
|
||||||
var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
|
var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
|
||||||
@ -442,7 +442,7 @@ function inputHandler(manager, eventType, input) {
|
|||||||
* @param {Object} manager
|
* @param {Object} manager
|
||||||
* @param {Object} input
|
* @param {Object} input
|
||||||
*/
|
*/
|
||||||
function computeInputData(manager, input) {
|
function computeInputData(manager: any, input: any) {
|
||||||
var session = manager.session;
|
var session = manager.session;
|
||||||
var pointers = input.pointers;
|
var pointers = input.pointers;
|
||||||
var pointersLength = pointers.length;
|
var pointersLength = pointers.length;
|
||||||
@ -494,7 +494,7 @@ function computeInputData(manager, input) {
|
|||||||
input.target = target;
|
input.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeDeltaXY(session, input) {
|
function computeDeltaXY(session: any, input: any) {
|
||||||
var center = input.center;
|
var center = input.center;
|
||||||
var offset = session.offsetDelta || {};
|
var offset = session.offsetDelta || {};
|
||||||
var prevDelta = session.prevDelta || {};
|
var prevDelta = session.prevDelta || {};
|
||||||
@ -521,10 +521,10 @@ function computeDeltaXY(session, input) {
|
|||||||
* @param {Object} session
|
* @param {Object} session
|
||||||
* @param {Object} input
|
* @param {Object} input
|
||||||
*/
|
*/
|
||||||
function computeIntervalInputData(session, input) {
|
function computeIntervalInputData(session: any, input: any) {
|
||||||
var last = session.lastInterval || input,
|
var last = session.lastInterval || input,
|
||||||
deltaTime = input.timeStamp - last.timeStamp,
|
deltaTime = input.timeStamp - last.timeStamp,
|
||||||
velocity, velocityX, velocityY, direction;
|
velocity: any, velocityX: any, velocityY: any, direction: any;
|
||||||
|
|
||||||
if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
|
if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
|
||||||
var deltaX = input.deltaX - last.deltaX;
|
var deltaX = input.deltaX - last.deltaX;
|
||||||
@ -556,10 +556,10 @@ function computeIntervalInputData(session, input) {
|
|||||||
* @param {Object} input
|
* @param {Object} input
|
||||||
* @returns {Object} clonedInputData
|
* @returns {Object} clonedInputData
|
||||||
*/
|
*/
|
||||||
function simpleCloneInputData(input) {
|
function simpleCloneInputData(input: any) {
|
||||||
// make a simple copy of the pointers because we will get a reference if we don't
|
// make a simple copy of the pointers because we will get a reference if we don't
|
||||||
// we only need clientXY for the calculations
|
// we only need clientXY for the calculations
|
||||||
var pointers = [];
|
var pointers: any = [];
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (i < input.pointers.length) {
|
while (i < input.pointers.length) {
|
||||||
pointers[i] = {
|
pointers[i] = {
|
||||||
@ -583,7 +583,7 @@ function simpleCloneInputData(input) {
|
|||||||
* @param {Array} pointers
|
* @param {Array} pointers
|
||||||
* @return {Object} center contains `x` and `y` properties
|
* @return {Object} center contains `x` and `y` properties
|
||||||
*/
|
*/
|
||||||
function getCenter(pointers) {
|
function getCenter(pointers: any) {
|
||||||
var pointersLength = pointers.length;
|
var pointersLength = pointers.length;
|
||||||
|
|
||||||
// no need to loop when only one touch
|
// no need to loop when only one touch
|
||||||
@ -614,7 +614,7 @@ function getCenter(pointers) {
|
|||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
* @return {Object} velocity `x` and `y`
|
* @return {Object} velocity `x` and `y`
|
||||||
*/
|
*/
|
||||||
function getVelocity(deltaTime, x, y) {
|
function getVelocity(deltaTime: any, x: any, y: any) {
|
||||||
return {
|
return {
|
||||||
x: x / deltaTime || 0,
|
x: x / deltaTime || 0,
|
||||||
y: y / deltaTime || 0
|
y: y / deltaTime || 0
|
||||||
@ -627,7 +627,7 @@ function getVelocity(deltaTime, x, y) {
|
|||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
* @return {Number} direction
|
* @return {Number} direction
|
||||||
*/
|
*/
|
||||||
function getDirection(x, y) {
|
function getDirection(x: any, y: any) {
|
||||||
if (x === y) {
|
if (x === y) {
|
||||||
return DIRECTION_NONE;
|
return DIRECTION_NONE;
|
||||||
}
|
}
|
||||||
@ -645,7 +645,7 @@ function getDirection(x, y) {
|
|||||||
* @param {Array} [props] containing x and y keys
|
* @param {Array} [props] containing x and y keys
|
||||||
* @return {Number} distance
|
* @return {Number} distance
|
||||||
*/
|
*/
|
||||||
function getDistance(p1, p2, props?) {
|
function getDistance(p1: any, p2: any, props?: any) {
|
||||||
if (!props) {
|
if (!props) {
|
||||||
props = PROPS_XY;
|
props = PROPS_XY;
|
||||||
}
|
}
|
||||||
@ -662,7 +662,7 @@ function getDistance(p1, p2, props?) {
|
|||||||
* @param {Array} [props] containing x and y keys
|
* @param {Array} [props] containing x and y keys
|
||||||
* @return {Number} angle
|
* @return {Number} angle
|
||||||
*/
|
*/
|
||||||
function getAngle(p1, p2, props?) {
|
function getAngle(p1: any, p2: any, props?: any) {
|
||||||
if (!props) {
|
if (!props) {
|
||||||
props = PROPS_XY;
|
props = PROPS_XY;
|
||||||
}
|
}
|
||||||
@ -677,7 +677,7 @@ function getAngle(p1, p2, props?) {
|
|||||||
* @param {Array} end array of pointers
|
* @param {Array} end array of pointers
|
||||||
* @return {Number} rotation
|
* @return {Number} rotation
|
||||||
*/
|
*/
|
||||||
function getRotation(start, end) {
|
function getRotation(start: any, end: any) {
|
||||||
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -688,11 +688,11 @@ function getRotation(start, end) {
|
|||||||
* @param {Array} end array of pointers
|
* @param {Array} end array of pointers
|
||||||
* @return {Number} scale
|
* @return {Number} scale
|
||||||
*/
|
*/
|
||||||
function getScale(start, end) {
|
function getScale(start: any, end: any) {
|
||||||
return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
||||||
}
|
}
|
||||||
|
|
||||||
var MOUSE_INPUT_MAP = {
|
var MOUSE_INPUT_MAP: any = {
|
||||||
mousedown: INPUT_START,
|
mousedown: INPUT_START,
|
||||||
mousemove: INPUT_MOVE,
|
mousemove: INPUT_MOVE,
|
||||||
mouseup: INPUT_END
|
mouseup: INPUT_END
|
||||||
@ -721,7 +721,7 @@ inherit(MouseInput, Input, {
|
|||||||
* handle mouse events
|
* handle mouse events
|
||||||
* @param {Object} ev
|
* @param {Object} ev
|
||||||
*/
|
*/
|
||||||
handler: function MEhandler(ev) {
|
handler: function MEhandler(ev: any) {
|
||||||
var eventType = MOUSE_INPUT_MAP[ev.type];
|
var eventType = MOUSE_INPUT_MAP[ev.type];
|
||||||
|
|
||||||
// on start we want to have the left mouse button down
|
// on start we want to have the left mouse button down
|
||||||
@ -751,7 +751,7 @@ inherit(MouseInput, Input, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var POINTER_INPUT_MAP = {
|
var POINTER_INPUT_MAP: any = {
|
||||||
pointerdown: INPUT_START,
|
pointerdown: INPUT_START,
|
||||||
pointermove: INPUT_MOVE,
|
pointermove: INPUT_MOVE,
|
||||||
pointerup: INPUT_END,
|
pointerup: INPUT_END,
|
||||||
@ -760,7 +760,7 @@ var POINTER_INPUT_MAP = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// in IE10 the pointer types is defined as an enum
|
// in IE10 the pointer types is defined as an enum
|
||||||
var IE10_POINTER_TYPE_ENUM = {
|
var IE10_POINTER_TYPE_ENUM: any = {
|
||||||
2: INPUT_TYPE_TOUCH,
|
2: INPUT_TYPE_TOUCH,
|
||||||
3: INPUT_TYPE_PEN,
|
3: INPUT_TYPE_PEN,
|
||||||
4: INPUT_TYPE_MOUSE,
|
4: INPUT_TYPE_MOUSE,
|
||||||
@ -795,7 +795,7 @@ inherit(PointerEventInput, Input, {
|
|||||||
* handle mouse events
|
* handle mouse events
|
||||||
* @param {Object} ev
|
* @param {Object} ev
|
||||||
*/
|
*/
|
||||||
handler: function PEhandler(ev) {
|
handler: function PEhandler(ev: any) {
|
||||||
var store = this.store;
|
var store = this.store;
|
||||||
var removePointer = false;
|
var removePointer = false;
|
||||||
|
|
||||||
@ -840,7 +840,7 @@ inherit(PointerEventInput, Input, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var SINGLE_TOUCH_INPUT_MAP = {
|
var SINGLE_TOUCH_INPUT_MAP: any = {
|
||||||
touchstart: INPUT_START,
|
touchstart: INPUT_START,
|
||||||
touchmove: INPUT_MOVE,
|
touchmove: INPUT_MOVE,
|
||||||
touchend: INPUT_END,
|
touchend: INPUT_END,
|
||||||
@ -864,7 +864,7 @@ function SingleTouchInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inherit(SingleTouchInput, Input, {
|
inherit(SingleTouchInput, Input, {
|
||||||
handler: function TEhandler(ev) {
|
handler: function TEhandler(ev: any) {
|
||||||
var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
||||||
|
|
||||||
// should we handle the touch events?
|
// should we handle the touch events?
|
||||||
@ -898,7 +898,7 @@ inherit(SingleTouchInput, Input, {
|
|||||||
* @param {Number} type flag
|
* @param {Number} type flag
|
||||||
* @returns {undefined|Array} [all, changed]
|
* @returns {undefined|Array} [all, changed]
|
||||||
*/
|
*/
|
||||||
function normalizeSingleTouches(ev, type) {
|
function normalizeSingleTouches(ev: any, type: any) {
|
||||||
var all = toArray(ev.touches);
|
var all = toArray(ev.touches);
|
||||||
var changed = toArray(ev.changedTouches);
|
var changed = toArray(ev.changedTouches);
|
||||||
|
|
||||||
@ -909,7 +909,7 @@ function normalizeSingleTouches(ev, type) {
|
|||||||
return [all, changed];
|
return [all, changed];
|
||||||
}
|
}
|
||||||
|
|
||||||
var TOUCH_INPUT_MAP = {
|
var TOUCH_INPUT_MAP : any= {
|
||||||
touchstart: INPUT_START,
|
touchstart: INPUT_START,
|
||||||
touchmove: INPUT_MOVE,
|
touchmove: INPUT_MOVE,
|
||||||
touchend: INPUT_END,
|
touchend: INPUT_END,
|
||||||
@ -923,7 +923,7 @@ var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @extends Input
|
* @extends Input
|
||||||
*/
|
*/
|
||||||
function TouchInput(manager: any, handler: any) {
|
function TouchInput(manager: any, handler: any): void {
|
||||||
this.evTarget = TOUCH_TARGET_EVENTS;
|
this.evTarget = TOUCH_TARGET_EVENTS;
|
||||||
this.targetIds = {};
|
this.targetIds = {};
|
||||||
|
|
||||||
@ -931,7 +931,7 @@ function TouchInput(manager: any, handler: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inherit(TouchInput, Input, {
|
inherit(TouchInput, Input, {
|
||||||
handler: function MTEhandler(ev) {
|
handler: function MTEhandler(ev: any) {
|
||||||
var type = TOUCH_INPUT_MAP[ev.type];
|
var type = TOUCH_INPUT_MAP[ev.type];
|
||||||
var touches = getTouches.call(this, ev, type);
|
var touches = getTouches.call(this, ev, type);
|
||||||
if (!touches) {
|
if (!touches) {
|
||||||
@ -953,7 +953,7 @@ inherit(TouchInput, Input, {
|
|||||||
* @param {Number} type flag
|
* @param {Number} type flag
|
||||||
* @returns {undefined|Array} [all, changed]
|
* @returns {undefined|Array} [all, changed]
|
||||||
*/
|
*/
|
||||||
function getTouches(ev, type) {
|
function getTouches(ev: any, type: any) {
|
||||||
var allTouches = toArray(ev.touches);
|
var allTouches = toArray(ev.touches);
|
||||||
var targetIds = this.targetIds;
|
var targetIds = this.targetIds;
|
||||||
|
|
||||||
@ -963,14 +963,14 @@ function getTouches(ev, type) {
|
|||||||
return [allTouches, allTouches];
|
return [allTouches, allTouches];
|
||||||
}
|
}
|
||||||
|
|
||||||
var i,
|
var i: any,
|
||||||
targetTouches,
|
targetTouches: any,
|
||||||
changedTouches = toArray(ev.changedTouches),
|
changedTouches = toArray(ev.changedTouches),
|
||||||
changedTargetTouches = [],
|
changedTargetTouches: any = [],
|
||||||
target = this.target;
|
target = this.target;
|
||||||
|
|
||||||
// get target touches from touches
|
// get target touches from touches
|
||||||
targetTouches = allTouches.filter(function(touch) {
|
targetTouches = allTouches.filter(function(touch: any) {
|
||||||
return hasParent(touch.target, target);
|
return hasParent(touch.target, target);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1017,12 +1017,12 @@ function getTouches(ev, type) {
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @extends Input
|
* @extends Input
|
||||||
*/
|
*/
|
||||||
function TouchMouseInput() {
|
function TouchMouseInput(): void {
|
||||||
Input.apply(this, arguments);
|
Input.apply(this, arguments);
|
||||||
|
|
||||||
var handler = bindFn(this.handler, this);
|
var handler = bindFn(this.handler, this);
|
||||||
this.touch = new TouchInput(this.manager, handler);
|
this.touch = new (<any>TouchInput)(this.manager, handler);
|
||||||
this.mouse = new MouseInput(this.manager, handler);
|
this.mouse = new (<any>MouseInput)(this.manager, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
inherit(TouchMouseInput, Input, {
|
inherit(TouchMouseInput, Input, {
|
||||||
@ -1032,7 +1032,7 @@ inherit(TouchMouseInput, Input, {
|
|||||||
* @param {String} inputEvent
|
* @param {String} inputEvent
|
||||||
* @param {Object} inputData
|
* @param {Object} inputData
|
||||||
*/
|
*/
|
||||||
handler: function TMEhandler(manager, inputEvent, inputData) {
|
handler: function TMEhandler(manager: any, inputEvent: any, inputData: any) {
|
||||||
var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH),
|
var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH),
|
||||||
isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
|
isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
|
||||||
|
|
||||||
@ -1079,7 +1079,7 @@ var TOUCH_ACTION_PAN_Y = 'pan-y';
|
|||||||
* @param {String} value
|
* @param {String} value
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function TouchAction(manager, value) {
|
function TouchAction(manager: any, value: any) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.set(value);
|
this.set(value);
|
||||||
}
|
}
|
||||||
@ -1089,7 +1089,7 @@ TouchAction.prototype = {
|
|||||||
* set the touchAction value on the element or enable the polyfill
|
* set the touchAction value on the element or enable the polyfill
|
||||||
* @param {String} value
|
* @param {String} value
|
||||||
*/
|
*/
|
||||||
set: function(value) {
|
set: function(value: any) {
|
||||||
// find out the touch-action by the event handlers
|
// find out the touch-action by the event handlers
|
||||||
if (value == TOUCH_ACTION_COMPUTE) {
|
if (value == TOUCH_ACTION_COMPUTE) {
|
||||||
value = this.compute();
|
value = this.compute();
|
||||||
@ -1113,8 +1113,8 @@ TouchAction.prototype = {
|
|||||||
* @returns {String} value
|
* @returns {String} value
|
||||||
*/
|
*/
|
||||||
compute: function() {
|
compute: function() {
|
||||||
var actions = [];
|
var actions: any = [];
|
||||||
each(this.manager.recognizers, function(recognizer) {
|
each(this.manager.recognizers, function(recognizer: any) {
|
||||||
if (boolOrFn(recognizer.options.enable, [recognizer])) {
|
if (boolOrFn(recognizer.options.enable, [recognizer])) {
|
||||||
actions = actions.concat(recognizer.getTouchAction());
|
actions = actions.concat(recognizer.getTouchAction());
|
||||||
}
|
}
|
||||||
@ -1126,7 +1126,7 @@ TouchAction.prototype = {
|
|||||||
* this method is called on each input cycle and provides the preventing of the browser behavior
|
* this method is called on each input cycle and provides the preventing of the browser behavior
|
||||||
* @param {Object} input
|
* @param {Object} input
|
||||||
*/
|
*/
|
||||||
preventDefaults: function(input) {
|
preventDefaults: function(input: any) {
|
||||||
// not needed with native support for the touchAction property
|
// not needed with native support for the touchAction property
|
||||||
if (NATIVE_TOUCH_ACTION) {
|
if (NATIVE_TOUCH_ACTION) {
|
||||||
return;
|
return;
|
||||||
@ -1174,7 +1174,7 @@ TouchAction.prototype = {
|
|||||||
* call preventDefault to prevent the browser's default behavior (scrolling in most cases)
|
* call preventDefault to prevent the browser's default behavior (scrolling in most cases)
|
||||||
* @param {Object} srcEvent
|
* @param {Object} srcEvent
|
||||||
*/
|
*/
|
||||||
preventSrc: function(srcEvent) {
|
preventSrc: function(srcEvent: any) {
|
||||||
this.manager.session.prevented = true;
|
this.manager.session.prevented = true;
|
||||||
srcEvent.preventDefault();
|
srcEvent.preventDefault();
|
||||||
}
|
}
|
||||||
@ -1185,7 +1185,7 @@ TouchAction.prototype = {
|
|||||||
* @param {String} actions
|
* @param {String} actions
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function cleanTouchActions(actions) {
|
function cleanTouchActions(actions: any) {
|
||||||
// none
|
// none
|
||||||
if (inStr(actions, TOUCH_ACTION_NONE)) {
|
if (inStr(actions, TOUCH_ACTION_NONE)) {
|
||||||
return TOUCH_ACTION_NONE;
|
return TOUCH_ACTION_NONE;
|
||||||
@ -1256,7 +1256,7 @@ var STATE_FAILED = 32;
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
*/
|
*/
|
||||||
function Recognizer(options) {
|
function Recognizer(options: any) {
|
||||||
this.options = Object.assign({}, this.defaults, options || {});
|
this.options = Object.assign({}, this.defaults, options || {});
|
||||||
|
|
||||||
this.id = uniqueId();
|
this.id = uniqueId();
|
||||||
@ -1284,7 +1284,7 @@ Recognizer.prototype = {
|
|||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
* @return {Recognizer}
|
* @return {Recognizer}
|
||||||
*/
|
*/
|
||||||
set: function(options) {
|
set: function(options: any) {
|
||||||
Object.assign(this.options, options);
|
Object.assign(this.options, options);
|
||||||
|
|
||||||
// also update the touchAction, in case something changed about the directions/enabled state
|
// also update the touchAction, in case something changed about the directions/enabled state
|
||||||
@ -1297,7 +1297,7 @@ Recognizer.prototype = {
|
|||||||
* @param {Recognizer} otherRecognizer
|
* @param {Recognizer} otherRecognizer
|
||||||
* @returns {Recognizer} this
|
* @returns {Recognizer} this
|
||||||
*/
|
*/
|
||||||
recognizeWith: function(otherRecognizer) {
|
recognizeWith: function(otherRecognizer: any) {
|
||||||
if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
|
if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -1316,7 +1316,7 @@ Recognizer.prototype = {
|
|||||||
* @param {Recognizer} otherRecognizer
|
* @param {Recognizer} otherRecognizer
|
||||||
* @returns {Recognizer} this
|
* @returns {Recognizer} this
|
||||||
*/
|
*/
|
||||||
dropRecognizeWith: function(otherRecognizer) {
|
dropRecognizeWith: function(otherRecognizer: any) {
|
||||||
if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
|
if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -1331,7 +1331,7 @@ Recognizer.prototype = {
|
|||||||
* @param {Recognizer} otherRecognizer
|
* @param {Recognizer} otherRecognizer
|
||||||
* @returns {Recognizer} this
|
* @returns {Recognizer} this
|
||||||
*/
|
*/
|
||||||
requireFailure: function(otherRecognizer) {
|
requireFailure: function(otherRecognizer: any) {
|
||||||
if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
|
if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -1350,7 +1350,7 @@ Recognizer.prototype = {
|
|||||||
* @param {Recognizer} otherRecognizer
|
* @param {Recognizer} otherRecognizer
|
||||||
* @returns {Recognizer} this
|
* @returns {Recognizer} this
|
||||||
*/
|
*/
|
||||||
dropRequireFailure: function(otherRecognizer) {
|
dropRequireFailure: function(otherRecognizer: any) {
|
||||||
if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
|
if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -1376,7 +1376,7 @@ Recognizer.prototype = {
|
|||||||
* @param {Recognizer} otherRecognizer
|
* @param {Recognizer} otherRecognizer
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
canRecognizeWith: function(otherRecognizer) {
|
canRecognizeWith: function(otherRecognizer: any) {
|
||||||
return !!this.simultaneous[otherRecognizer.id];
|
return !!this.simultaneous[otherRecognizer.id];
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1385,11 +1385,11 @@ Recognizer.prototype = {
|
|||||||
* that all the needed recognizers has failed before emitting.
|
* that all the needed recognizers has failed before emitting.
|
||||||
* @param {Object} input
|
* @param {Object} input
|
||||||
*/
|
*/
|
||||||
emit: function(input) {
|
emit: function(input: any) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var state = this.state;
|
var state = this.state;
|
||||||
|
|
||||||
function emit(event) {
|
function emit(event: any) {
|
||||||
self.manager.emit(event, input);
|
self.manager.emit(event, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1416,7 +1416,7 @@ Recognizer.prototype = {
|
|||||||
* otherwise, setup the state to FAILED.
|
* otherwise, setup the state to FAILED.
|
||||||
* @param {Object} input
|
* @param {Object} input
|
||||||
*/
|
*/
|
||||||
tryEmit: function(input) {
|
tryEmit: function(input: any) {
|
||||||
if (this.canEmit()) {
|
if (this.canEmit()) {
|
||||||
return this.emit(input);
|
return this.emit(input);
|
||||||
}
|
}
|
||||||
@ -1443,7 +1443,7 @@ Recognizer.prototype = {
|
|||||||
* update the recognizer
|
* update the recognizer
|
||||||
* @param {Object} inputData
|
* @param {Object} inputData
|
||||||
*/
|
*/
|
||||||
recognize: function(inputData) {
|
recognize: function(inputData: any) {
|
||||||
// make a new copy of the inputData
|
// make a new copy of the inputData
|
||||||
// so we can change the inputData without messing up the other recognizers
|
// so we can change the inputData without messing up the other recognizers
|
||||||
var inputDataClone = Object.assign({}, inputData);
|
var inputDataClone = Object.assign({}, inputData);
|
||||||
@ -1476,7 +1476,7 @@ Recognizer.prototype = {
|
|||||||
* @param {Object} inputData
|
* @param {Object} inputData
|
||||||
* @returns {Const} STATE
|
* @returns {Const} STATE
|
||||||
*/
|
*/
|
||||||
process: function(inputData) { }, // jshint ignore:line
|
process: function(inputData: any) { }, // jshint ignore:line
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the preferred touch-action
|
* return the preferred touch-action
|
||||||
@ -1498,7 +1498,7 @@ Recognizer.prototype = {
|
|||||||
* @param {Const} state
|
* @param {Const} state
|
||||||
* @returns {String} state
|
* @returns {String} state
|
||||||
*/
|
*/
|
||||||
function stateStr(state) {
|
function stateStr(state: any) {
|
||||||
if (state & STATE_CANCELLED) {
|
if (state & STATE_CANCELLED) {
|
||||||
return 'cancel';
|
return 'cancel';
|
||||||
} else if (state & STATE_ENDED) {
|
} else if (state & STATE_ENDED) {
|
||||||
@ -1516,7 +1516,7 @@ function stateStr(state) {
|
|||||||
* @param {Const} direction
|
* @param {Const} direction
|
||||||
* @returns {String}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
function directionStr(direction) {
|
function directionStr(direction: any) {
|
||||||
if (direction == DIRECTION_DOWN) {
|
if (direction == DIRECTION_DOWN) {
|
||||||
return 'down';
|
return 'down';
|
||||||
} else if (direction == DIRECTION_UP) {
|
} else if (direction == DIRECTION_UP) {
|
||||||
@ -1535,7 +1535,7 @@ function directionStr(direction) {
|
|||||||
* @param {Recognizer} recognizer
|
* @param {Recognizer} recognizer
|
||||||
* @returns {Recognizer}
|
* @returns {Recognizer}
|
||||||
*/
|
*/
|
||||||
function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
function getRecognizerByNameIfManager(otherRecognizer: any, recognizer: any) {
|
||||||
var manager = recognizer.manager;
|
var manager = recognizer.manager;
|
||||||
if (manager) {
|
if (manager) {
|
||||||
return manager.get(otherRecognizer);
|
return manager.get(otherRecognizer);
|
||||||
@ -1571,7 +1571,7 @@ inherit(AttrRecognizer, Recognizer, {
|
|||||||
* @param {Object} input
|
* @param {Object} input
|
||||||
* @returns {Boolean} recognized
|
* @returns {Boolean} recognized
|
||||||
*/
|
*/
|
||||||
attrTest: function(input) {
|
attrTest: function(input: any) {
|
||||||
var optionPointers = this.options.pointers;
|
var optionPointers = this.options.pointers;
|
||||||
return optionPointers === 0 || input.pointers.length === optionPointers;
|
return optionPointers === 0 || input.pointers.length === optionPointers;
|
||||||
},
|
},
|
||||||
@ -1582,7 +1582,7 @@ inherit(AttrRecognizer, Recognizer, {
|
|||||||
* @param {Object} input
|
* @param {Object} input
|
||||||
* @returns {*} State
|
* @returns {*} State
|
||||||
*/
|
*/
|
||||||
process: function(input) {
|
process: function(input: any) {
|
||||||
var state = this.state;
|
var state = this.state;
|
||||||
var eventType = input.eventType;
|
var eventType = input.eventType;
|
||||||
|
|
||||||
@ -1631,7 +1631,7 @@ inherit(PanRecognizer, AttrRecognizer, {
|
|||||||
|
|
||||||
getTouchAction: function() {
|
getTouchAction: function() {
|
||||||
var direction = this.options.direction;
|
var direction = this.options.direction;
|
||||||
var actions = [];
|
var actions: any = [];
|
||||||
if (direction & DIRECTION_HORIZONTAL) {
|
if (direction & DIRECTION_HORIZONTAL) {
|
||||||
actions.push(TOUCH_ACTION_PAN_Y);
|
actions.push(TOUCH_ACTION_PAN_Y);
|
||||||
}
|
}
|
||||||
@ -1641,7 +1641,7 @@ inherit(PanRecognizer, AttrRecognizer, {
|
|||||||
return actions;
|
return actions;
|
||||||
},
|
},
|
||||||
|
|
||||||
directionTest: function(input) {
|
directionTest: function(input: any) {
|
||||||
var options = this.options;
|
var options = this.options;
|
||||||
var hasMoved = true;
|
var hasMoved = true;
|
||||||
var distance = input.distance;
|
var distance = input.distance;
|
||||||
@ -1665,12 +1665,12 @@ inherit(PanRecognizer, AttrRecognizer, {
|
|||||||
return hasMoved && distance > options.threshold && direction & options.direction;
|
return hasMoved && distance > options.threshold && direction & options.direction;
|
||||||
},
|
},
|
||||||
|
|
||||||
attrTest: function(input) {
|
attrTest: function(input: any) {
|
||||||
return AttrRecognizer.prototype.attrTest.call(this, input) &&
|
return AttrRecognizer.prototype.attrTest.call(this, input) &&
|
||||||
(this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input)));
|
(this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input)));
|
||||||
},
|
},
|
||||||
|
|
||||||
emit: function(input) {
|
emit: function(input: any) {
|
||||||
|
|
||||||
this.pX = input.deltaX;
|
this.pX = input.deltaX;
|
||||||
this.pY = input.deltaY;
|
this.pY = input.deltaY;
|
||||||
@ -1709,12 +1709,12 @@ inherit(PinchRecognizer, AttrRecognizer, {
|
|||||||
return [TOUCH_ACTION_NONE];
|
return [TOUCH_ACTION_NONE];
|
||||||
},
|
},
|
||||||
|
|
||||||
attrTest: function(input) {
|
attrTest: function(input: any) {
|
||||||
return this._super.attrTest.call(this, input) &&
|
return this._super.attrTest.call(this, input) &&
|
||||||
(Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
|
(Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
|
||||||
},
|
},
|
||||||
|
|
||||||
emit: function(input) {
|
emit: function(input: any) {
|
||||||
if (input.scale !== 1) {
|
if (input.scale !== 1) {
|
||||||
var inOut = input.scale < 1 ? 'in' : 'out';
|
var inOut = input.scale < 1 ? 'in' : 'out';
|
||||||
input.additionalEvent = this.options.event + inOut;
|
input.additionalEvent = this.options.event + inOut;
|
||||||
@ -1752,7 +1752,7 @@ inherit(PressRecognizer, Recognizer, {
|
|||||||
return [TOUCH_ACTION_AUTO];
|
return [TOUCH_ACTION_AUTO];
|
||||||
},
|
},
|
||||||
|
|
||||||
process: function(input) {
|
process: function(input: any) {
|
||||||
var options = this.options;
|
var options = this.options;
|
||||||
var validPointers = input.pointers.length === options.pointers;
|
var validPointers = input.pointers.length === options.pointers;
|
||||||
var validMovement = input.distance < options.threshold;
|
var validMovement = input.distance < options.threshold;
|
||||||
@ -1780,7 +1780,7 @@ inherit(PressRecognizer, Recognizer, {
|
|||||||
clearTimeout(this._timer);
|
clearTimeout(this._timer);
|
||||||
},
|
},
|
||||||
|
|
||||||
emit: function(input) {
|
emit: function(input: any) {
|
||||||
if (this.state !== STATE_RECOGNIZED) {
|
if (this.state !== STATE_RECOGNIZED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1819,7 +1819,7 @@ inherit(RotateRecognizer, AttrRecognizer, {
|
|||||||
return [TOUCH_ACTION_NONE];
|
return [TOUCH_ACTION_NONE];
|
||||||
},
|
},
|
||||||
|
|
||||||
attrTest: function(input) {
|
attrTest: function(input: any) {
|
||||||
return this._super.attrTest.call(this, input) &&
|
return this._super.attrTest.call(this, input) &&
|
||||||
(Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
(Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
||||||
}
|
}
|
||||||
@ -1852,9 +1852,9 @@ inherit(SwipeRecognizer, AttrRecognizer, {
|
|||||||
return PanRecognizer.prototype.getTouchAction.call(this);
|
return PanRecognizer.prototype.getTouchAction.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
attrTest: function(input) {
|
attrTest: function(input: any) {
|
||||||
var direction = this.options.direction;
|
var direction = this.options.direction;
|
||||||
var velocity;
|
var velocity: any;
|
||||||
|
|
||||||
if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
|
if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
|
||||||
velocity = input.overallVelocity;
|
velocity = input.overallVelocity;
|
||||||
@ -1871,7 +1871,7 @@ inherit(SwipeRecognizer, AttrRecognizer, {
|
|||||||
abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
|
abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
|
||||||
},
|
},
|
||||||
|
|
||||||
emit: function(input) {
|
emit: function(input: any) {
|
||||||
var direction = directionStr(input.offsetDirection);
|
var direction = directionStr(input.offsetDirection);
|
||||||
if (direction) {
|
if (direction) {
|
||||||
this.manager.emit(this.options.event + direction, input);
|
this.manager.emit(this.options.event + direction, input);
|
||||||
@ -1923,7 +1923,7 @@ inherit(TapRecognizer, Recognizer, {
|
|||||||
return [TOUCH_ACTION_MANIPULATION];
|
return [TOUCH_ACTION_MANIPULATION];
|
||||||
},
|
},
|
||||||
|
|
||||||
process: function(input) {
|
process: function(input: any) {
|
||||||
var options = this.options;
|
var options = this.options;
|
||||||
|
|
||||||
var validPointers = input.pointers.length === options.pointers;
|
var validPointers = input.pointers.length === options.pointers;
|
||||||
@ -2002,10 +2002,10 @@ inherit(TapRecognizer, Recognizer, {
|
|||||||
* @param {Object} [options]
|
* @param {Object} [options]
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Hammer(element, options) {
|
function Hammer(element: any, options: any): any {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.recognizers = ifUndefined(options.recognizers, _defaults.preset);
|
options.recognizers = ifUndefined(options.recognizers, _defaults.preset);
|
||||||
return new Manager(element, options);
|
return new (<any>Manager)(element, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2017,7 +2017,7 @@ var VERSION = '2.0.6';
|
|||||||
* default settings
|
* default settings
|
||||||
* @namespace
|
* @namespace
|
||||||
*/
|
*/
|
||||||
var _defaults = {
|
var _defaults: any = {
|
||||||
/**
|
/**
|
||||||
* set if DOM events are being triggered.
|
* set if DOM events are being triggered.
|
||||||
* But this is slower and unused by simple implementations, so disabled by default.
|
* But this is slower and unused by simple implementations, so disabled by default.
|
||||||
@ -2134,7 +2134,7 @@ var FORCED_STOP = 2;
|
|||||||
* @param {Object} [options]
|
* @param {Object} [options]
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Manager(element, options) {
|
function Manager(element: any, options: any) {
|
||||||
this.options = Object.assign({}, _defaults, options || {});
|
this.options = Object.assign({}, _defaults, options || {});
|
||||||
|
|
||||||
this.options.inputTarget = this.options.inputTarget || element;
|
this.options.inputTarget = this.options.inputTarget || element;
|
||||||
@ -2145,11 +2145,11 @@ function Manager(element, options) {
|
|||||||
|
|
||||||
this.element = element;
|
this.element = element;
|
||||||
this.input = createInputInstance(this);
|
this.input = createInputInstance(this);
|
||||||
this.touchAction = new TouchAction(this, this.options.touchAction);
|
this.touchAction = new (<any>TouchAction)(this, this.options.touchAction);
|
||||||
|
|
||||||
toggleCssProps(this, true);
|
toggleCssProps(this, true);
|
||||||
|
|
||||||
each(this.options.recognizers, function(item) {
|
each(this.options.recognizers, function(item: any) {
|
||||||
var recognizer = this.add(new (item[0])(item[1]));
|
var recognizer = this.add(new (item[0])(item[1]));
|
||||||
item[2] && recognizer.recognizeWith(item[2]);
|
item[2] && recognizer.recognizeWith(item[2]);
|
||||||
item[3] && recognizer.requireFailure(item[3]);
|
item[3] && recognizer.requireFailure(item[3]);
|
||||||
@ -2162,7 +2162,7 @@ Manager.prototype = {
|
|||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
* @returns {Manager}
|
* @returns {Manager}
|
||||||
*/
|
*/
|
||||||
set: function(options) {
|
set: function(options: any) {
|
||||||
Object.assign(this.options, options);
|
Object.assign(this.options, options);
|
||||||
|
|
||||||
// Options that need a little more setup
|
// Options that need a little more setup
|
||||||
@ -2184,7 +2184,7 @@ Manager.prototype = {
|
|||||||
* When forced, the recognizer cycle is stopped immediately.
|
* When forced, the recognizer cycle is stopped immediately.
|
||||||
* @param {Boolean} [force]
|
* @param {Boolean} [force]
|
||||||
*/
|
*/
|
||||||
stop: function(force) {
|
stop: function(force: any) {
|
||||||
this.session.stopped = force ? FORCED_STOP : STOP;
|
this.session.stopped = force ? FORCED_STOP : STOP;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2194,7 +2194,7 @@ Manager.prototype = {
|
|||||||
* it walks through all the recognizers and tries to detect the gesture that is being made
|
* it walks through all the recognizers and tries to detect the gesture that is being made
|
||||||
* @param {Object} inputData
|
* @param {Object} inputData
|
||||||
*/
|
*/
|
||||||
recognize: function(inputData) {
|
recognize: function(inputData: any) {
|
||||||
var session = this.session;
|
var session = this.session;
|
||||||
if (session.stopped) {
|
if (session.stopped) {
|
||||||
return;
|
return;
|
||||||
@ -2203,7 +2203,7 @@ Manager.prototype = {
|
|||||||
// run the touch-action polyfill
|
// run the touch-action polyfill
|
||||||
this.touchAction.preventDefaults(inputData);
|
this.touchAction.preventDefaults(inputData);
|
||||||
|
|
||||||
var recognizer;
|
var recognizer: any;
|
||||||
var recognizers = this.recognizers;
|
var recognizers = this.recognizers;
|
||||||
|
|
||||||
// this holds the recognizer that is being recognized.
|
// this holds the recognizer that is being recognized.
|
||||||
@ -2249,7 +2249,7 @@ Manager.prototype = {
|
|||||||
* @param {Recognizer|String} recognizer
|
* @param {Recognizer|String} recognizer
|
||||||
* @returns {Recognizer|Null}
|
* @returns {Recognizer|Null}
|
||||||
*/
|
*/
|
||||||
get: function(recognizer) {
|
get: function(recognizer: any) {
|
||||||
if (recognizer instanceof Recognizer) {
|
if (recognizer instanceof Recognizer) {
|
||||||
return recognizer;
|
return recognizer;
|
||||||
}
|
}
|
||||||
@ -2269,7 +2269,7 @@ Manager.prototype = {
|
|||||||
* @param {Recognizer} recognizer
|
* @param {Recognizer} recognizer
|
||||||
* @returns {Recognizer|Manager}
|
* @returns {Recognizer|Manager}
|
||||||
*/
|
*/
|
||||||
add: function(recognizer) {
|
add: function(recognizer: any) {
|
||||||
if (invokeArrayArg(recognizer, 'add', this)) {
|
if (invokeArrayArg(recognizer, 'add', this)) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -2292,7 +2292,7 @@ Manager.prototype = {
|
|||||||
* @param {Recognizer|String} recognizer
|
* @param {Recognizer|String} recognizer
|
||||||
* @returns {Manager}
|
* @returns {Manager}
|
||||||
*/
|
*/
|
||||||
remove: function(recognizer) {
|
remove: function(recognizer: any) {
|
||||||
if (invokeArrayArg(recognizer, 'remove', this)) {
|
if (invokeArrayArg(recognizer, 'remove', this)) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -2319,9 +2319,9 @@ Manager.prototype = {
|
|||||||
* @param {Function} handler
|
* @param {Function} handler
|
||||||
* @returns {EventEmitter} this
|
* @returns {EventEmitter} this
|
||||||
*/
|
*/
|
||||||
on: function(events, handler) {
|
on: function(events: any, handler: any) {
|
||||||
var handlers = this.handlers;
|
var handlers = this.handlers;
|
||||||
each(splitStr(events), function(event) {
|
each(splitStr(events), function(event: any) {
|
||||||
handlers[event] = handlers[event] || [];
|
handlers[event] = handlers[event] || [];
|
||||||
handlers[event].push(handler);
|
handlers[event].push(handler);
|
||||||
});
|
});
|
||||||
@ -2334,9 +2334,9 @@ Manager.prototype = {
|
|||||||
* @param {Function} [handler]
|
* @param {Function} [handler]
|
||||||
* @returns {EventEmitter} this
|
* @returns {EventEmitter} this
|
||||||
*/
|
*/
|
||||||
off: function(events, handler) {
|
off: function(events: any, handler: any) {
|
||||||
var handlers = this.handlers;
|
var handlers = this.handlers;
|
||||||
each(splitStr(events), function(event) {
|
each(splitStr(events), function(event: any) {
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
delete handlers[event];
|
delete handlers[event];
|
||||||
} else {
|
} else {
|
||||||
@ -2351,7 +2351,7 @@ Manager.prototype = {
|
|||||||
* @param {String} event
|
* @param {String} event
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
*/
|
*/
|
||||||
emit: function(event, data) {
|
emit: function(event: any, data: any) {
|
||||||
// we also want to trigger dom events
|
// we also want to trigger dom events
|
||||||
if (this.options.domEvents) {
|
if (this.options.domEvents) {
|
||||||
triggerDomEvent(event, data);
|
triggerDomEvent(event, data);
|
||||||
@ -2394,12 +2394,12 @@ Manager.prototype = {
|
|||||||
* @param {Manager} manager
|
* @param {Manager} manager
|
||||||
* @param {Boolean} add
|
* @param {Boolean} add
|
||||||
*/
|
*/
|
||||||
function toggleCssProps(manager, add) {
|
function toggleCssProps(manager: any, add: any) {
|
||||||
var element = manager.element;
|
var element = manager.element;
|
||||||
if (!element.style) {
|
if (!element.style) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
each(manager.options.cssProps, function(value, name) {
|
each(manager.options.cssProps, function(value: any, name: any) {
|
||||||
element.style[prefixed(element.style, name)] = add ? value : '';
|
element.style[prefixed(element.style, name)] = add ? value : '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2409,7 +2409,7 @@ function toggleCssProps(manager, add) {
|
|||||||
* @param {String} event
|
* @param {String} event
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
*/
|
*/
|
||||||
function triggerDomEvent(event, data) {
|
function triggerDomEvent(event: any, data: any) {
|
||||||
var gestureEvent: any = doc.createEvent('Event');
|
var gestureEvent: any = doc.createEvent('Event');
|
||||||
gestureEvent.initEvent(event, true, true);
|
gestureEvent.initEvent(event, true, true);
|
||||||
gestureEvent.gesture = data;
|
gestureEvent.gesture = data;
|
||||||
|
@ -608,5 +608,5 @@ export abstract class NavController {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
abstract registerChildNav(nav: any);
|
abstract registerChildNav(nav: any): void;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ describe('ViewController', () => {
|
|||||||
it('should emit LifeCycleEvent when called with component data', (done) => {
|
it('should emit LifeCycleEvent when called with component data', (done) => {
|
||||||
// arrange
|
// arrange
|
||||||
let viewController = mockView();
|
let viewController = mockView();
|
||||||
subscription = viewController.willEnter.subscribe((event) => {
|
subscription = viewController.willEnter.subscribe((event: any) => {
|
||||||
// assert
|
// assert
|
||||||
expect(event).toEqual(null);
|
expect(event).toEqual(null);
|
||||||
done();
|
done();
|
||||||
@ -24,7 +24,7 @@ describe('ViewController', () => {
|
|||||||
it('should emit LifeCycleEvent when called with component data', (done) => {
|
it('should emit LifeCycleEvent when called with component data', (done) => {
|
||||||
// arrange
|
// arrange
|
||||||
let viewController = mockView();
|
let viewController = mockView();
|
||||||
subscription = viewController.didEnter.subscribe((event) => {
|
subscription = viewController.didEnter.subscribe((event: any) => {
|
||||||
// assert
|
// assert
|
||||||
expect(event).toEqual(null);
|
expect(event).toEqual(null);
|
||||||
done();
|
done();
|
||||||
@ -41,7 +41,7 @@ describe('ViewController', () => {
|
|||||||
it('should emit LifeCycleEvent when called with component data', (done) => {
|
it('should emit LifeCycleEvent when called with component data', (done) => {
|
||||||
// arrange
|
// arrange
|
||||||
let viewController = mockView();
|
let viewController = mockView();
|
||||||
subscription = viewController.willLeave.subscribe((event) => {
|
subscription = viewController.willLeave.subscribe((event: any) => {
|
||||||
// assert
|
// assert
|
||||||
expect(event).toEqual(null);
|
expect(event).toEqual(null);
|
||||||
done();
|
done();
|
||||||
@ -58,7 +58,7 @@ describe('ViewController', () => {
|
|||||||
it('should emit LifeCycleEvent when called with component data', (done) => {
|
it('should emit LifeCycleEvent when called with component data', (done) => {
|
||||||
// arrange
|
// arrange
|
||||||
let viewController = mockView();
|
let viewController = mockView();
|
||||||
subscription = viewController.didLeave.subscribe((event) => {
|
subscription = viewController.didLeave.subscribe((event: any) => {
|
||||||
// assert
|
// assert
|
||||||
expect(event).toEqual(null);
|
expect(event).toEqual(null);
|
||||||
done();
|
done();
|
||||||
@ -75,7 +75,7 @@ describe('ViewController', () => {
|
|||||||
it('should emit LifeCycleEvent when called with component data', (done) => {
|
it('should emit LifeCycleEvent when called with component data', (done) => {
|
||||||
// arrange
|
// arrange
|
||||||
let viewController = mockView();
|
let viewController = mockView();
|
||||||
subscription = viewController.willUnload.subscribe((event) => {
|
subscription = viewController.willUnload.subscribe((event: any) => {
|
||||||
expect(event).toEqual(null);
|
expect(event).toEqual(null);
|
||||||
done();
|
done();
|
||||||
}, (err: any) => {
|
}, (err: any) => {
|
||||||
|
@ -162,7 +162,7 @@ export class Keyboard {
|
|||||||
|
|
||||||
function cssClass() {
|
function cssClass() {
|
||||||
self._dom.write(() => {
|
self._dom.write(() => {
|
||||||
platform.doc().body.classList[isKeyInputEnabled ? 'add' : 'remove']('focus-outline');
|
(<any>platform.doc().body.classList)[isKeyInputEnabled ? 'add' : 'remove']('focus-outline');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ export const PLATFORM_CONFIGS: { [key: string]: PlatformConfig } = {
|
|||||||
|
|
||||||
// cordova has its own exitApp method
|
// cordova has its own exitApp method
|
||||||
plt.exitApp = function() {
|
plt.exitApp = function() {
|
||||||
win['navigator']['app'].exitApp();
|
(<any>win)['navigator']['app'].exitApp();
|
||||||
};
|
};
|
||||||
|
|
||||||
// cordova has fully loaded and we've added listeners
|
// cordova has fully loaded and we've added listeners
|
||||||
|
@ -20,7 +20,7 @@ export function isSafari(plt: Platform): boolean {
|
|||||||
|
|
||||||
|
|
||||||
export function isWKWebView(plt: Platform): boolean {
|
export function isWKWebView(plt: Platform): boolean {
|
||||||
return isIos(plt) && !!plt.win()['webkit'];
|
return isIos(plt) && !!(<any>plt.win())['webkit'];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isIosUIWebView(plt: Platform): boolean {
|
export function isIosUIWebView(plt: Platform): boolean {
|
||||||
|
@ -1175,8 +1175,8 @@ export function setupPlatform(doc: HTMLDocument, platformConfigs: {[key: string]
|
|||||||
plt.init();
|
plt.init();
|
||||||
|
|
||||||
// add the platform obj to the window
|
// add the platform obj to the window
|
||||||
win['Ionic'] = win['Ionic'] || {};
|
(<any>win)['Ionic'] = (<any>win)['Ionic'] || {};
|
||||||
win['Ionic']['platform'] = plt;
|
(<any>win)['Ionic']['platform'] = plt;
|
||||||
|
|
||||||
return plt;
|
return plt;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ export class Activator implements ActivatorBase {
|
|||||||
let ele: HTMLElement;
|
let ele: HTMLElement;
|
||||||
for (var i = 0; i < this._active.length; i++) {
|
for (var i = 0; i < this._active.length; i++) {
|
||||||
ele = this._active[i];
|
ele = this._active[i];
|
||||||
ele.style[this.dom.plt.Css.transition] = animated ? '' : 'none';
|
(<any>ele.style)[this.dom.plt.Css.transition] = animated ? '' : 'none';
|
||||||
ele.classList.remove(this._css);
|
ele.classList.remove(this._css);
|
||||||
}
|
}
|
||||||
this._active.length = 0;
|
this._active.length = 0;
|
||||||
|
@ -120,7 +120,7 @@ describe('Activator', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function testValues() {
|
function testValues(): any {
|
||||||
let parent = document.createElement('div');
|
let parent = document.createElement('div');
|
||||||
let ele = document.createElement('a');
|
let ele = document.createElement('a');
|
||||||
parent.appendChild(ele);
|
parent.appendChild(ele);
|
||||||
|
@ -11,9 +11,9 @@ export function renderDateTime(template: string, value: DateTimeData, locale: Lo
|
|||||||
FORMAT_KEYS.forEach((format, index) => {
|
FORMAT_KEYS.forEach((format, index) => {
|
||||||
if (template.indexOf(format.f) > -1) {
|
if (template.indexOf(format.f) > -1) {
|
||||||
var token = '{' + index + '}';
|
var token = '{' + index + '}';
|
||||||
var text = renderTextFormat(format.f, value[format.k], value, locale);
|
var text = renderTextFormat(format.f, (<any>value)[format.k], value, locale);
|
||||||
|
|
||||||
if (!hasText && text && isPresent(value[format.k])) {
|
if (!hasText && text && isPresent((<any>value)[format.k])) {
|
||||||
hasText = true;
|
hasText = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ export function updateDate(existingData: DateTimeData, newData: any) {
|
|||||||
// merge new values from the picker's selection
|
// merge new values from the picker's selection
|
||||||
// to the existing DateTimeData values
|
// to the existing DateTimeData values
|
||||||
for (var k in newData) {
|
for (var k in newData) {
|
||||||
existingData[k] = newData[k].value;
|
(<any>existingData)[k] = newData[k].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -271,7 +271,7 @@ export function updateDate(existingData: DateTimeData, newData: any) {
|
|||||||
} else {
|
} else {
|
||||||
// blank data, clear everything out
|
// blank data, clear everything out
|
||||||
for (var k in existingData) {
|
for (var k in existingData) {
|
||||||
delete existingData[k];
|
delete (<any>existingData)[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,7 +318,7 @@ export function getValueFromFormat(date: DateTimeData, format: string) {
|
|||||||
if (format === FORMAT_hh || format === FORMAT_h) {
|
if (format === FORMAT_hh || format === FORMAT_h) {
|
||||||
return (date.hour > 12 ? date.hour - 12 : date.hour);
|
return (date.hour > 12 ? date.hour - 12 : date.hour);
|
||||||
}
|
}
|
||||||
return date[convertFormatToKey(format)];
|
return (<any>date)[convertFormatToKey(format)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ export function getCss(docEle: HTMLElement) {
|
|||||||
var keys = ['webkitTransform', '-webkit-transform', 'webkit-transform', 'transform'];
|
var keys = ['webkitTransform', '-webkit-transform', 'webkit-transform', 'transform'];
|
||||||
|
|
||||||
for (i = 0; i < keys.length; i++) {
|
for (i = 0; i < keys.length; i++) {
|
||||||
if (docEle.style[keys[i]] !== undefined) {
|
if ((<any>docEle.style)[keys[i]] !== undefined) {
|
||||||
css.transform = keys[i];
|
css.transform = keys[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ export function getCss(docEle: HTMLElement) {
|
|||||||
// transition
|
// transition
|
||||||
keys = ['webkitTransition', 'transition'];
|
keys = ['webkitTransition', 'transition'];
|
||||||
for (i = 0; i < keys.length; i++) {
|
for (i = 0; i < keys.length; i++) {
|
||||||
if (docEle.style[keys[i]] !== undefined) {
|
if ((<any>docEle.style)[keys[i]] !== undefined) {
|
||||||
css.transition = keys[i];
|
css.transition = keys[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import { ScrollView } from '../util/scroll-view';
|
|||||||
* @demo /docs/v2/demos/src/events/
|
* @demo /docs/v2/demos/src/events/
|
||||||
*/
|
*/
|
||||||
export class Events {
|
export class Events {
|
||||||
private _channels: Array<any> = [];
|
private _channels: any = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe to an event topic. Events that get posted to that topic will trigger the provided handler.
|
* Subscribe to an event topic. Events that get posted to that topic will trigger the provided handler.
|
||||||
|
@ -50,7 +50,7 @@ export class IonicErrorHandler extends ErrorHandler {
|
|||||||
handleError(err: any): void {
|
handleError(err: any): void {
|
||||||
super.handleError(err);
|
super.handleError(err);
|
||||||
try {
|
try {
|
||||||
const devServer = window['IonicDevServer'];
|
const devServer = (<any>window)['IonicDevServer'];
|
||||||
if (devServer) {
|
if (devServer) {
|
||||||
devServer.handleError(err);
|
devServer.handleError(err);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ export class MockPlatform extends Platform {
|
|||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
const keepers = [];
|
const keepers: any[] = [];
|
||||||
this.timeouts.forEach(t => {
|
this.timeouts.forEach(t => {
|
||||||
if (t.timeout < timeout) {
|
if (t.timeout < timeout) {
|
||||||
t.callback();
|
t.callback();
|
||||||
@ -160,7 +160,7 @@ export class MockDomController extends DomController {
|
|||||||
|
|
||||||
flush(done: any) {
|
flush(done: any) {
|
||||||
this.mockedPlatform.flushTimeouts(() => {
|
this.mockedPlatform.flushTimeouts(() => {
|
||||||
this.mockedPlatform.flushRafs(timeStamp => {
|
this.mockedPlatform.flushRafs((timeStamp: number) => {
|
||||||
done(timeStamp);
|
done(timeStamp);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -168,7 +168,7 @@ export class MockDomController extends DomController {
|
|||||||
|
|
||||||
flushUntil(timeout: number, done: any) {
|
flushUntil(timeout: number, done: any) {
|
||||||
this.mockedPlatform.flushTimeoutsUntil(timeout, () => {
|
this.mockedPlatform.flushTimeoutsUntil(timeout, () => {
|
||||||
this.mockedPlatform.flushRafs(timeStamp => {
|
this.mockedPlatform.flushRafs((timeStamp: number) => {
|
||||||
done(timeStamp);
|
done(timeStamp);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -125,8 +125,8 @@ describe('mock-providers', () => {
|
|||||||
it('should set rafs', (done) => {
|
it('should set rafs', (done) => {
|
||||||
let callOrder: number[] = [];
|
let callOrder: number[] = [];
|
||||||
let timestamps: number[] = [];
|
let timestamps: number[] = [];
|
||||||
let callback1 = (timeStamp) => { callOrder.push(1); timestamps.push(timeStamp); };
|
let callback1 = (timeStamp: number) => { callOrder.push(1); timestamps.push(timeStamp); };
|
||||||
let callback2 = (timeStamp) => { callOrder.push(2); timestamps.push(timeStamp); };
|
let callback2 = (timeStamp: number) => { callOrder.push(2); timestamps.push(timeStamp); };
|
||||||
|
|
||||||
plt.raf(callback1);
|
plt.raf(callback1);
|
||||||
plt.raf(callback2);
|
plt.raf(callback2);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"lib": ["dom", "es2015"],
|
"lib": ["dom", "es2015"],
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": true,
|
||||||
"removeComments": false,
|
"removeComments": false,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
|
Reference in New Issue
Block a user