fix(slides): non-zero initial width

This commit is contained in:
Max Lynch
2015-08-21 13:06:12 -05:00
parent de719feec6
commit ef1d6a66f7

View File

@ -3,6 +3,7 @@ import {Component, View, ElementRef, EventEmitter, onInit, Host, forwardRef, NgF
import {DragGesture} from 'ionic/gestures/drag-gesture';
import {IonicComponent, IonicDirective} from '../../config/annotations';
import {dom} from 'ionic/util';
import {Platform} from 'ionic/platform/platform';
import * as util from 'ionic/util';
@ -109,6 +110,11 @@ export class Slides {
// 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';
@ -535,7 +541,6 @@ export class SlidePager {
}
changed() {
console.log('Active changed!', this.slides.currentIndex);
}
getSlides() {