[ 
https://issues.apache.org/jira/browse/CB-9365?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14729402#comment-14729402
 ] 

ASF GitHub Bot commented on CB-9365:
------------------------------------

Github user robpaveza commented on a diff in the pull request:

    
https://github.com/apache/cordova-plugin-vibration/pull/38#discussion_r38669813
  
    --- Diff: src/windows/VibrationProxy.js ---
    @@ -60,12 +61,43 @@ if (VibrationDevice) {
                     fail(e);
                 }
             }, 
    -        vibrateWithPattern: function(success, fail, args) {
    -            // TODO: Implement with setTimeout.
    -            fail('"vibrateWithPattern" is unsupported by this platform.');
    +        vibrateWithPattern: function (success, fail, args) {
    +            // Cancel current vibrations first
    +            module.exports.cancelVibration(function () {
    +                // Removes the first zero
    +                if (args[0] && args[0][0] === 0) {
    +                    args[0].shift(0);
    +                }
    +
    +                patternChainPromise = args[0].reduce(function 
(previousValue, currentValue, index) {
    +                    if (index % 2 === 0) {
    +                        return previousValue.then(function () {
    +                            return new WinJS.Promise(function (complete, 
error) {
    +                                module.exports.vibrate(function () {}, 
function(err) {
    +                                    console.error(err);
    +                                    error(err);
    +                                }, [currentValue]);
    +
    +                                setTimeout(function () {
    +                                    complete();
    +                                }, parseInt(currentValue, 10));
    +                            });
    +                        });
    +                    } else {
    +                        return previousValue.then(function () {
    +                            return new WinJS.Promise(function (complete) {
    --- End diff --
    
    Prefer `WinJS.Promise.timeout(parseInt(currentValue, 10))` to `new 
WinJS.Promise( ... setTimeout(...))`.


> Add support for 'vibrateWithPattern' to Windows Phone 8.1 / Windows 10
> ----------------------------------------------------------------------
>
>                 Key: CB-9365
>                 URL: https://issues.apache.org/jira/browse/CB-9365
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Vibration
>            Reporter: Rob Paveza
>            Assignee: Sergey Shakhnazarov
>            Priority: Minor
>
> 'vibrateWithPattern' is supported by C# component in wp8, but needs to be 
> migrated to Windows Phone 8.1.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to