chore(slides): swiper updates

This commit is contained in:
Dan Bucholtz
2016-09-13 17:14:23 -05:00
committed by Adam Bradley
parent ed221eff1d
commit 7b443dea4c
4 changed files with 3983 additions and 31 deletions

View File

@ -1,10 +1,10 @@
import { ChangeDetectionStrategy, Component, Directive, ElementRef, EventEmitter, Input, Host, Output, Renderer, ViewEncapsulation } from '@angular/core'; import { ChangeDetectionStrategy, Component, Directive, ElementRef, EventEmitter, Input, Host, Output, Renderer, ViewEncapsulation } from '@angular/core';
import { Animation } from '../../animations/animation'; import { Animation } from '../../animations/animation';
import { Config } from '../../config/config';
import { Gesture } from '../../gestures/gesture'; import { Gesture } from '../../gestures/gesture';
import { CSS } from '../../util/dom'; import { CSS } from '../../util/dom';
import { debounce, defaults, isTrueProperty, isPresent } from '../../util/util'; import { debounce, defaults, isTrueProperty, isPresent } from '../../util/util';
import { dom } from '../../util';
import { Ion } from '../ion'; import { Ion } from '../ion';
import { Swiper } from './swiper-widget'; import { Swiper } from './swiper-widget';
@ -202,72 +202,72 @@ export class Slides extends Ion {
/** /**
* @private * @private
*/ */
private id: number; id: number;
/** /**
* @private * @private
*/ */
private slideId: string; slideId: string;
/** /**
* @private * @private
*/ */
private showPager: boolean; showPager: boolean;
/** /**
* @private * @private
*/ */
private slider: Swiper; slider: Swiper;
/** /**
* @private * @private
*/ */
private maxScale: number; maxScale: number;
/** /**
* @private * @private
*/ */
private zoomElement: HTMLElement; zoomElement: HTMLElement;
/** /**
* @private * @private
*/ */
private zoomGesture: Gesture; zoomGesture: Gesture;
/** /**
* @private * @private
*/ */
private scale: number; scale: number;
/** /**
* @private * @private
*/ */
private zoomLastPosX: number; zoomLastPosX: number;
/** /**
* @private * @private
*/ */
private zoomLastPosY: number; zoomLastPosY: number;
/** /**
* @private * @private
*/ */
private viewportWidth: number; viewportWidth: number;
/** /**
* @private * @private
*/ */
private viewportHeight: number; viewportHeight: number;
/** /**
* @private * @private
*/ */
private enableZoom: boolean; enableZoom: boolean;
/** /**
* @private * @private
*/ */
private touch: { touch: {
x: number, x: number,
y: number, y: number,
startX: number, startX: number,
@ -323,8 +323,8 @@ export class Slides extends Ion {
@Output() ionDrag: EventEmitter<any> = new EventEmitter(); @Output() ionDrag: EventEmitter<any> = new EventEmitter();
constructor(elementRef: ElementRef, renderer: Renderer) { constructor(config: Config, elementRef: ElementRef, renderer: Renderer) {
super(elementRef); super(config, elementRef, renderer);
this.rapidUpdate = debounce(() => { this.rapidUpdate = debounce(() => {
this.update(); this.update();
}, 10); }, 10);
@ -332,7 +332,7 @@ export class Slides extends Ion {
this.id = ++slidesId; this.id = ++slidesId;
this.slideId = 'slides-' + this.id; this.slideId = 'slides-' + this.id;
renderer.setElementClass(elementRef.nativeElement, this.slideId, true); this.setElementClass(this.slideId, true);
} }
/** /**
@ -466,7 +466,7 @@ export class Slides extends Ion {
this.zoomLastPosY = 0; this.zoomLastPosY = 0;
let lastScale: number, startX: number, startY: number, posX = 0, posY = 0, zoomRect: any; let lastScale: number, zoomRect: any;
this.viewportWidth = this.getNativeElement().offsetWidth; this.viewportWidth = this.getNativeElement().offsetWidth;
this.viewportHeight = this.getNativeElement().offsetHeight; this.viewportHeight = this.getNativeElement().offsetHeight;
@ -491,7 +491,7 @@ export class Slides extends Ion {
this.zoomGesture.on('pinch', (e: any) => { this.zoomGesture.on('pinch', (e: any) => {
this.scale = Math.max(1, Math.min(lastScale * e.scale, 10)); this.scale = Math.max(1, Math.min(lastScale * e.scale, 10));
console.debug('Scaling', this.scale); console.debug('Scaling', this.scale);
this.zoomElement.style[CSS.transform] = 'scale(' + this.scale + ')'; (<any>this.zoomElement.style)[CSS.transform] = 'scale(' + this.scale + ')';
zoomRect = this.zoomElement.getBoundingClientRect(); zoomRect = this.zoomElement.getBoundingClientRect();
}); });
@ -516,8 +516,8 @@ export class Slides extends Ion {
*/ */
resetZoom() { resetZoom() {
if (this.zoomElement) { if (this.zoomElement) {
this.zoomElement.parentElement.style[CSS.transform] = ''; (<any>this.zoomElement.parentElement.style)[CSS.transform] = '';
this.zoomElement.style[CSS.transform] = 'scale(1)'; (<any>this.zoomElement.style)[CSS.transform] = 'scale(1)';
} }
this.scale = 1; this.scale = 1;
@ -563,9 +563,9 @@ export class Slides extends Ion {
.duration(this.zoomDuration) .duration(this.zoomDuration)
.easing('linear'); .easing('linear');
let zw = new Animation(this.touch.target.children[0]) // let zw = new Animation(this.touch.target.children[0])
.duration(this.zoomDuration) // .duration(this.zoomDuration)
.easing('linear'); // .easing('linear');
let za = new Animation(); let za = new Animation();
za.add(zi); za.add(zi);
@ -620,7 +620,7 @@ export class Slides extends Ion {
// TODO: Support mice as well // TODO: Support mice as well
let target = ((dom.closest(e.target, '.slide').children[0] as HTMLElement).children[0] as HTMLElement); let target = ((e.target.closest('.slide').children[0] as HTMLElement).children[0] as HTMLElement);
this.touch = { this.touch = {
x: null, x: null,
@ -684,7 +684,7 @@ export class Slides extends Ion {
} else { } else {
console.debug('TRANSFORM', this.touch.x, this.touch.y, this.touch.target); console.debug('TRANSFORM', this.touch.x, this.touch.y, this.touch.target);
// this.touch.target.style[CSS.transform] = 'translateX(' + this.touch.x + 'px) translateY(' + this.touch.y + 'px)'; // this.touch.target.style[CSS.transform] = 'translateX(' + this.touch.x + 'px) translateY(' + this.touch.y + 'px)';
this.touch.target.style[CSS.transform] = 'translateX(' + this.touch.x + 'px) translateY(' + this.touch.y + 'px)'; (<any>this.touch.target.style)[CSS.transform] = 'translateX(' + this.touch.x + 'px) translateY(' + this.touch.y + 'px)';
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
return false; return false;
@ -852,7 +852,7 @@ export class Slide {
/** /**
* @private * @private
*/ */
private ele: HTMLElement; ele: HTMLElement;
/** /**
@ -862,7 +862,7 @@ export class Slide {
constructor( constructor(
elementRef: ElementRef, elementRef: ElementRef,
@Host() private slides: Slides @Host() public slides: Slides
) { ) {
this.ele = elementRef.nativeElement; this.ele = elementRef.nativeElement;
this.ele.classList.add('swiper-slide'); this.ele.classList.add('swiper-slide');

View File

@ -1,4 +1,3 @@
export declare class Swiper { export declare class Swiper {
constructor(container: HTMLElement, params: any); constructor(container: HTMLElement, params: any);
slides: Array<HTMLElement>; slides: Array<HTMLElement>;

File diff suppressed because it is too large Load Diff