Skip to content

Commit d26b345

Browse files
committed
add flip
1 parent af3b6bd commit d26b345

File tree

3 files changed

+45
-13
lines changed

3 files changed

+45
-13
lines changed

src/MobileNativeFeatures/MobileTransitions.xml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@
66
<icon>iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAd0lEQVR42q1TQQ7AIAjjEfz/Oe4Ah/mizSWYEFM3cDbpsRVKJZqDG9XIlMQjqI2X8cyaqBN3SsagmMCLCy2gG4R2VvAKMjhsIkaBScBAxmBRYFHKFgO2caIrKOoGT06FDMoY4pYzfhVJs0WSv1X2wS59Jh/sa2A3/2BcyNllo4UAAAAASUVORK5CYII=</icon>
77

88
<properties>
9-
<property key="direction" type="enumeration" required="true" defaultValue="up">
9+
<property key="transitionType" type="enumeration" required="true" defaultValue="slide">
10+
<caption>Type</caption>
11+
<category>Settings</category>
12+
<description>The type of transition.</description>
13+
<enumerationValues>
14+
<enumerationValue key="slide">Slide</enumerationValue>
15+
<enumerationValue key="flip">Flip</enumerationValue>
16+
<enumerationValue key="fade">Fade</enumerationValue>
17+
</enumerationValues>
18+
</property>
19+
<property key="direction" type="enumeration" required="true" defaultValue="left">
1020
<caption>Direction</caption>
1121
<category>Settings</category>
1222
<description>The direction to transition the next page</description>
1323
<enumerationValues>
14-
<enumerationValue key="up">Slide Up</enumerationValue>
15-
<enumerationValue key="down">Slide Down</enumerationValue>
16-
<enumerationValue key="left">Slide Left</enumerationValue>
17-
<enumerationValue key="right">Slide Right</enumerationValue>
18-
<enumerationValue key="fade">Fade</enumerationValue>
24+
<enumerationValue key="up">Up</enumerationValue>
25+
<enumerationValue key="down">Down</enumerationValue>
26+
<enumerationValue key="left">Left</enumerationValue>
27+
<enumerationValue key="right">Right</enumerationValue>
1928
</enumerationValues>
2029
</property>
2130
<property key="clsName" type="string" required="true">
@@ -37,6 +46,6 @@
3746
<caption>Fixed Pixels Bottom</caption>
3847
<category>Settings</category>
3948
<description>Any footer pixels that you don't want to slide.</description>
40-
</property>
49+
</property>
4150
</properties>
4251
</widget>

src/MobileNativeFeatures/widget/MobileTransitions.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ define([
3030
// Parameters configured in the Modeler.
3131
clsName: null,
3232
direction: null,
33+
transitionType: null,
3334
fixedPixelsTop: 0,
3435
fixedPixelsBottom: 0,
3536

@@ -89,19 +90,19 @@ define([
8990
if (typeof window.plugins !== "undefined") {
9091

9192
if (typeof window.plugins.nativepagetransitions !== "undefined") {
92-
if (this.direction === "fade") {
93+
if (this.transitionType === "fade") {
9394
this._listenerHandle = query("."+this.clsName).on("click", lang.hitch(this, function () {
94-
window.plugins.nativepagetransitions.nextTransition = this.direction;
95+
window.plugins.nativepagetransitions.nextTransition = this.transitionType;
9596
window.plugins.nativepagetransitions.nextOptions = {
9697
"duration" : this.duration, // in milliseconds (ms), default 400
9798
"iosdelay" : -1, // ms to wait for the iOS webview to update before animation kicks in, default 60
9899
"androiddelay" : -1
99100
};
100101
}));
101-
} else {
102+
} else if (this.transitionType === "slide") {
102103

103104
this._listenerHandle = query("."+this.clsName).on("click", lang.hitch(this, function () {
104-
window.plugins.nativepagetransitions.nextTransition = this.direction;
105+
window.plugins.nativepagetransitions.nextTransition = this.transitionType;
105106
window.plugins.nativepagetransitions.nextOptions = {
106107
"direction": this.direction, // "left|right|up|down", default "left" (which is like "next")
107108
"duration": this.duration, // in milliseconds (ms), default 400
@@ -113,6 +114,18 @@ define([
113114
"fixedPixelsBottom": this.fixedPixelsBottom // the number of pixels of your fixed footer (f.i. a tab bar), default 0 (iOS and Android)
114115
};
115116
}));
117+
} else if (this.transitionType === "flip") {
118+
119+
this._listenerHandle = query("."+this.clsName).on("click", lang.hitch(this, function () {
120+
window.plugins.nativepagetransitions.nextTransition = this.transitionType;
121+
window.plugins.nativepagetransitions.nextOptions = {
122+
"direction": this.direction, // "left|right|up|down", default "left" (which is like "next")
123+
"duration": this.duration, // in milliseconds (ms), default 400
124+
"iosdelay": -1, //defer transitions until they"re called later ////60, // ms to wait for the iOS webview to update before animation kicks in, default 60
125+
"androiddelay": -1, //defer transitions until they"re called later ////70 // same as above but for Android, default 70
126+
"winphonedelay": 200, // same as above but for Windows Phone, default 200,
127+
};
128+
}));
116129
}
117130
}
118131
} else {
@@ -140,7 +153,7 @@ define([
140153
alert("error: " + msg);
141154
} // called in case you pass in weird values
142155
);
143-
} else {
156+
} else if(window.plugins.nativepagetransitions.nextTransition === "slide"){
144157
window.plugins.nativepagetransitions.slide(
145158
window.plugins.nativepagetransitions.nextOptions,
146159
function (msg) {
@@ -150,11 +163,21 @@ define([
150163
alert("error: " + msg);
151164
} // called in case you pass in weird values
152165
);
166+
} else if (window.plugins.nativepagetransitions.nextTransition === "flip") {
167+
window.plugins.nativepagetransitions.flip(
168+
window.plugins.nativepagetransitions.nextOptions,
169+
function (msg) {
170+
//console.log("success: " + msg);
171+
}, // called when the animation has finished
172+
function (msg) {
173+
alert("error: " + msg);
174+
} // called in case you pass in weird values
175+
);
153176
}
154177
window.plugins.nativepagetransitions.nextTransition = null;
155178
window.plugins.nativepagetransitions.nextOptions = null;
156179
//set a limit on how long we're going to keep the transition waiting, in case something breaks
157-
setTimeout(this._cancelTransition, 5000);
180+
setTimeout(this._cancelTransition, 10000);
158181
}
159182

160183
return deferred;

test/widgets/MobileNativeFeatures.mpk

173 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)