mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +08:00
chore(noImplicitAny): add noImplicitAny to tsconfig
This commit is contained in:
@ -53,7 +53,7 @@ export function addRole(ele: HTMLElement, role: string) {
|
||||
ele.setAttribute('role', role);
|
||||
}
|
||||
|
||||
export function addLabel(ele: HTMLElement, label) {
|
||||
export function addLabel(ele: HTMLElement, label: string) {
|
||||
ele.setAttribute('aria-label', label);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import { updatePaginationClasses } from './swiper-pagination';
|
||||
Classes
|
||||
===========================*/
|
||||
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]);
|
||||
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) {
|
||||
var slideToIndex = s.clickedIndex;
|
||||
var realIndex;
|
||||
var realIndex: number;
|
||||
var slidesPerView = s.slidesPerView === 'auto' ? currentSlidesPerView(s) : <number>s.slidesPerView;
|
||||
|
||||
if (s.loop) {
|
||||
@ -263,23 +263,27 @@ function updateClickedSlide(s: Slides, plt: Platform, e: SlideUIEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
var isTouched,
|
||||
isMoved,
|
||||
allowTouchCallbacks,
|
||||
touchStartTime,
|
||||
isScrolling,
|
||||
currentTranslate,
|
||||
startTranslate,
|
||||
allowThresholdMove,
|
||||
// Last click time
|
||||
lastClickTime = Date.now(), clickTimeout,
|
||||
// Velocities
|
||||
velocities = [],
|
||||
allowMomentumBounce;
|
||||
var isTouched: boolean;
|
||||
var isMoved: boolean;
|
||||
var allowTouchCallbacks: boolean;
|
||||
var touchStartTime: number;
|
||||
var isScrolling: boolean;
|
||||
var currentTranslate: number;
|
||||
var startTranslate: any;
|
||||
var allowThresholdMove: any;
|
||||
|
||||
// Last click time
|
||||
var lastClickTime = Date.now();
|
||||
var clickTimeout: any;
|
||||
|
||||
// Velocities
|
||||
var velocities: any[] = [];
|
||||
var allowMomentumBounce: boolean;
|
||||
|
||||
|
||||
// Touch handlers
|
||||
var isTouchEvent, startMoving;
|
||||
var isTouchEvent: boolean;
|
||||
var startMoving: boolean;
|
||||
|
||||
function onTouchStart(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
||||
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;
|
||||
|
||||
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) {
|
||||
isScrolling = false;
|
||||
} else {
|
||||
@ -516,12 +520,12 @@ function onTouchMove(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
||||
// Velocity
|
||||
if (velocities.length === 0) {
|
||||
velocities.push({
|
||||
position: s._touches[isHorizontal(s) ? 'startX' : 'startY'],
|
||||
position: (<any>s._touches)[isHorizontal(s) ? 'startX' : 'startY'],
|
||||
time: touchStartTime
|
||||
});
|
||||
}
|
||||
velocities.push({
|
||||
position: s._touches[isHorizontal(s) ? 'currentX' : 'currentY'],
|
||||
position: (<any>s._touches)[isHorizontal(s) ? 'currentX' : 'currentY'],
|
||||
time: (new Date()).getTime()
|
||||
});
|
||||
}
|
||||
@ -592,7 +596,7 @@ function onTouchEnd(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
||||
}
|
||||
isTouched = isMoved = false;
|
||||
|
||||
var currentPos;
|
||||
var currentPos: number;
|
||||
if (s.followFinger) {
|
||||
currentPos = s._rtl ? s._translate : -s._translate;
|
||||
} else {
|
||||
@ -642,7 +646,7 @@ function onTouchEnd(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
||||
var newPosition = s._translate + momentumDistance;
|
||||
if (s._rtl) newPosition = - newPosition;
|
||||
var doBounce = false;
|
||||
var afterBouncePosition;
|
||||
var afterBouncePosition: number;
|
||||
var bounceAmount = Math.abs(s.velocity) * 20 * s.freeModeMomentumBounceRatio;
|
||||
|
||||
if (newPosition < maxTranslate(s)) {
|
||||
@ -670,8 +674,8 @@ function onTouchEnd(s: Slides, plt: Platform, ev: SlideUIEvent) {
|
||||
}
|
||||
|
||||
} else if (s.freeModeSticky) {
|
||||
var j = 0,
|
||||
nextSlide;
|
||||
var j = 0;
|
||||
var nextSlide: number;
|
||||
for (j = 0; j < s._snapGrid.length; j += 1) {
|
||||
if (s._snapGrid[j] > -newPosition) {
|
||||
nextSlide = j;
|
||||
|
@ -4,7 +4,10 @@ import { updateClasses } from './swiper-classes';
|
||||
|
||||
export function updateActiveIndex(s: Slides) {
|
||||
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 ++) {
|
||||
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) {
|
||||
|
@ -44,7 +44,7 @@ function handleKeyboard(s: Slides, plt: Platform, e: KeyboardEvent) {
|
||||
var swiperOffset = offset(s.container, plt);
|
||||
|
||||
if (s._rtl) {
|
||||
swiperOffset.left = swiperOffset.left - s.container[0].scrollLeft;
|
||||
swiperOffset.left = swiperOffset.left - s.container.scrollLeft;
|
||||
}
|
||||
|
||||
var swiperCoord = [
|
||||
|
@ -5,8 +5,10 @@ import { eachChild, isHorizontal, transform, transition } from './swiper-utils';
|
||||
/*=========================
|
||||
Parallax
|
||||
===========================*/
|
||||
function setParallaxTransform(s: Slides, el: HTMLElement, progress) {
|
||||
var p, pX, pY;
|
||||
function setParallaxTransform(s: Slides, el: HTMLElement, progress: number) {
|
||||
var p: string;
|
||||
var pX: string;
|
||||
var pY: string;
|
||||
var rtlFactor = s._rtl ? -1 : 1;
|
||||
|
||||
p = el.getAttribute('data-swiper-parallax') || '0';
|
||||
@ -30,13 +32,13 @@ function setParallaxTransform(s: Slides, el: HTMLElement, progress) {
|
||||
if ((pX).indexOf('%') >= 0) {
|
||||
pX = parseInt(pX, 10) * progress * rtlFactor + '%';
|
||||
} else {
|
||||
pX = pX * progress * rtlFactor + 'px' ;
|
||||
pX = <any>pX * progress * rtlFactor + 'px' ;
|
||||
}
|
||||
|
||||
if ((pY).indexOf('%') >= 0) {
|
||||
pY = parseInt(pY, 10) * progress + '%';
|
||||
} else {
|
||||
pY = pY * progress + 'px' ;
|
||||
pY = <any>pY * progress + 'px' ;
|
||||
}
|
||||
|
||||
transform(el, 'translate3d(' + pX + ', ' + pY + ',0px)');
|
||||
@ -51,7 +53,7 @@ export function parallaxSetTranslate(s: Slides) {
|
||||
for (var i = 0; i < s._slides.length; i++) {
|
||||
var slide = s._slides[i];
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ export function setWrapperTranslate(s: Slides, plt: Platform, translate: any, sh
|
||||
s._translate = isHorizontal(s) ? x : y;
|
||||
|
||||
// Check if we need to update progress
|
||||
var progress;
|
||||
var progress: number;
|
||||
var translatesDiff = maxTranslate(s) - minTranslate(s);
|
||||
|
||||
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) {
|
||||
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
|
||||
if (typeof axis === 'undefined') {
|
||||
@ -71,7 +74,7 @@ export function getTranslate(s: Slides, plt: Platform, el: HTMLElement, axis: st
|
||||
if (win.WebKitCSSMatrix) {
|
||||
curTransform = curStyle.transform || curStyle.webkitTransform;
|
||||
if (curTransform.split(',').length > 6) {
|
||||
curTransform = curTransform.split(', ').map(function(a){
|
||||
curTransform = curTransform.split(', ').map(function(a: any){
|
||||
return a.replace(',', '.');
|
||||
}).join(', ');
|
||||
}
|
||||
@ -80,14 +83,14 @@ export function getTranslate(s: Slides, plt: Platform, el: HTMLElement, axis: st
|
||||
transformMatrix = new win.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
|
||||
|
||||
} 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(',');
|
||||
}
|
||||
|
||||
if (axis === 'x') {
|
||||
if (win.WebKitCSSMatrix) {
|
||||
// Latest Chrome and webkits Fix
|
||||
curTransform = transformMatrix.m41;
|
||||
curTransform = <any>transformMatrix.m41;
|
||||
} else if (matrix.length === 16) {
|
||||
// Crazy IE10 Matrix
|
||||
curTransform = parseFloat(matrix[12]);
|
||||
|
@ -2,7 +2,7 @@ import { Slides } from '../slides';
|
||||
import { Platform } from '../../../platform/platform';
|
||||
|
||||
|
||||
export function round(a) {
|
||||
export function round(a: any) {
|
||||
return Math.floor(a);
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ export function queryChildren(parentEle: HTMLElement, query: string): HTMLElemen
|
||||
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) {
|
||||
var nodes = parentEle.querySelectorAll(query);
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
|
@ -354,7 +354,24 @@ function toggleZoom(s: Slides, plt: Platform) {
|
||||
|
||||
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) {
|
||||
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
|
||||
===========================*/
|
||||
export function updateAutoHeight(s: Slides) {
|
||||
var activeSlides = [];
|
||||
var activeSlides: SlideElement[] = [];
|
||||
var newHeight = 0;
|
||||
var i;
|
||||
var i: number;
|
||||
|
||||
// Find slides currently in view
|
||||
if (s.slidesPerView !== 'auto' && s.slidesPerView > 1) {
|
||||
@ -378,7 +378,7 @@ export function updateSlidesSize(s: Slides, plt: Platform) {
|
||||
inlineStyle(s._slides, { marginRight: '', marginBottom: '' });
|
||||
}
|
||||
|
||||
var slidesNumberEvenToRows;
|
||||
var slidesNumberEvenToRows: number;
|
||||
if (s.slidesPerColumn > 1) {
|
||||
if (Math.floor(s._slides.length / s.slidesPerColumn) === s._slides.length / s.slidesPerColumn) {
|
||||
slidesNumberEvenToRows = s._slides.length;
|
||||
@ -401,8 +401,10 @@ export function updateSlidesSize(s: Slides, plt: Platform) {
|
||||
var slide = s._slides[i];
|
||||
if (s.slidesPerColumn > 1) {
|
||||
// Set slides order
|
||||
var newSlideOrderIndex;
|
||||
var column, row;
|
||||
var newSlideOrderIndex: number;
|
||||
var column: number;
|
||||
var row: number;
|
||||
|
||||
if (s.slidesPerColumnFill === 'column') {
|
||||
column = Math.floor(i / 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 cssObj = {};
|
||||
var cssObj: {[key: string]: string} = {};
|
||||
|
||||
if (isHorizontal(s)) {
|
||||
cssObj['marginTop'] = cssVal;
|
||||
@ -436,8 +438,8 @@ export function updateSlidesSize(s: Slides, plt: Platform) {
|
||||
}
|
||||
|
||||
inlineStyle(slide, cssObj);
|
||||
slide.setAttribute('data-swiper-column', column);
|
||||
slide.setAttribute('data-swiper-row', row);
|
||||
slide.setAttribute('data-swiper-column', <any>column);
|
||||
slide.setAttribute('data-swiper-row', <any>row);
|
||||
}
|
||||
|
||||
if (slide.style.display === 'none') {
|
||||
@ -487,7 +489,7 @@ export function updateSlidesSize(s: Slides, plt: Platform) {
|
||||
index ++;
|
||||
}
|
||||
s._virtualSize = Math.max(s._virtualSize, s._renderedSize) + s.slidesOffsetAfter;
|
||||
var newSlidesGrid;
|
||||
var newSlidesGrid: any[];
|
||||
|
||||
if (
|
||||
s._rtl && (s.effect === 'slide' || s.effect === 'coverflow')) {
|
||||
@ -554,10 +556,14 @@ export function updateSlidesSize(s: Slides, plt: Platform) {
|
||||
Dynamic Slides Per View
|
||||
===========================*/
|
||||
export function currentSlidesPerView(s: Slides) {
|
||||
var spv = 1, i, j;
|
||||
var spv = 1;
|
||||
var i: number;
|
||||
var j: number;
|
||||
|
||||
if (s.centeredSlides) {
|
||||
var size = s._slides[s._activeIndex].swiperSlideSize;
|
||||
var breakLoop;
|
||||
var breakLoop: boolean;
|
||||
|
||||
for (i = s._activeIndex + 1; i < s._slides.length; i++) {
|
||||
if (s._slides[i] && !breakLoop) {
|
||||
size += s._slides[i].swiperSlideSize;
|
||||
@ -565,6 +571,7 @@ export function currentSlidesPerView(s: Slides) {
|
||||
if (size > s._renderedSize) breakLoop = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = s._activeIndex - 1; j >= 0; j--) {
|
||||
if (s._slides[j] && !breakLoop) {
|
||||
size += s._slides[j].swiperSlideSize;
|
||||
@ -572,6 +579,7 @@ export function currentSlidesPerView(s: Slides) {
|
||||
if (size > s._renderedSize) breakLoop = true;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
for (i = s._activeIndex + 1; i < s._slides.length; i++) {
|
||||
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);
|
||||
}
|
||||
|
||||
var translated, newTranslate;
|
||||
var translated: boolean;
|
||||
var newTranslate: number;
|
||||
|
||||
function forceSetTranslate() {
|
||||
newTranslate = Math.min(Math.max(s._translate, maxTranslate(s)), minTranslate(s));
|
||||
setWrapperTranslate(s, plt, newTranslate);
|
||||
@ -654,8 +664,8 @@ function createLoop(s: Slides) {
|
||||
s.loopedSlides = slides.length;
|
||||
}
|
||||
|
||||
var prependSlides = [];
|
||||
var appendSlides = [];
|
||||
var prependSlides: SlideElement[] = [];
|
||||
var appendSlides: SlideElement[] = [];
|
||||
|
||||
for (var i = 0; i < slides.length; i++) {
|
||||
var slide = slides[i];
|
||||
@ -686,7 +696,8 @@ function destroyLoop(s: Slides) {
|
||||
}
|
||||
|
||||
export function fixLoop(s: Slides, plt: Platform) {
|
||||
var newIndex;
|
||||
var newIndex: number;
|
||||
|
||||
if (s._activeIndex < s.loopedSlides) {
|
||||
// Fix For Negative Oversliding
|
||||
newIndex = s._slides.length - s.loopedSlides * 3 + s._activeIndex;
|
||||
|
Reference in New Issue
Block a user