forked from github/Toast-PhoneGap-Plugin
#36 control the vertical position (added WP support)
This commit is contained in:
parent
2cb29b217a
commit
3d0b2927ae
@ -150,7 +150,7 @@ You can copy-paste these lines of code for a quick test:
|
|||||||
<button onclick="window.plugins.toast.show('Hello there!', 'long', 'center', function(a){console.log('toast success: ' + a)}, function(b){alert('toast error: ' + b)})">Toast show long center</button>
|
<button onclick="window.plugins.toast.show('Hello there!', 'long', 'center', function(a){console.log('toast success: ' + a)}, function(b){alert('toast error: ' + b)})">Toast show long center</button>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Tweaking the vertical position (iOS and Android)
|
#### Tweaking the vertical position
|
||||||
Since 2.1.0 you can add pixels to move the toast up or down.
|
Since 2.1.0 you can add pixels to move the toast up or down.
|
||||||
Note that `showWithOptions` can be used instead of the functions above, but it's not useful unless you want to pass `addPixelsY`.
|
Note that `showWithOptions` can be used instead of the functions above, but it's not useful unless you want to pass `addPixelsY`.
|
||||||
```js
|
```js
|
||||||
|
@ -39,6 +39,9 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
|
|
||||||
[DataMember(IsRequired = true, Name = "position")]
|
[DataMember(IsRequired = true, Name = "position")]
|
||||||
public string position { get; set; }
|
public string position { get; set; }
|
||||||
|
|
||||||
|
[DataMember(IsRequired = false, Name = "addPixelsY")]
|
||||||
|
public int addPixelsY { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(string options)
|
public void show(string options)
|
||||||
@ -60,6 +63,7 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
var message = toastOptions.message;
|
var message = toastOptions.message;
|
||||||
var duration = toastOptions.duration;
|
var duration = toastOptions.duration;
|
||||||
var position = toastOptions.position;
|
var position = toastOptions.position;
|
||||||
|
int addPixelsY = toastOptions.addPixelsY;
|
||||||
|
|
||||||
string aliasCurrentCommandCallbackId = args[1];
|
string aliasCurrentCommandCallbackId = args[1];
|
||||||
|
|
||||||
@ -104,17 +108,17 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
if ("top".Equals(position))
|
if ("top".Equals(position))
|
||||||
{
|
{
|
||||||
popup.VerticalAlignment = VerticalAlignment.Top;
|
popup.VerticalAlignment = VerticalAlignment.Top;
|
||||||
popup.VerticalOffset = 20;
|
popup.VerticalOffset = 20 + addPixelsY;
|
||||||
}
|
}
|
||||||
else if ("bottom".Equals(position))
|
else if ("bottom".Equals(position))
|
||||||
{
|
{
|
||||||
popup.VerticalAlignment = VerticalAlignment.Bottom;
|
popup.VerticalAlignment = VerticalAlignment.Bottom;
|
||||||
popup.VerticalOffset = -100; // TODO can do better
|
popup.VerticalOffset = -100 + addPixelsY; // TODO can do better
|
||||||
}
|
}
|
||||||
else if ("center".Equals(position))
|
else if ("center".Equals(position))
|
||||||
{
|
{
|
||||||
popup.VerticalAlignment = VerticalAlignment.Center;
|
popup.VerticalAlignment = VerticalAlignment.Center;
|
||||||
popup.VerticalOffset = -50; // TODO can do way better
|
popup.VerticalOffset = -50 + addPixelsY; // TODO can do way better
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user