Skip to content

Commit

Permalink
Added the possibility to globally define defaults for a number of pro…
Browse files Browse the repository at this point in the history
…perties
  • Loading branch information
EddyVerbruggen committed Oct 16, 2014
1 parent 55d6859 commit 6aa812a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin
xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="com.telerik.plugins.nativepagetransitions"
version="0.1.4">
version="0.1.5">

<name>Native Page Transitions</name>

Expand Down
27 changes: 17 additions & 10 deletions www/NativePageTransitions.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
function NativePageTransitions() {
}

NativePageTransitions.prototype.globalOptions = {
duration: 400,
iosdelay: 60,
androiddelay: 70,
slowdownfactor: 4
};

NativePageTransitions.prototype.slide = function (options, onSuccess, onError) {
var opts = options || {};
if (!this._validateHref(opts.href, onError)) {
return;
}
opts.direction = opts.direction || "left";
if (opts.duration == undefined || opts.duration == "null") {
opts.duration = 400;
opts.duration = this.globalOptions.duration;
}
if (opts.androiddelay == undefined || opts.androiddelay == "null") {
opts.androiddelay = 50;
opts.androiddelay = this.globalOptions.androiddelay;
}
if (opts.iosdelay == undefined || opts.iosdelay == "null") {
opts.iosdelay = 50;
opts.iosdelay = this.globalOptions.iosdelay;
}
// setting slowdownfactor > 1 makes the next page slide less pixels. Use 1 for side-by-side.
opts.slowdownfactor = opts.slowdownfactor || 3;
opts.slowdownfactor = opts.slowdownfactor || this.globalOptions.slowdownfactor;
cordova.exec(onSuccess, onError, "NativePageTransitions", "slide", [opts]);
};

Expand All @@ -29,13 +36,13 @@ NativePageTransitions.prototype.drawer = function (options, onSuccess, onError)
opts.origin = opts.origin || "left";
opts.action = opts.action || "open";
if (opts.duration == undefined || opts.duration == "null") {
opts.duration = 400;
opts.duration = this.globalOptions.duration;
}
if (opts.androiddelay == undefined || opts.androiddelay == "null") {
opts.androiddelay = 50;
opts.androiddelay = this.globalOptions.androiddelay;
}
if (opts.iosdelay == undefined || opts.iosdelay == "null") {
opts.iosdelay = 50;
opts.iosdelay = this.globalOptions.iosdelay;
}
cordova.exec(onSuccess, onError, "NativePageTransitions", "drawer", [opts]);
};
Expand All @@ -47,13 +54,13 @@ NativePageTransitions.prototype.flip = function (options, onSuccess, onError) {
}
opts.direction = opts.direction || "right";
if (opts.duration == undefined || opts.duration == "null") {
opts.duration = 400;
opts.duration = this.globalOptions.duration;
}
if (opts.androiddelay == undefined || opts.androiddelay == "null") {
opts.androiddelay = 50;
opts.androiddelay = this.globalOptions.androiddelay;
}
if (opts.iosdelay == undefined || opts.iosdelay == "null") {
opts.iosdelay = 50;
opts.iosdelay = this.globalOptions.iosdelay;
}
cordova.exec(onSuccess, onError, "NativePageTransitions", "flip", [opts]);
};
Expand Down

0 comments on commit 6aa812a

Please sign in to comment.