#1 2017-11-09 23:24:03

eduardoalfaro
Member
Registered: 2016-06-08
Posts: 35

How to include JavaScript Framework within AppBuilder?

Hello to anyone…

I am wondering about if we can include a JavaScript framework (or more than one) into our APP with AppBuilder.

I mean, there are a lot of JS (JavaScript) frameworks that gives you a lot of new functionalities and powerful features so you can include all of them into your own projects, websites and hybrid-apps.

I have tried to include, for example, “paper.js” JS frameworkb, but I really do not know to proceed or complete the process.

Please, if you have time, take a look to its website for more information: http://paperjs.org/about/

I know how to include the JavaScript “.js” file with the AppBuilder APP File Manager... but I do not know how to call it and then create the canvas.

First of all you need to call the “.js” file:

<script type="text/javascript" src="../../dist/paper-full.js"></script>

Then next, create the script code for the canvas:

    <script type="text/paperscript" canvas="canvas">
    // The amount of symbol we want to place;
    var count = 150;

    // Create a symbol, which we will use to place instances of later:
    var path = new Path.Circle({
        center: new Point(0, 0),
        radius: 5,
        fillColor: 'white',
        strokeColor: 'black'
    });

    var symbol = new SymbolDefinition(path);

    // Place the instances of the symbol:
    for (var i = 0; i < count; i++) {
        // The center position is a random point in the view:
        var center = Point.random() * view.size;
        var placed = symbol.place(center);
        var scale = (i + 1) / count;
        placed.scale(scale);
        placed.data.vector = new Point({
            angle: Math.random() * 360,
            length : scale * Math.random() / 5
        });
    }

    var vector = new Point({
        angle: 45,
        length: 0
    });

    var mouseVector = vector.clone();

    function onMouseMove(event) {
        mouseVector = view.center - event.point;
    }

    // The onFrame function is called up to 60 times a second:
    function onFrame(event) {
        vector = vector + (mouseVector - vector) / 30;

        // Run through the active layer's children list and change
        // the position of the placed symbols:
        for (var i = 0; i < count; i++) {
            var item = project.activeLayer.children[i];
            var size = item.bounds.size;
            var length = vector.length / 10 * size.width / 10;
            item.position += vector.normalize(length) + item.data.vector;
            keepInView(item);
        }
    }

    function keepInView(item) {
        var position = item.position;
        var itemBounds = item.bounds;
        var bounds = view.bounds;
        if (itemBounds.left > bounds.width) {
            position.x = -item.bounds.width;
        }

        if (position.x < -itemBounds.width) {
            position.x = bounds.width + itemBounds.width;
        }

        if (itemBounds.top > view.size.height) {
            position.y = -itemBounds.height;
        }

        if (position.y < -itemBounds.height) {
            position.y = bounds.height  + itemBounds.height / 2;
        }
    }
    </script>

And finally, call the canvas:

<canvas id="canvas" resize hidpi="off" style="background:black"></canvas>

Do you have any idea how to include this and other JS Framework whintin AppBuilder?

I think this kind of feature will be..... gorgeous!!! ;-D

Thank you so much!!!

Eduardo.

Offline

#2 2017-11-10 11:31:40

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,653
Website

Re: How to include JavaScript Framework within AppBuilder?

Hello Eduardo,

Certainly its possible to use thirdparty Javascript in our DecSoft's App Builder applications. As you know, basically we must to include the appropriate Javascript file(s) using the Files Manager, and, in the proper order. Most of times we need to prepare an HTML Content control that contain the elements for our Javascript code, for example, a "canvas" HTML element like in the case of Paper.js.

After that we need to deal with the Javascript code in the proper way, for example, I am not sure about your above code, because they don't initialize any canvas element. Basically, after add the appropriate Javascript files, we must use the right Javascript code in the right place in our application: you know that we can use Javascript code in any place, just placing it between the "StartJS" and "EndJS" actions.

I prepare a "PaperJs" sample for you that shown how we can use the jQuery the Paper.js Javascript libraries in our applications. This sample is included now in the current DecSoft's App Builder release, but I also upload it here for your convenience: PaperJs.zip.

Offline

#3 2017-11-10 12:38:50

eduardoalfaro
Member
Registered: 2016-06-08
Posts: 35

Re: How to include JavaScript Framework within AppBuilder?

Hello David,

Really!!! YOU ARE INCREDIBLE!!!

This JS library gives to AppBuilder lots of new features!!!
THANK YOU so much for your knowledge

Eduardo

Offline

#4 2017-11-10 14:25:22

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,653
Website

Re: How to include JavaScript Framework within AppBuilder?

Hello to all,

eduardoalfaro wrote:

Hello David,

Really!!! YOU ARE INCREDIBLE!!!

This JS library gives to AppBuilder lots of new features!!!
THANK YOU so much for your knowledge

Eduardo

You're welcome Eduardo! Please, let me know if you have any further questions. smile

Offline

Board footer

Powered by FluxBB


Copyright © 2017 DecSoft. All rights reserved.