Skip to content

Commit 54e6821

Browse files
Merge pull request #33 from TheOriginalJosh/orientation-bug-fixes
Orientation bug fixes
2 parents 90343d6 + f89e2ee commit 54e6821

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

nativescript-slides.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import * as gestures from 'ui/gestures';
1010
import {AnimationCurve, Orientation} from 'ui/enums';
1111
import {Color} from 'color';
1212
import {Image} from 'ui/image';
13-
import * as imageSource from 'image-source';
13+
14+
// declare const android:any;
1415

1516
let LayoutParams: any;
1617
if (app.android) {
@@ -244,20 +245,25 @@ export class SlideContainer extends AbsoluteLayout {
244245

245246
//handles application orientation change
246247
app.on(app.orientationChangedEvent, (args: app.OrientationChangedEventData) => {
247-
this._pageWidth = Platform.screen.mainScreen.widthDIPs;
248-
this.eachLayoutChild((view: View) => {
249-
if (view instanceof StackLayout) {
250-
AbsoluteLayout.setLeft(view, this.pageWidth);
251-
view.width = this.pageWidth;
252-
}
253-
});
248+
//event and page orientation didn't seem to alwasy be on the same page so setting it in the time out addresses this.
249+
setTimeout(() => {
250+
this._pageWidth = Platform.screen.mainScreen.widthDIPs;
251+
this.eachLayoutChild((view: View) => {
252+
if (view instanceof StackLayout) {
253+
AbsoluteLayout.setLeft(view, this.pageWidth);
254+
view.width = this.pageWidth;
255+
}
256+
});
254257

255-
if (this.disablePan === false) {
256-
this.applySwipe(this.pageWidth);
257-
}
258-
let topOffset = Platform.screen.mainScreen.heightDIPs - 105;
259-
AbsoluteLayout.setTop(this._footer, topOffset);
260-
this.currentPanel.panel.translateX = -this.pageWidth;
258+
if (this.disablePan === false) {
259+
this.applySwipe(this.pageWidth);
260+
}
261+
let topOffset = Platform.screen.mainScreen.heightDIPs - 105;
262+
if (this.pageIndicators) {
263+
AbsoluteLayout.setTop(this._footer, topOffset);
264+
}
265+
this.currentPanel.panel.translateX = -this.pageWidth;
266+
}, 100);
261267
});
262268
}
263269
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-slides",
3-
"version": "1.5.2",
3+
"version": "1.5.3",
44
"description": "NativeScript Slides plugin.",
55
"main": "nativescript-slides.js",
66
"nativescript": {

0 commit comments

Comments
 (0)