mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 19:57:22 +08:00
Progress on scroll zoom
This commit is contained in:
@ -8,6 +8,14 @@ ion-scroll {
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&[center] {
|
||||||
|
scroll-content {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scroll-content {
|
scroll-content {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
@ -7,6 +7,8 @@ import {Gesture} from '../../gestures/gesture';
|
|||||||
import {CSS} from '../../util/dom';
|
import {CSS} from '../../util/dom';
|
||||||
import {Animation} from '../../animations/animation';
|
import {Animation} from '../../animations/animation';
|
||||||
|
|
||||||
|
import * as util from 'ionic/util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ion-scroll is a non-flexboxed scroll area that can
|
* ion-scroll is a non-flexboxed scroll area that can
|
||||||
* scroll horizontally or vertically.
|
* scroll horizontally or vertically.
|
||||||
@ -37,12 +39,15 @@ export class Scroll extends Ion {
|
|||||||
onInit() {
|
onInit() {
|
||||||
this.scrollElement = this.getNativeElement().children[0];
|
this.scrollElement = this.getNativeElement().children[0];
|
||||||
|
|
||||||
if(this.zoom === "") {
|
if(util.isTrueProperty(this.zoom)) {
|
||||||
|
console.log('Zoom?', this.zoom);
|
||||||
|
|
||||||
this.initZoomScrolling();
|
this.initZoomScrolling();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initZoomScrolling() {
|
initZoomScrolling() {
|
||||||
|
console.log('Init zoom');
|
||||||
this.zoomElement = this.scrollElement.children[0];
|
this.zoomElement = this.scrollElement.children[0];
|
||||||
|
|
||||||
this.zoomElement && this.zoomElement.classList.add('ion-scroll-zoom');
|
this.zoomElement && this.zoomElement.classList.add('ion-scroll-zoom');
|
||||||
@ -64,13 +69,11 @@ export class Scroll extends Ion {
|
|||||||
console.log('PINCH', e);
|
console.log('PINCH', e);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
this.zoomGesture.on('doubletap', (e) => {
|
this.zoomGesture.on('doubletap', (e) => {
|
||||||
this.zoomAnimation.to('scale', '3');
|
this.zoomAnimation.to('scale', '3');
|
||||||
this.zoomAnimation.play();
|
this.zoomAnimation.play();
|
||||||
//this.zoomElement.style[CSS.transform] = 'scale(3)';
|
//this.zoomElement.style[CSS.transform] = 'scale(3)';
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,8 @@ import {Component, View, ElementRef, EventEmitter, onInit,
|
|||||||
Host, forwardRef, NgFor, NgIf, NgClass} from 'angular2/angular2';
|
Host, forwardRef, NgFor, NgIf, NgClass} from 'angular2/angular2';
|
||||||
|
|
||||||
import {Ion} from '../ion';
|
import {Ion} from '../ion';
|
||||||
|
import {Animation} from 'ionic/animations/animation';
|
||||||
|
import {Gesture} from 'ionic/gestures/gesture';
|
||||||
import {DragGesture} from 'ionic/gestures/drag-gesture';
|
import {DragGesture} from 'ionic/gestures/drag-gesture';
|
||||||
import {IonicComponent, IonicDirective} from '../../config/annotations';
|
import {IonicComponent, IonicDirective} from '../../config/annotations';
|
||||||
import {IonicConfig} from '../../config/config';
|
import {IonicConfig} from '../../config/config';
|
||||||
@ -94,6 +96,7 @@ export class Slides extends Ion {
|
|||||||
*/
|
*/
|
||||||
@IonicDirective({
|
@IonicDirective({
|
||||||
selector: 'ion-slide',
|
selector: 'ion-slide',
|
||||||
|
properties: ['zoom']
|
||||||
})
|
})
|
||||||
export class Slide {
|
export class Slide {
|
||||||
/**
|
/**
|
||||||
@ -107,6 +110,49 @@ export class Slide {
|
|||||||
this.ele = elementRef.nativeElement;
|
this.ele = elementRef.nativeElement;
|
||||||
this.ele.classList.add('swiper-slide');
|
this.ele.classList.add('swiper-slide');
|
||||||
}
|
}
|
||||||
|
onInit() {
|
||||||
|
if(this.zoom !== "false") {
|
||||||
|
//this.initZoom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
initZoom() {
|
||||||
|
var g = new Gesture(this.ele);
|
||||||
|
|
||||||
|
let zoomAnimation = new Animation(this.ele);
|
||||||
|
zoomAnimation.from('scale', '1');
|
||||||
|
|
||||||
|
g.on('doubletap', (e) => {
|
||||||
|
zoomAnimation.to('scale', '3');
|
||||||
|
zoomAnimation.play();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
initZoomScrolling() {
|
||||||
|
this.zoomElement = this.ele.children[0];
|
||||||
|
|
||||||
|
this.zoomElement && this.zoomElement.classList.add('ion-scroll-zoom');
|
||||||
|
|
||||||
|
this.scrollElement.addEventListener('scroll', (e) => {
|
||||||
|
console.log("Scrolling", e);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.zoomGesture = new Gesture(this.scrollElement);
|
||||||
|
this.zoomGesture.listen();
|
||||||
|
|
||||||
|
this.zoomAnimation = new Animation(this.zoomElement);
|
||||||
|
this.zoomAnimation
|
||||||
|
.duration(200)
|
||||||
|
.easing('ease-in')
|
||||||
|
.from('scale', '1');
|
||||||
|
|
||||||
|
this.zoomGesture.on('pinch', (e) => {
|
||||||
|
console.log('PINCH', e);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@IonicDirective({
|
@IonicDirective({
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<ion-slides [options]="extraOptions" id="slider" style="background-color: black">
|
<ion-slides [options]="extraOptions" id="slider" style="background-color: black">
|
||||||
<ion-slide *ng-for="#image of images">
|
<ion-slide *ng-for="#image of images">
|
||||||
<img data-src="{{getImageUrl(image)}}" slide-lazy>
|
<ion-scroll scroll-x="true" scroll-y="true" zoom center>
|
||||||
|
<img data-src="{{getImageUrl(image)}}" slide-lazy>
|
||||||
|
</ion-scroll>
|
||||||
</ion-slide>
|
</ion-slide>
|
||||||
</ion-slides>
|
</ion-slides>
|
||||||
|
<style>
|
||||||
|
|
||||||
|
ion-scroll {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
@ -102,6 +102,7 @@ export const isUndefined = val => typeof val === 'undefined';
|
|||||||
export const isBlank = val => val === undefined || val === null;
|
export const isBlank = val => val === undefined || val === null;
|
||||||
export const isObject = val => typeof val === 'object';
|
export const isObject = val => typeof val === 'object';
|
||||||
export const isArray = Array.isArray;
|
export const isArray = Array.isArray;
|
||||||
|
export const isTrueProperty = val => typeof val !== 'undefined' && val !== "false";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a string in the format thisIsAString to a slug format this-is-a-string
|
* Convert a string in the format thisIsAString to a slug format this-is-a-string
|
||||||
|
Reference in New Issue
Block a user