mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 11:41:20 +08:00
fix(slides): non-zero initial width
This commit is contained in:
@ -3,6 +3,7 @@ import {Component, View, ElementRef, EventEmitter, onInit, Host, forwardRef, NgF
|
|||||||
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 {dom} from 'ionic/util';
|
import {dom} from 'ionic/util';
|
||||||
|
import {Platform} from 'ionic/platform/platform';
|
||||||
import * as util from 'ionic/util';
|
import * as util from 'ionic/util';
|
||||||
|
|
||||||
|
|
||||||
@ -109,6 +110,11 @@ export class Slides {
|
|||||||
// that the user will actually see.
|
// that the user will actually see.
|
||||||
this.containerWidth = this.ele.offsetWidth || this.ele.getBoundingClientRect().width;
|
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
|
// Set the wrapper element to the total width of the child elements
|
||||||
this.wrapperElement.style.width = ((this.containerWidth * this.slides.length)) + 'px';
|
this.wrapperElement.style.width = ((this.containerWidth * this.slides.length)) + 'px';
|
||||||
|
|
||||||
@ -535,7 +541,6 @@ export class SlidePager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
changed() {
|
changed() {
|
||||||
console.log('Active changed!', this.slides.currentIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getSlides() {
|
getSlides() {
|
||||||
|
Reference in New Issue
Block a user