From 8157a58e84e8b15b16a77a937edb0fa02398211c Mon Sep 17 00:00:00 2001 From: hanson Date: Mon, 4 Mar 2013 19:11:47 +0800 Subject: [PATCH] fix bug of this.wrapper.clientWidth in function refreshSize is 0 if I new a swipeview but the HTML DOM hasnot rendered. --- src/swipeview.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/swipeview.js b/src/swipeview.js index 56b0a00..23411ab 100644 --- a/src/swipeview.js +++ b/src/swipeview.js @@ -162,8 +162,8 @@ var SwipeView = (function (window, document) { }, refreshSize: function () { - this.wrapperWidth = this.wrapper.clientWidth; - this.wrapperHeight = this.wrapper.clientHeight; + this.wrapperWidth = this.wrapper.clientWidth!=0 ? this.wrapper.clientWidth : this.wrapper.ownerDocument.body.clientWidth; + this.wrapperHeight = this.wrapper.clientHeight!=0 ? this.wrapper.clientHeight : this.wrapper.ownerDocument.body.clientHeight; this.pageWidth = this.wrapperWidth; this.maxX = -this.options.numberOfPages * this.pageWidth + this.wrapperWidth; this.snapThreshold = this.options.snapThreshold === null ? @@ -468,4 +468,4 @@ var SwipeView = (function (window, document) { } return SwipeView; -})(window, document); \ No newline at end of file +})(window, document);