mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
feat(slider): new swiper component
This commit is contained in:
@ -14,6 +14,7 @@ export * from 'ionic/components/item/item-group'
|
||||
export * from 'ionic/components/form/input'
|
||||
export * from 'ionic/components/text-input/text-input'
|
||||
export * from 'ionic/components/form/label'
|
||||
export * from 'ionic/components/image/image'
|
||||
export * from 'ionic/components/list/list'
|
||||
export * from 'ionic/components/show-hide-when/show-hide-when'
|
||||
|
||||
|
@ -5,6 +5,7 @@ import {IonicConfig} from '../../config/config';
|
||||
import {IonicComponent} from '../../config/annotations';
|
||||
import {Gesture} from '../../gestures/gesture';
|
||||
import {CSS} from '../../util/dom';
|
||||
import {Animation} from '../../animations/animation';
|
||||
|
||||
/**
|
||||
* ion-scroll is a non-flexboxed scroll area that can
|
||||
@ -53,9 +54,23 @@ export class Scroll extends Ion {
|
||||
this.zoomGesture = new Gesture(this.scrollElement);
|
||||
this.zoomGesture.listen();
|
||||
|
||||
this.zoomGesture.on('doubletap', (e) => {
|
||||
this.zoomElement.style[CSS.transform] = 'scale(3)';
|
||||
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);
|
||||
});
|
||||
|
||||
/*
|
||||
this.zoomGesture.on('doubletap', (e) => {
|
||||
this.zoomAnimation.to('scale', '3');
|
||||
this.zoomAnimation.play();
|
||||
//this.zoomElement.style[CSS.transform] = 'scale(3)';
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,53 +1,513 @@
|
||||
|
||||
// Slides
|
||||
// --------------------------------------------------
|
||||
|
||||
$z-index-slider-pager: 1 !default;
|
||||
|
||||
|
||||
.slides {
|
||||
ion-swipe-slides {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/**
|
||||
* Swiper 3.1.2
|
||||
* Most modern mobile touch slider and framework with hardware accelerated transitions
|
||||
*
|
||||
* http://www.idangero.us/swiper/
|
||||
*
|
||||
* Copyright 2015, Vladimir Kharlampidi
|
||||
* The iDangero.us
|
||||
* http://www.idangero.us/
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
* Released on: August 22, 2015
|
||||
*/
|
||||
.swiper-container {
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
/* Fix of Webkit flickering */
|
||||
z-index: 1;
|
||||
}
|
||||
.swiper-container-no-flexbox .swiper-slide {
|
||||
float: left;
|
||||
}
|
||||
.swiper-container-vertical > .swiper-wrapper {
|
||||
-webkit-box-orient: vertical;
|
||||
-moz-box-orient: vertical;
|
||||
-ms-flex-direction: column;
|
||||
-webkit-flex-direction: column;
|
||||
flex-direction: column;
|
||||
}
|
||||
.swiper-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1;
|
||||
display: -webkit-box;
|
||||
display: -moz-box;
|
||||
display: -ms-flexbox;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
-webkit-transition-property: -webkit-transform;
|
||||
-moz-transition-property: -moz-transform;
|
||||
-o-transition-property: -o-transform;
|
||||
-ms-transition-property: -ms-transform;
|
||||
transition-property: transform;
|
||||
-webkit-box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.swiper-container-android .swiper-slide,
|
||||
.swiper-wrapper {
|
||||
-webkit-transform: translate3d(0px, 0, 0);
|
||||
-moz-transform: translate3d(0px, 0, 0);
|
||||
-o-transform: translate(0px, 0px);
|
||||
-ms-transform: translate3d(0px, 0, 0);
|
||||
transform: translate3d(0px, 0, 0);
|
||||
}
|
||||
.swiper-container-multirow > .swiper-wrapper {
|
||||
-webkit-box-lines: multiple;
|
||||
-moz-box-lines: multiple;
|
||||
-ms-flex-wrap: wrap;
|
||||
-webkit-flex-wrap: wrap;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.swiper-container-free-mode > .swiper-wrapper {
|
||||
-webkit-transition-timing-function: ease-out;
|
||||
-moz-transition-timing-function: ease-out;
|
||||
-ms-transition-timing-function: ease-out;
|
||||
-o-transition-timing-function: ease-out;
|
||||
transition-timing-function: ease-out;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.swiper-slide {
|
||||
-webkit-flex-shrink: 0;
|
||||
-ms-flex: 0 0 auto;
|
||||
flex-shrink: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
/* a11y */
|
||||
.swiper-container .swiper-notification {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
z-index: -1000;
|
||||
}
|
||||
/* IE10 Windows Phone 8 Fixes */
|
||||
.swiper-wp8-horizontal {
|
||||
-ms-touch-action: pan-y;
|
||||
touch-action: pan-y;
|
||||
}
|
||||
.swiper-wp8-vertical {
|
||||
-ms-touch-action: pan-x;
|
||||
touch-action: pan-x;
|
||||
}
|
||||
/* Arrows */
|
||||
.swiper-button-prev,
|
||||
.swiper-button-next {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 27px;
|
||||
height: 44px;
|
||||
margin-top: -22px;
|
||||
z-index: 10;
|
||||
cursor: pointer;
|
||||
-moz-background-size: 27px 44px;
|
||||
-webkit-background-size: 27px 44px;
|
||||
background-size: 27px 44px;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.swiper-button-prev.swiper-button-disabled,
|
||||
.swiper-button-next.swiper-button-disabled {
|
||||
opacity: 0.35;
|
||||
cursor: auto;
|
||||
pointer-events: none;
|
||||
}
|
||||
.swiper-button-prev,
|
||||
.swiper-container-rtl .swiper-button-next {
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23007aff'%2F%3E%3C%2Fsvg%3E");
|
||||
left: 10px;
|
||||
right: auto;
|
||||
}
|
||||
.swiper-button-prev.swiper-button-black,
|
||||
.swiper-container-rtl .swiper-button-next.swiper-button-black {
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23000000'%2F%3E%3C%2Fsvg%3E");
|
||||
}
|
||||
.swiper-button-prev.swiper-button-white,
|
||||
.swiper-container-rtl .swiper-button-next.swiper-button-white {
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23ffffff'%2F%3E%3C%2Fsvg%3E");
|
||||
}
|
||||
.swiper-button-next,
|
||||
.swiper-container-rtl .swiper-button-prev {
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23007aff'%2F%3E%3C%2Fsvg%3E");
|
||||
right: 10px;
|
||||
left: auto;
|
||||
}
|
||||
.swiper-button-next.swiper-button-black,
|
||||
.swiper-container-rtl .swiper-button-prev.swiper-button-black {
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23000000'%2F%3E%3C%2Fsvg%3E");
|
||||
}
|
||||
.swiper-button-next.swiper-button-white,
|
||||
.swiper-container-rtl .swiper-button-prev.swiper-button-white {
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23ffffff'%2F%3E%3C%2Fsvg%3E");
|
||||
}
|
||||
/* Pagination Styles */
|
||||
.swiper-pagination {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
-webkit-transition: 300ms;
|
||||
-moz-transition: 300ms;
|
||||
-o-transition: 300ms;
|
||||
transition: 300ms;
|
||||
-webkit-transform: translate3d(0, 0, 0);
|
||||
-ms-transform: translate3d(0, 0, 0);
|
||||
-o-transform: translate3d(0, 0, 0);
|
||||
transform: translate3d(0, 0, 0);
|
||||
z-index: 10;
|
||||
}
|
||||
.swiper-pagination.swiper-pagination-hidden {
|
||||
opacity: 0;
|
||||
}
|
||||
.swiper-pagination-bullet {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
display: inline-block;
|
||||
border-radius: 100%;
|
||||
background: #000;
|
||||
opacity: 0.2;
|
||||
}
|
||||
button.swiper-pagination-bullet {
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-shadow: none;
|
||||
-moz-appearance: none;
|
||||
-ms-appearance: none;
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
.swiper-pagination-clickable .swiper-pagination-bullet {
|
||||
cursor: pointer;
|
||||
}
|
||||
.swiper-pagination-white .swiper-pagination-bullet {
|
||||
background: #fff;
|
||||
}
|
||||
.swiper-pagination-bullet-active {
|
||||
opacity: 1;
|
||||
background: #007aff;
|
||||
}
|
||||
.swiper-pagination-white .swiper-pagination-bullet-active {
|
||||
background: #fff;
|
||||
}
|
||||
.swiper-pagination-black .swiper-pagination-bullet-active {
|
||||
background: #000;
|
||||
}
|
||||
.swiper-container-vertical > .swiper-pagination {
|
||||
right: 10px;
|
||||
top: 50%;
|
||||
-webkit-transform: translate3d(0px, -50%, 0);
|
||||
-moz-transform: translate3d(0px, -50%, 0);
|
||||
-o-transform: translate(0px, -50%);
|
||||
-ms-transform: translate3d(0px, -50%, 0);
|
||||
transform: translate3d(0px, -50%, 0);
|
||||
}
|
||||
.swiper-container-vertical > .swiper-pagination .swiper-pagination-bullet {
|
||||
margin: 5px 0;
|
||||
display: block;
|
||||
}
|
||||
.swiper-container-horizontal > .swiper-pagination {
|
||||
bottom: 10px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.swiper-container-horizontal > .swiper-pagination .swiper-pagination-bullet {
|
||||
margin: 0 5px;
|
||||
}
|
||||
/* 3D Container */
|
||||
.swiper-container-3d {
|
||||
-webkit-perspective: 1200px;
|
||||
-moz-perspective: 1200px;
|
||||
-o-perspective: 1200px;
|
||||
perspective: 1200px;
|
||||
}
|
||||
.swiper-container-3d .swiper-wrapper,
|
||||
.swiper-container-3d .swiper-slide,
|
||||
.swiper-container-3d .swiper-slide-shadow-left,
|
||||
.swiper-container-3d .swiper-slide-shadow-right,
|
||||
.swiper-container-3d .swiper-slide-shadow-top,
|
||||
.swiper-container-3d .swiper-slide-shadow-bottom,
|
||||
.swiper-container-3d .swiper-cube-shadow {
|
||||
-webkit-transform-style: preserve-3d;
|
||||
-moz-transform-style: preserve-3d;
|
||||
-ms-transform-style: preserve-3d;
|
||||
transform-style: preserve-3d;
|
||||
}
|
||||
.swiper-container-3d .swiper-slide-shadow-left,
|
||||
.swiper-container-3d .swiper-slide-shadow-right,
|
||||
.swiper-container-3d .swiper-slide-shadow-top,
|
||||
.swiper-container-3d .swiper-slide-shadow-bottom {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
z-index: 10;
|
||||
}
|
||||
.swiper-container-3d .swiper-slide-shadow-left {
|
||||
background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0)));
|
||||
/* Safari 4+, Chrome */
|
||||
background-image: -webkit-linear-gradient(right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Chrome 10+, Safari 5.1+, iOS 5+ */
|
||||
background-image: -moz-linear-gradient(right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Firefox 3.6-15 */
|
||||
background-image: -o-linear-gradient(right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Opera 11.10-12.00 */
|
||||
background-image: linear-gradient(to left, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Firefox 16+, IE10, Opera 12.50+ */
|
||||
}
|
||||
.swiper-container-3d .swiper-slide-shadow-right {
|
||||
background-image: -webkit-gradient(linear, right top, left top, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0)));
|
||||
/* Safari 4+, Chrome */
|
||||
background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Chrome 10+, Safari 5.1+, iOS 5+ */
|
||||
background-image: -moz-linear-gradient(left, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Firefox 3.6-15 */
|
||||
background-image: -o-linear-gradient(left, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Opera 11.10-12.00 */
|
||||
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Firefox 16+, IE10, Opera 12.50+ */
|
||||
}
|
||||
.swiper-container-3d .swiper-slide-shadow-top {
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0)));
|
||||
/* Safari 4+, Chrome */
|
||||
background-image: -webkit-linear-gradient(bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Chrome 10+, Safari 5.1+, iOS 5+ */
|
||||
background-image: -moz-linear-gradient(bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Firefox 3.6-15 */
|
||||
background-image: -o-linear-gradient(bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Opera 11.10-12.00 */
|
||||
background-image: linear-gradient(to top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Firefox 16+, IE10, Opera 12.50+ */
|
||||
}
|
||||
.swiper-container-3d .swiper-slide-shadow-bottom {
|
||||
background-image: -webkit-gradient(linear, left bottom, left top, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0)));
|
||||
/* Safari 4+, Chrome */
|
||||
background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Chrome 10+, Safari 5.1+, iOS 5+ */
|
||||
background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Firefox 3.6-15 */
|
||||
background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Opera 11.10-12.00 */
|
||||
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
/* Firefox 16+, IE10, Opera 12.50+ */
|
||||
}
|
||||
/* Coverflow */
|
||||
.swiper-container-coverflow .swiper-wrapper {
|
||||
/* Windows 8 IE 10 fix */
|
||||
-ms-perspective: 1200px;
|
||||
}
|
||||
/* Fade */
|
||||
.swiper-container-fade.swiper-container-free-mode .swiper-slide {
|
||||
-webkit-transition-timing-function: ease-out;
|
||||
-moz-transition-timing-function: ease-out;
|
||||
-ms-transition-timing-function: ease-out;
|
||||
-o-transition-timing-function: ease-out;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
.swiper-container-fade .swiper-slide {
|
||||
pointer-events: none;
|
||||
}
|
||||
.swiper-container-fade .swiper-slide .swiper-slide {
|
||||
pointer-events: none;
|
||||
}
|
||||
.swiper-container-fade .swiper-slide-active,
|
||||
.swiper-container-fade .swiper-slide-active .swiper-slide-active {
|
||||
pointer-events: auto;
|
||||
}
|
||||
/* Cube */
|
||||
.swiper-container-cube {
|
||||
overflow: visible;
|
||||
}
|
||||
.swiper-container-cube .swiper-slide {
|
||||
pointer-events: none;
|
||||
visibility: hidden;
|
||||
-webkit-transform-origin: 0 0;
|
||||
-moz-transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
-webkit-backface-visibility: hidden;
|
||||
-moz-backface-visibility: hidden;
|
||||
-ms-backface-visibility: hidden;
|
||||
backface-visibility: hidden;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1;
|
||||
}
|
||||
.swiper-container-cube.swiper-container-rtl .swiper-slide {
|
||||
-webkit-transform-origin: 100% 0;
|
||||
-moz-transform-origin: 100% 0;
|
||||
-ms-transform-origin: 100% 0;
|
||||
transform-origin: 100% 0;
|
||||
}
|
||||
.swiper-container-cube .swiper-slide-active,
|
||||
.swiper-container-cube .swiper-slide-next,
|
||||
.swiper-container-cube .swiper-slide-prev,
|
||||
.swiper-container-cube .swiper-slide-next + .swiper-slide {
|
||||
pointer-events: auto;
|
||||
visibility: visible;
|
||||
}
|
||||
.swiper-container-cube .swiper-slide-shadow-top,
|
||||
.swiper-container-cube .swiper-slide-shadow-bottom,
|
||||
.swiper-container-cube .swiper-slide-shadow-left,
|
||||
.swiper-container-cube .swiper-slide-shadow-right {
|
||||
z-index: 0;
|
||||
-webkit-backface-visibility: hidden;
|
||||
-moz-backface-visibility: hidden;
|
||||
-ms-backface-visibility: hidden;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
.swiper-container-cube .swiper-cube-shadow {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #000;
|
||||
opacity: 0.6;
|
||||
-webkit-filter: blur(50px);
|
||||
filter: blur(50px);
|
||||
z-index: 0;
|
||||
}
|
||||
/* Scrollbar */
|
||||
.swiper-scrollbar {
|
||||
border-radius: 10px;
|
||||
position: relative;
|
||||
-ms-touch-action: none;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.swiper-container-horizontal > .swiper-scrollbar {
|
||||
position: absolute;
|
||||
left: 1%;
|
||||
bottom: 3px;
|
||||
z-index: 50;
|
||||
height: 5px;
|
||||
width: 98%;
|
||||
}
|
||||
.swiper-container-vertical > .swiper-scrollbar {
|
||||
position: absolute;
|
||||
right: 3px;
|
||||
top: 1%;
|
||||
z-index: 50;
|
||||
width: 5px;
|
||||
height: 98%;
|
||||
}
|
||||
.swiper-scrollbar-drag {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
border-radius: 10px;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.swiper-scrollbar-cursor-drag {
|
||||
cursor: move;
|
||||
}
|
||||
/* Preloader */
|
||||
.swiper-lazy-preloader {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
margin-left: -21px;
|
||||
margin-top: -21px;
|
||||
z-index: 10;
|
||||
-webkit-transform-origin: 50%;
|
||||
-moz-transform-origin: 50%;
|
||||
transform-origin: 50%;
|
||||
-webkit-animation: swiper-preloader-spin 1s steps(12, end) infinite;
|
||||
-moz-animation: swiper-preloader-spin 1s steps(12, end) infinite;
|
||||
animation: swiper-preloader-spin 1s steps(12, end) infinite;
|
||||
}
|
||||
.swiper-lazy-preloader:after {
|
||||
display: block;
|
||||
content: "";
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20viewBox%3D'0%200%20120%20120'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20xmlns%3Axlink%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink'%3E%3Cdefs%3E%3Cline%20id%3D'l'%20x1%3D'60'%20x2%3D'60'%20y1%3D'7'%20y2%3D'27'%20stroke%3D'%236c6c6c'%20stroke-width%3D'11'%20stroke-linecap%3D'round'%2F%3E%3C%2Fdefs%3E%3Cg%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(30%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(60%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(90%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(120%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(150%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.37'%20transform%3D'rotate(180%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.46'%20transform%3D'rotate(210%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.56'%20transform%3D'rotate(240%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.66'%20transform%3D'rotate(270%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.75'%20transform%3D'rotate(300%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.85'%20transform%3D'rotate(330%2060%2C60)'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
|
||||
background-position: 50%;
|
||||
-webkit-background-size: 100%;
|
||||
background-size: 100%;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.swiper-lazy-preloader-white:after {
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20viewBox%3D'0%200%20120%20120'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20xmlns%3Axlink%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink'%3E%3Cdefs%3E%3Cline%20id%3D'l'%20x1%3D'60'%20x2%3D'60'%20y1%3D'7'%20y2%3D'27'%20stroke%3D'%23fff'%20stroke-width%3D'11'%20stroke-linecap%3D'round'%2F%3E%3C%2Fdefs%3E%3Cg%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(30%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(60%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(90%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(120%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(150%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.37'%20transform%3D'rotate(180%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.46'%20transform%3D'rotate(210%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.56'%20transform%3D'rotate(240%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.66'%20transform%3D'rotate(270%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.75'%20transform%3D'rotate(300%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.85'%20transform%3D'rotate(330%2060%2C60)'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
|
||||
}
|
||||
@-webkit-keyframes swiper-preloader-spin {
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@keyframes swiper-preloader-spin {
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
ion-slides {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.swiper-container {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.slides-view {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.slide {
|
||||
position: relative;
|
||||
display: block;
|
||||
float: left;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.pager {
|
||||
display: block;
|
||||
.swiper-wrapper {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
z-index: $z-index-slider-pager;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 15px;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.swiper-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.swiper-slide {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
box-sizing: border-box;
|
||||
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
//background: #fff;
|
||||
/* Center slide text vertically */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.slide-pager-page {
|
||||
display: inline-block;
|
||||
margin: 0px 3px;
|
||||
width: 15px;
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
|
||||
opacity: 0.3;
|
||||
|
||||
&.active {
|
||||
transition: (opacity 0.4s ease-in);
|
||||
opacity: 1;
|
||||
}
|
||||
img {
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,30 @@
|
||||
import {Component, View, ElementRef, EventEmitter, onInit, Host, forwardRef, NgFor, NgIf} from 'angular2/angular2';
|
||||
import {Component, View, ElementRef, EventEmitter, onInit,
|
||||
Host, forwardRef, NgFor, NgIf, NgClass} from 'angular2/angular2';
|
||||
|
||||
import {Ion} from '../ion';
|
||||
import {DragGesture} from 'ionic/gestures/drag-gesture';
|
||||
import {IonicComponent, IonicDirective} from '../../config/annotations';
|
||||
import {IonicConfig} from '../../config/config';
|
||||
import {dom} from 'ionic/util';
|
||||
import {Platform} from 'ionic/platform/platform';
|
||||
import * as util from 'ionic/util';
|
||||
|
||||
import {Swiper} from './swiper-widget';
|
||||
|
||||
/**
|
||||
* Slides is a slide box implementation based off of swipe.js
|
||||
* and the ionic1 implementation.
|
||||
* Slides is a slide box implementation based on Swiper.js
|
||||
*
|
||||
* May 21st, 2015
|
||||
* @maxlynch
|
||||
* Swiper.js:
|
||||
* The most modern mobile touch slider and framework with hardware accelerated transitions
|
||||
*
|
||||
* http://www.idangero.us/swiper/
|
||||
*
|
||||
* Copyright 2015, Vladimir Kharlampidi
|
||||
* The iDangero.us
|
||||
* http://www.idangero.us/
|
||||
*
|
||||
* Licensed under MIT
|
||||
*
|
||||
* * TODO: Finish the slideshow, should continue on transition end or a
|
||||
* similar event.
|
||||
* * TODO: Add support for 2 slide cloning
|
||||
* * TODO: Test support for N-slide sliding (like go 2 slides ahead)
|
||||
* * TODO: Analyze performance, add request animation frame if necessary
|
||||
* * TODO: Test mouse support
|
||||
* * TODO: Port over mouse handling
|
||||
*/
|
||||
@IonicComponent({
|
||||
selector: 'ion-slides',
|
||||
@ -28,517 +32,55 @@ import * as util from 'ionic/util';
|
||||
'loop',
|
||||
'index',
|
||||
'bounce',
|
||||
'showPager'
|
||||
'hidePager',
|
||||
'options'
|
||||
]
|
||||
})
|
||||
@View({
|
||||
template: '<div class="slides-view"><ng-content></ng-content></div><ion-pager *ng-if="showPager"></ion-pager>',
|
||||
directives: [NgIf, forwardRef(() => SlidePager)]
|
||||
template: `<div class="swiper-container">
|
||||
<div class="swiper-wrapper">
|
||||
<ng-content></ng-content>
|
||||
</div>
|
||||
<div [class.hide]="hidePager" class="swiper-pagination"></div>
|
||||
</div>`,
|
||||
directives: [NgIf, NgClass]
|
||||
})
|
||||
export class Slides {
|
||||
export class Slides extends Ion {
|
||||
/**
|
||||
* TODO
|
||||
* @param {ElementRef} elementRef TODO
|
||||
*/
|
||||
constructor(elementRef: ElementRef) {
|
||||
// Grab the main container, and the slides-view wrapper
|
||||
this.ele = elementRef.nativeElement;
|
||||
|
||||
this.slides = [];
|
||||
this.currentIndex = 0;
|
||||
|
||||
// How quickly to animate between slides
|
||||
this.animateSpeed = 300;
|
||||
|
||||
// How often to switch slides automatically. Zero is no auto sliding
|
||||
this.slideDelay = 0;//3000;
|
||||
|
||||
// Whether to bounce on the edges if not continuous (overscrolling)
|
||||
this.bounce = false;
|
||||
|
||||
this.showPager = true;
|
||||
|
||||
this.changed = new EventEmitter('changed');
|
||||
|
||||
// Initialize our slides gesture handler
|
||||
this.gesture = new SlidesGesture(this);
|
||||
this.gesture.listen();
|
||||
constructor(elementRef: ElementRef, config: IonicConfig) {
|
||||
super(elementRef, config);
|
||||
}
|
||||
|
||||
onInit() {
|
||||
this.continuous = util.isDefined(this.loop) && (this.slides.length > 1 ? true : false);
|
||||
//this.getNativeElement().classList.add('swiper-container');
|
||||
|
||||
// Grab the wrapper element that contains the slides
|
||||
this.wrapperElement = this.ele.children[0];
|
||||
var options = util.defaults({
|
||||
pagination: '.swiper-pagination',
|
||||
paginationClickable: true,
|
||||
lazyLoading: true
|
||||
}, this.options);
|
||||
|
||||
this.resize();
|
||||
var swiper = new Swiper(this.getNativeElement().children[0], options);
|
||||
|
||||
if(this.slideDelay) {
|
||||
this.startShow();
|
||||
console.log('Build swiper', swiper, options);
|
||||
|
||||
this.swiper = swiper;
|
||||
}
|
||||
|
||||
//special case if two slides
|
||||
/*
|
||||
if (this.continuous && this.slides.length < 3) {
|
||||
this.element.appendChild(this.slides[0].clone())//cloneNode(true));
|
||||
element.appendChild(element.children[1].cloneNode(true));
|
||||
slides = element.children;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the slideshow.
|
||||
*/
|
||||
startShow() {
|
||||
this._showTimeout = setTimeout(this.next.bind(this), this.slideDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* End the slideshow.
|
||||
*/
|
||||
stopShow() {
|
||||
clearTimeout(this._showTimout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pager element for handling rendering of page icons and
|
||||
* switching slides through clicks, etc.
|
||||
*/
|
||||
setPager(pager) {
|
||||
this._pager = pager;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
resize() {
|
||||
// Get the width of the container, which is the viewport
|
||||
// that the user will actually see.
|
||||
this.containerWidth = this.ele.offsetWidth || this.ele.getBoundingClientRect().width;
|
||||
|
||||
// Fallback: don't allow zero width
|
||||
if(this.containerWidth === 0) {
|
||||
this.containerWidth = Platform.width();
|
||||
}
|
||||
|
||||
// Set the wrapper element to the total width of the child elements
|
||||
this.wrapperElement.style.width = ((this.containerWidth * this.slides.length)) + 'px';
|
||||
|
||||
// Position all the child slides
|
||||
this._bump();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new slide to the slides.
|
||||
* @param {Slide} slide The slide to add.
|
||||
*/
|
||||
add(slide) {
|
||||
console.log('Added slide');
|
||||
this._append(slide);
|
||||
|
||||
this.resize();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param {TODO} to TODO
|
||||
* @param {TODO} slideSpeed TODO
|
||||
*/
|
||||
slide(to, slideSpeed) {
|
||||
let index = this.currentIndex;
|
||||
let width = this.containerWidth;
|
||||
|
||||
// do nothing if already on requested slide
|
||||
if (index == to) return;
|
||||
|
||||
var direction = Math.abs(index-to) / (index-to); // 1: backward, -1: forward
|
||||
|
||||
// get the actual position of the slide
|
||||
if (this.continuous) {
|
||||
var natural_direction = direction;
|
||||
direction = -this.slides[this._circle(to)].x / width;
|
||||
|
||||
// if going forward but to < index, use to = slides.length + to
|
||||
// if going backward but to > index, use to = -slides.length + to
|
||||
if (direction !== natural_direction) to = -direction * this.slides.length + to;
|
||||
|
||||
}
|
||||
|
||||
var diff = Math.abs(index-to) - 1;
|
||||
|
||||
// move all the slides between index and to in the right direction
|
||||
while (diff--) this._move( this._circle((to > index ? to : index) - diff - 1), width * direction, 0);
|
||||
|
||||
to = this._circle(to);
|
||||
|
||||
this._move(index, width * direction, slideSpeed || this.animateSpeed);
|
||||
this._move(to, 0, slideSpeed || this.animateSpeed);
|
||||
|
||||
if (this.continuous) this._move(this._circle(to - direction), -(width * direction), 0); // we need to get the next in place
|
||||
|
||||
this.currentIndex = to;
|
||||
|
||||
this._changed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Slide left, possibly wrapping around in continuous mode.
|
||||
*/
|
||||
prev() {
|
||||
if(this.continuous) {
|
||||
|
||||
// Always allow us to go back
|
||||
this.slide(this.currentIndex - 1);
|
||||
|
||||
} else if(this.currentIndex > 0) {
|
||||
|
||||
// If we have one slide to the left
|
||||
this.slide(this.currentIndex - 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Slide right, possibly wrapping around in continuous mode.
|
||||
*/
|
||||
next() {
|
||||
if(this.continuous) {
|
||||
|
||||
// Always allow us to go next
|
||||
this.slide(this.currentIndex + 1);
|
||||
|
||||
} else if(this.currentIndex < this.slides.length - 1) {
|
||||
|
||||
// If not in continuous mode, only slide if we have a right slide
|
||||
this.slide(this.currentIndex + 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* TODO
|
||||
*/
|
||||
_changed() {
|
||||
this._pager && this._pager.changed(this.currentIndex);
|
||||
|
||||
update() {
|
||||
setTimeout(() => {
|
||||
this.changed.next(this.currentIndex);
|
||||
this.swiper.update();
|
||||
if(this.swiper.slides.length > 10) {
|
||||
this.hidePager = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Reposition all the existing slides so they are in the right position
|
||||
*/
|
||||
_bump() {
|
||||
let slide;
|
||||
let tx;
|
||||
|
||||
let i = this.slides.length;
|
||||
|
||||
while(i--) {
|
||||
slide = this.slides[i];
|
||||
|
||||
// Set the slide's left position to a negative of the current index and its width
|
||||
slide.left = i * -this.containerWidth;
|
||||
slide.width = this.containerWidth;
|
||||
|
||||
// Check if this slide is before or after the currently active one,
|
||||
// since we have to position it before or after it
|
||||
tx = 0;
|
||||
if(this.currentIndex > i) {
|
||||
tx = -this.containerWidth;
|
||||
} else if(this.currentIndex < i) {
|
||||
tx = this.containerWidth;
|
||||
getSliderWidget() {
|
||||
return this.swiper;
|
||||
}
|
||||
|
||||
this._move(i, tx);
|
||||
}
|
||||
|
||||
if(this.continuous) {
|
||||
// If we are in continuous mode, we need to wrap the previous and
|
||||
// last element to get a complete "circle"
|
||||
let index1 = this._circle(this.currentIndex - 1);
|
||||
let index2 = this._circle(this.currentIndex + 1);
|
||||
|
||||
this._move(index1, -this.containerWidth);//, 0);
|
||||
this._move(index2, this.containerWidth);//, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* TODO
|
||||
* @param {Event} event TODO
|
||||
*/
|
||||
_dragStart(event) {
|
||||
|
||||
this._isScrolling = undefined;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Code to run before operating on a drag.
|
||||
* @param {Event} event TODO
|
||||
*/
|
||||
_dragPre(event) {
|
||||
let dx = event.deltaX;
|
||||
let dy = event.deltaY;
|
||||
|
||||
if(this.disableScroll) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// determine if scrolling test has run - one time test
|
||||
if(typeof this._isScrolling == 'undefined') {
|
||||
this._isScrolling = !!(this._isScrolling || Math.abs(dx) < Math.abs(dy));
|
||||
}
|
||||
|
||||
// If we're scrolling, never run the drag
|
||||
if(this._isScrolling) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Process a drag, with a deltaX value.
|
||||
* @param {Event} event TODO
|
||||
*/
|
||||
_drag(event) {
|
||||
let dx = event.deltaX;
|
||||
let width = this.containerWidth;
|
||||
let index = this.currentIndex;
|
||||
|
||||
// Check if we should run (scroll detection, etc)
|
||||
let shouldRun = this._dragPre(event);
|
||||
if(shouldRun === false) { return; }
|
||||
|
||||
// We're doing this
|
||||
event.preventDefault();
|
||||
|
||||
let index1, index2, index3;
|
||||
|
||||
if(this.continuous) {
|
||||
|
||||
// Grab the left/center/right slides
|
||||
index1 = this._circle(this.currentIndex - 1);
|
||||
index2 = this.currentIndex;
|
||||
index3 = this._circle(this.currentIndex + 1);
|
||||
|
||||
} else {
|
||||
|
||||
index1 = this.currentIndex - 1;
|
||||
index2 = this.currentIndex;
|
||||
index3 = this.currentIndex + 1;
|
||||
|
||||
var isPastBounds =
|
||||
index == 0 && dx > 0 // if first slide and slide amt is greater than 0
|
||||
|| index == this.slides.length - 1 && dx < 0; // or if last slide and slide amt is less than 0
|
||||
|
||||
if(this.bounce) {
|
||||
// If we have drag bouncing/overscroll enabled,
|
||||
// let's slow down the drag on the edges
|
||||
|
||||
// if first slide and sliding left
|
||||
// or if last slide and sliding right
|
||||
// and if sliding at all,
|
||||
// Adjust resistance
|
||||
dx = dx /
|
||||
((!index && dx > 0 || index == this.slides.length - 1 && dx < 0) ?
|
||||
( Math.abs(dx) / width + 1 ) // determine resistance level
|
||||
: 1 );
|
||||
|
||||
} else if(isPastBounds) {
|
||||
// We aren't overscrolling (bouncing), and we're past the bounds
|
||||
let slide = this.slides[index];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let s1 = this.slides[index1];
|
||||
let s2 = this.slides[index2];
|
||||
let s3 = this.slides[index3];
|
||||
|
||||
// Translate the left/center/right slides based on the deltaX of the drag
|
||||
if(s1) {
|
||||
s1.translate(dx + s1.x);
|
||||
}
|
||||
if(s2) {
|
||||
s2.translate(dx + s2.x);
|
||||
}
|
||||
if(s3) {
|
||||
s3.translate(dx + s3.x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* TODO
|
||||
* @param {Event} event TODO
|
||||
* @param {TODO} drag TODO
|
||||
*/
|
||||
_endDrag(event, drag) {
|
||||
this._finish(event, drag);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* TODO
|
||||
* @param {Event} event TODO
|
||||
* @param {TODO} drag TODO
|
||||
*/
|
||||
_finish(event, drag) {
|
||||
|
||||
let delta = {
|
||||
x: event.deltaX,
|
||||
y: event.deltaY
|
||||
}
|
||||
|
||||
let width = this.containerWidth;
|
||||
let index = this.currentIndex;
|
||||
let slides = this.slides;
|
||||
let move = this._move.bind(this);
|
||||
let circle = this._circle.bind(this);
|
||||
let isScrolling = this._isScrolling;
|
||||
let speed = this.animateSpeed;
|
||||
|
||||
// measure duration
|
||||
var duration = +new Date - drag.time;
|
||||
|
||||
// determine if slide attempt triggers next/prev slide
|
||||
var isValidSlide =
|
||||
Number(duration) < 250 // if slide duration is less than 250ms
|
||||
&& Math.abs(delta.x) > 20 // and if slide amt is greater than 20px
|
||||
|| Math.abs(delta.x) > width/3; // or if slide amt is greater than half the width
|
||||
|
||||
// determine if slide attempt is past start and end
|
||||
var isPastBounds =
|
||||
!index && delta.x > 0 // if first slide and slide amt is greater than 0
|
||||
|| index == slides.length - 1 && delta.x < 0; // or if last slide and slide amt is less than 0
|
||||
|
||||
if (this.continuous) isPastBounds = false;
|
||||
|
||||
// determine direction of swipe (true:right, false:left)
|
||||
var direction = delta.x < 0;
|
||||
|
||||
// if not scrolling vertically
|
||||
if (!isScrolling) {
|
||||
|
||||
if (isValidSlide && !isPastBounds) {
|
||||
|
||||
if (direction) {
|
||||
|
||||
if (this.continuous) { // we need to get the next in this direction in place
|
||||
|
||||
move(circle(index-1), -width, 0);
|
||||
move(circle(index+2), width, 0);
|
||||
|
||||
} else {
|
||||
move(index-1, -width, 0);
|
||||
}
|
||||
|
||||
move(index, slides[index].x-width, speed);
|
||||
move(circle(index+1), slides[circle(index+1)].x-width, speed);
|
||||
this.currentIndex = circle(index+1);
|
||||
|
||||
this._changed();
|
||||
|
||||
} else {
|
||||
if (this.continuous) { // we need to get the next in this direction in place
|
||||
|
||||
move(circle(index+1), width, 0);
|
||||
move(circle(index-2), -width, 0);
|
||||
|
||||
} else {
|
||||
move(index+1, width, 0);
|
||||
}
|
||||
|
||||
move(index, slides[index].x+width, speed);
|
||||
move(circle(index-1), slides[circle(index-1)].x+width, speed);
|
||||
this.currentIndex = circle(index-1);
|
||||
|
||||
this._changed();
|
||||
|
||||
}
|
||||
|
||||
//options.callback && options.callback(index, slides[index]);
|
||||
|
||||
} else {
|
||||
|
||||
if (this.continuous) {
|
||||
|
||||
move(circle(index-1), -width, speed);
|
||||
move(index, 0, speed);
|
||||
move(circle(index+1), width, speed);
|
||||
|
||||
this._changed();
|
||||
|
||||
} else {
|
||||
|
||||
move(index-1, -width, speed);
|
||||
move(index, 0, speed);
|
||||
move(index+1, width, speed);
|
||||
|
||||
this._changed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// kill touchmove and touchend event listeners until touchstart called again
|
||||
//element.removeEventListener('touchmove', events, false)
|
||||
//element.removeEventListener('touchend', events, false)
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* TODO
|
||||
* @param {TODO} pos TODO
|
||||
* @param {TODO} translateX TODO
|
||||
* @param {TODO} speed TODO
|
||||
*/
|
||||
_move(pos, translateX, speed) {
|
||||
// Should already be wrapped with circle
|
||||
let slide = this.slides[pos];
|
||||
if(!slide) { return; }
|
||||
|
||||
slide.translate(translateX, speed);
|
||||
slide.x = translateX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* A modulo "circle" to stay in the bounds of the slide array
|
||||
* @param {TODO} i TODO
|
||||
* @returns {TODO} TODO
|
||||
*/
|
||||
_circle(i) {
|
||||
return (this.slides.length + (i % this.slides.length)) % this.slides.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Add specified slide to the end of the list of slides.
|
||||
* @param {Slide} slide TODO
|
||||
*/
|
||||
_append(slide) {
|
||||
this.slides.push(slide);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Add specified slide to the beginning of the list of slides.
|
||||
* @param {Slide} slide TODO
|
||||
*/
|
||||
_prepend(slide) {
|
||||
this.slides.unshift(slide);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -554,123 +96,20 @@ export class Slide {
|
||||
* @param {ElementRef} elementRef TODO
|
||||
*/
|
||||
constructor(
|
||||
@Host() slides: Slides,
|
||||
//@Host() slides: Slides,
|
||||
elementRef: ElementRef
|
||||
) {
|
||||
this.ele = elementRef.nativeElement;
|
||||
|
||||
slides.add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param {TODO} x TODO
|
||||
* @param {TODO} duration TODO
|
||||
*/
|
||||
translate(x, duration) {
|
||||
this._translateX = x;
|
||||
|
||||
duration = duration || 0;
|
||||
|
||||
this.ele.style[dom.CSS.transition + 'Duration'] = duration + 'ms';
|
||||
this.ele.style[dom.CSS.transform] = 'translate3d(' + x + 'px, 0, 0)';
|
||||
}
|
||||
|
||||
get translateX() {
|
||||
return this._translateX;
|
||||
}
|
||||
|
||||
set left(x) {
|
||||
this._left = x;
|
||||
this.ele.style.left = x + 'px';
|
||||
}
|
||||
get left() {
|
||||
return this._left;
|
||||
}
|
||||
|
||||
set width(width) {
|
||||
this._width = width;
|
||||
this.ele.style.width = width + 'px';
|
||||
}
|
||||
|
||||
get width() {
|
||||
return this._width;
|
||||
this.ele.classList.add('swiper-slide');
|
||||
//slides.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
@IonicComponent({
|
||||
selector: 'ion-pager',
|
||||
@IonicDirective({
|
||||
selector: 'slide-lazy',
|
||||
})
|
||||
@View({
|
||||
//[class.active]="$index == currentSlide}" ng-click="pagerClick($index)"><i class="icon ion-record"></i></span></div>',
|
||||
template: `<span class="slide-pager-page" *ng-for="#page of getSlides(); #i = index" [class.active]="i == slides.currentIndex"><i class="icon ion-record"></i></span>`,
|
||||
directives: [NgFor]
|
||||
})
|
||||
export class SlidePager {
|
||||
/**
|
||||
* TODO
|
||||
* @param {Slides} slides The containing slidebox.
|
||||
* @param {ElementRef} elementRef TODO
|
||||
*/
|
||||
constructor(
|
||||
@Host() slides: Slides,
|
||||
elementRef: ElementRef
|
||||
) {
|
||||
this.ele = elementRef.nativeElement;
|
||||
|
||||
this.slides = slides;
|
||||
|
||||
this.slides.setPager(this);
|
||||
}
|
||||
|
||||
changed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of slides in the slidebox.
|
||||
* @returns {Array<Slide>} An array of slides in the slidebox.
|
||||
*/
|
||||
getSlides() {
|
||||
return this.slides.slides.slice(0, 10);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
export class SlidesGesture extends DragGesture {
|
||||
/**
|
||||
* TODO
|
||||
* @param {Slides} slides TODO
|
||||
*/
|
||||
constructor(slides) {
|
||||
super(slides.ele);
|
||||
this.slides = slides;
|
||||
}
|
||||
onDrag(event) {
|
||||
let x = event.center.x;
|
||||
let y = event.center.y;
|
||||
|
||||
this._drag.x = x;
|
||||
this._drag.y = y;
|
||||
|
||||
this.slides._drag(event);
|
||||
}
|
||||
onDragStart(event) {
|
||||
|
||||
this._drag = {
|
||||
startX: event.center.x,
|
||||
startY: event.center.y,
|
||||
time: +new Date
|
||||
}
|
||||
|
||||
this.slides._dragStart(event, this._drag);
|
||||
}
|
||||
onDragEnd(event) {
|
||||
this.slides._endDrag(event, this._drag);
|
||||
export class SlideLazy {
|
||||
constructor(elementRef: ElementRef) {
|
||||
elementRef.getNativeElement().classList.add('swiper-lazy');
|
||||
}
|
||||
}
|
||||
|
3968
ionic/components/slides/swiper-widget.ts
Normal file
3968
ionic/components/slides/swiper-widget.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,45 @@
|
||||
import {App} from 'ionic/ionic';
|
||||
import {App, IonicApp, Http} from 'ionic/ionic';
|
||||
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class IonicApp {
|
||||
next() {
|
||||
console.log('Next');
|
||||
class MyApp {
|
||||
constructor(private app: IonicApp) {
|
||||
this.extraOptions = {
|
||||
loop: true
|
||||
};
|
||||
|
||||
this.images = [];
|
||||
|
||||
let tags = "amsterdam";
|
||||
let FLICKR_API_KEY = '504fd7414f6275eb5b657ddbfba80a2c';
|
||||
|
||||
let baseUrl = 'https://api.flickr.com/services/rest/';
|
||||
|
||||
Http.get(baseUrl + '?method=flickr.groups.pools.getPhotos&group_id=1463451@N25&safe_search=1&api_key=' + FLICKR_API_KEY + '&jsoncallback=JSON_CALLBACK&format=json&tags=' + tags, {
|
||||
method: 'jsonp'
|
||||
}).then((val) => {
|
||||
this.images = val.photos.photo;
|
||||
this.slider.update();
|
||||
}, (err) => {
|
||||
alert('Unable to load images');
|
||||
console.error(err);
|
||||
})
|
||||
}
|
||||
prev() {
|
||||
console.log('Prev');
|
||||
|
||||
onInit() {
|
||||
setTimeout(() => {
|
||||
this.slider = this.app.getComponent('slider');
|
||||
console.log('Got slider', this.slider);
|
||||
});
|
||||
}
|
||||
|
||||
getImageUrl(item) {
|
||||
return "http://farm"+ item.farm +".static.flickr.com/"+ item.server +"/"+ item.id +"_"+ item.secret + "_z.jpg";
|
||||
}
|
||||
|
||||
doRefresh() {
|
||||
console.log('DOREFRESH')
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,5 @@
|
||||
<ion-slides #slides>
|
||||
<ion-slide style="background-color: blue">
|
||||
<h2>Page 1</h2>
|
||||
</ion-slide>
|
||||
<ion-slide style="background-color: yellow">
|
||||
<h2>Page 2</h2>
|
||||
<ion-slides [options]="extraOptions" id="slider" style="background-color: black">
|
||||
<ion-slide *ng-for="#image of images">
|
||||
<img data-src="{{getImageUrl(image)}}" slide-lazy>
|
||||
</ion-slide>
|
||||
</ion-slides>
|
||||
|
||||
<!--
|
||||
<div style="position: absolute; bottom: 10px; left: 0; width: 100%; text-align: center">
|
||||
<button (click)="slides.prev()">Prev</button>
|
||||
<button (click)="slides.next()">Next</button>
|
||||
</div>
|
||||
-->
|
||||
|
@ -1,33 +0,0 @@
|
||||
import {App} from 'ionic/ionic';
|
||||
|
||||
|
||||
@App({
|
||||
template: `
|
||||
<ion-slides #slides loop>
|
||||
<ion-slide style="background-color: blue">
|
||||
<h2>Page 1</h2>
|
||||
</ion-slide>
|
||||
<ion-slide style="background-color: yellow">
|
||||
<h2>Page 2</h2>
|
||||
</ion-slide>
|
||||
<ion-slide style="background-color: pink">
|
||||
<h2>Page 3</h2>
|
||||
</ion-slide>
|
||||
<ion-pager>
|
||||
</ion-pager>
|
||||
</ion-slides>
|
||||
|
||||
<div style="position: absolute; bottom: 10px; left: 0; width: 100%; text-align: center">
|
||||
<button (click)="slides.prev()">Prev</button>
|
||||
<button (click)="slides.next()">Next</button>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
class IonicApp {
|
||||
next() {
|
||||
console.log('Next');
|
||||
}
|
||||
prev() {
|
||||
console.log('Prev');
|
||||
}
|
||||
}
|
37
ionic/components/swiper/test/basic/index.ts
Normal file
37
ionic/components/swiper/test/basic/index.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import {App, Http} from 'ionic/ionic';
|
||||
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class MyApp {
|
||||
constructor() {
|
||||
this.extraOptions = {
|
||||
loop: true
|
||||
};
|
||||
|
||||
this.images = [];
|
||||
|
||||
let tags = "amsterdam";
|
||||
let FLICKR_API_KEY = '504fd7414f6275eb5b657ddbfba80a2c';
|
||||
let baseUrl = 'https://api.flickr.com/services/rest/';
|
||||
|
||||
Http.get(baseUrl + '?method=flickr.groups.pools.getPhotos&group_id=1463451@N25&safe_search=1&api_key=' + FLICKR_API_KEY + '&jsoncallback=JSON_CALLBACK&format=json&tags=' + tags, {
|
||||
method: 'jsonp'
|
||||
}).then((val) => {
|
||||
console.log('Loaded', val);
|
||||
this.images = val.photos.photo;
|
||||
}, (err) => {
|
||||
alert('Unable to load images');
|
||||
console.error(err);
|
||||
})
|
||||
}
|
||||
|
||||
getImageUrl(item) {
|
||||
return "http://farm"+ item.farm +".static.flickr.com/"+ item.server +"/"+ item.id +"_"+ item.secret + "_z.jpg";
|
||||
}
|
||||
|
||||
doRefresh() {
|
||||
console.log('DOREFRESH')
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ import {IonicConfig} from './config';
|
||||
import {ionicBootstrap} from '../components/app/app';
|
||||
import {
|
||||
Aside, AsideToggle, Button, Content, Scroll, Refresher,
|
||||
Slides, Slide, SlidePager,
|
||||
Slides, Slide, SlideLazy,
|
||||
Tabs, Tab,
|
||||
Card, List, ListHeader, Item, ItemGroup, ItemGroupTitle,
|
||||
Toolbar,
|
||||
@ -52,7 +52,7 @@ export const IonicDirectives = [
|
||||
// Slides
|
||||
forwardRef(() => Slides),
|
||||
forwardRef(() => Slide),
|
||||
forwardRef(() => SlidePager),
|
||||
forwardRef(() => SlideLazy),
|
||||
|
||||
// Tabs
|
||||
forwardRef(() => Tabs),
|
||||
|
@ -30,6 +30,10 @@ export class Gesture {
|
||||
}
|
||||
|
||||
on(type, cb) {
|
||||
if(type == 'pinch' || type == 'rotate') {
|
||||
console.log('Enabling pinch');
|
||||
this.hammertime.get('pinch').set({enable: true});
|
||||
}
|
||||
this.hammertime.on(type, cb);
|
||||
(this._callbacks[type] || (this._callbacks[type] = [])).push(cb);
|
||||
//this.element.addEventListener(type, cb);
|
||||
|
@ -10,8 +10,9 @@
|
||||
"angular2": "2.0.0-alpha.35",
|
||||
"reflect-metadata": "0.1.0",
|
||||
"rtts_assert": "2.0.0-alpha.35",
|
||||
"traceur": "0.0.91",
|
||||
"swiper": "^3.1.2",
|
||||
"systemjs": "0.16.11",
|
||||
"traceur": "0.0.91",
|
||||
"zone.js": "0.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
Reference in New Issue
Block a user