Giter VIP home page Giter VIP logo

alice's Introduction

AliceJS

AliceJS - (A Lightweight Independent CSS Engine) is a micro JavaScript library focused on using hardware-accelerated capabilities (in particular CSS3 features) in modern browsers for generating high-quality, high-end visual effects.

This library and the sample code is Open Source under the Apache 2.0 License.

Special Attention As of version 0.5 there is no support for the 0.2 and 0.1 since there was a large transition in the method styling. So please if you're looking to transition to 0.5, you will need to re-write your code to fit the new method styling. Please take caution in doing so.

Author(s):

Compatibility Issues: AliceJs 0.5 is not compatible with 0.2 or 0.1. We made improvements in the readability of AliceJs with objectifying the parameters of the methods. We hope this doesn't cause any confusion or stop you from trying out the new caterpillar effect!

Requirements:

  1. A WebKit-based browser with support for CSS3.

How to use AliceJS in a web project

  1. Download the source package (zip or tar.gz) and unzip it to your web folder (e.g., /var/www/html/your project name/js/alice).

  2. Include the AliceJS library in your HTML using one of the following:

    a. Full library (with comments):

         <script src="js/alice/alice.js"></script>
    

    b. Minified version of the full library:

         <script src="js/alice/alice-min.js"></script>
    

    c. Specific effect(s):

         <script src="js/alice/src/alice.core.js"></script>
         <script src="js/alice/src/alice.plugins.cheshire.js"></script>
    
  3. Create your HTML markup. For example:

         <div id="deck" class="cards">
             <div class="card"><span>2</span></div>
             <div class="card"><span>3</span></div>
             <div class="card"><span>4</span></div>
             <div class="card"><span>5</span></div>
             <div class="card"><span>6</span></div>
             <div class="card"><span>7</span></div>
             <div class="card"><span>8</span></div>
             <div class="card"><span>9</span></div>
             <div class="card"><span>10</span></div>
             <div class="card"><span>J</span></div>
             <div class="card"><span>Q</span></div>
             <div class="card"><span>K</span></div>
             <div class="card"><span>A</span></div>
         </div>
    
  4. Apply Alice's effects by specifying the ID of your target DIV and some parameters. These options will apply a "slide (left)" effect to your DIVs.

         <script type="text/javascript">
         var deck = document.getElementById("deck").children;
    
         alicejs.slide({
             elems: deck, 
             move: "left", 
             duration: {
                 "value": "1000ms",
                 "randomness": "0%",
                 "offset": "150ms"
             }
         });
         </script>
    
  5. Add optional CSS styling to your DIVs:

         <style type="text/css">
         .card {
             float: left;
             background: transparent;
             border: 1px solid #CCC;
             border-radius: 20px;
             width: 75px;
             height: 100px;
             padding: 10px;
             text-align: center;
         }
         </style>
    

More Info

Contributing Changes

To contribute code to this repository, you must sign up as an official contributor.

To build the code you will need to have node installed. To build run the following in your shell(git-bash for windows):

./configure

This will install the dependancies. You should then be able to run:

jake

to build Alice.js

Running tests in a headless PhantomJS instance

Those tests require Grunt. Also, require grunt-contrib-qunit and grunt-contrib-jasmine plugins. To install all of them, type:

npm install -g grunt-cli
npm install grunt grunt-contrib-qunit grunt-contrib-jasmine
  • Run qunit tests with the grunt qunit -v command.
  • Run jasmine tests with the grunt jasmine -v command.
  • Run all tests with the grunt test -v command.

Bug Reporting and Feature Requests

If you find a bug or have an enhancement request, please report an Issue and send a message (via github messages) to the author(s) to let them know that you have filed an issue.

Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

alice's People

Contributors

gtanner avatar pelegri avatar psiborg avatar timwindsor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alice's Issues

Parameter list should be more flexible with defining elements

All effects should be able to accept its first parameter as a

  • string, denoting the Id of an element
  • element, denoting an element itself
  • string[], denoting a list of element Ids
  • element[] elems, denoting a list of elements
  • nodeList, denoting a nodeList (important for better integration with frameworks such as dojo, jQuery...)

To implement AliceJS my image disappears

Hello I need your help when I to implement the code in my html , and to refresh my browser my image disappears, I inspect with the console, and don't show me errors, And I put my cursor on the code in my inspecto's browser, a blue box appears with the effect, this means that the code runs fine but because my image is disappear?

Reorganize directory structure.

Current code needs some reorganization as it is confusing where everything lives and the root dirctory is a flood of files that all server different purpuses.

Top level directories should be created to sort files into logical groupings:

src/

All source code (further breakdown should happen in this folder (plugins folder / etc, but will be handled in another task

pkg/

The build output

docs/

All supporting documentation (samples / etc)

tests/

Unit test code.

build/

Any build support code, test runners, test markup, etc.

thirdparty/ or lib/

Third party code (jWorkflow, jasmine, etc) that is needed for building / bundling / etc

/

root dir should really only include the JakeFile, README.md, license information.

Support multiple axis animations

Currently it looks like only x or y axis animations are supported but not both. We need our animation to move diagonally, something like this:

{
  move: {direction: 'custom', from: '0, 0', to: '100px, 100px'}
}

StyleSheets with Import Issue

It appears that if a developer has any "import" at the beginning of their stylesheet the the keyframe insert causes an error.

randomness property ignored for slide()

I am trying to include randomness in a slide effect, using the following, however it doesn't appear to be used.

a.slide(elements, "left", 3, { "value": "700ms", "randomness": "75%", "timing" : "ease-in-out", "offset": "100ms" });

Am I just doing it wrong, or is this a bug?

Cannot chain cheshire rotate events

When chaining 2 cheshire events together, only the second one is applied.

Expected results:

  1. Rotate an image 90 degrees
  2. Then start an infinite 360 rotation every minute, with the rotation starting from that initial 90 deg position.

Actual results:

  1. The initial rotation (first cheshire in the following chained code snippet) seems to be ignored.
  2. The 360 deg animation always starts from 0 degrees, instead of the rotated 90deg angle I had tried to initially set the object to.

Is the following code how one should be able to do this chaining event? If not, can you specify the correction?

How to reproduce:

var a = alice.init({workflow: true});

a.cheshire({
        "perspectiveOrigin": "bottom",
        "elems": ["orbit"],
        "rotate": 90,
        "overshoot": 0,
        "duration": "0ms",
        "timing": "linear",
        "iteration": "1",
        "direction": "reverse"
    }).delay(0)
        .cheshire({
        "perspectiveOrigin": "bottom",
        "elems": ["orbit"],
        "rotate": 360,
        "overshoot": 0,
        "duration": "60000ms",
        "timing": "linear",
        "delay": {
            "value": "0ms",
            "randomness": "0%"
        },
        "iteration": "infinite",
        "direction": "reverse",
        "playstate": "running"
    }).start();

improve documentation to explain parameter values/defaults

I had some trouble understanding what values & format were accepted for each parameter of the animation methods. I think there is an opportunity to improve the documentation (or code comments / samples) to make this easier for developers who aren't already familiar with the framework

For example: I see the last parameter of the slide() method is playstate, and one code snippet shows that an eligible value is "running". What do either of these mean (what is a playstate)? What are other values besides 'running' that can be used instead? How would a developer know what values to fill in?

parseFloat() does not have a second parameter

Throughout the code of Alice, parseFloat() is used with a second parameter, ala parseInt's second parameter, "radix". However, parseFloat() only works in base 10, and therefore does not have a radix parameter.

Write Unit Tests

It is hard to contribute patches, new features, etc, without a test suite to catch regressions.

IE 10 support

It turns out, at least in the release preview, IE 10 style element is case sensitive. So in the javascript where it is checking for "MSAnimation" this will always fail. But it will find "msAnimation". So if you update this code in alice.core from:
// Internet Explorer 10+
else if ("MSAnimation" in el.style) {
this.prefix = "-ms-";
this.prefixJS = "MS";
}

to:
// Internet Explorer 10+
else if ("msAnimation" in el.style) {
this.prefix = "-ms-";
this.prefixJS = "ms";
}

Alice will then work in IE10 release preview.

However it turns out you do not need the ms prefix for css3 animations to work in IE10 but again it is case sensitive, so where all the style elements are being set, when in IE the first letter must be lower case for example when setting the "AnimationName" it must be "animationName".

Doing this will of coarse break everything when you do need a prefix, so for now it is probably best to keep the ms prefix.

Generalize randomn factor

Today, there is only one random factor for the entire effect. One should be able to control aspects of an effect independently, so for example, a randomness factor for "duration", and another for "angle" etc...

Add an "onEnd" handler for animations

Allow calling code to be notified automatically when an animation has ended. For continuous animations, wondering if something can be called after each cycle (not sure CSS handles that).

If "end()" is called on an animation, the "onEnd" handler should be called too.

Embed jWorkflow into Alice.js by default

Since you can't really just slam in any method chaining library and jWorkflow is only 1k minified we should just include it into alice (closured and hidden away) so that chaining animations can always be built into the library

Build out our test suite.

More of the codebase needs to be put under test.

Some thoughts as to how to get this needs to happen (demo page is nice for a smoke test but we need something automated).

Should be fine to test the final css rules applied to the element (as this is repeatable and constant) as what to test.

Keyframe rules are not deleted

I just found out that Alice.js does not always delete the keyframe rules it creates.
Alice.js uses the "webkitAnimationEnd" event to clear the keyframes rules it created and inserted to the css document. Unfortunately this event isn't fired after every animation completion - at least on my playbook (same story with webkitTransitionEnd event).

To fix this issue I've changed a few lines starting from the line: 234 in alice.cheshire.js so it's using setTimeout insted, like so:
// Add listener to clear animation after it's done
//if ("MozAnimation" in elem.style) {
// elem.addEventListener("animationend", alice.clearAnimation, false);
//}
//else {
// elem.addEventListener(alice.prefixJS + "AnimationEnd", alice.clearAnimation, false);
//}
setTimeout(function () {
alice.clearAnimation2(elem, animId);
}, parseInt(calc.delay) + parseInt(calc.duration));

And in alice.core.js added a method "clearAnimation2":
clearAnimation2: function (elem, animId) {
elem.style[alice.prefixJS + "AnimationName"] = "";
elem.style[alice.prefixJS + "AnimationDelay"] = "";
elem.style[alice.prefixJS + "AnimationDuration"] = "";
elem.style[alice.prefixJS + "AnimationTimingFunction"] = "";
elem.style[alice.prefixJS + "AnimationIterationCount"] = "";
elem.style[alice.prefixJS + "AnimationDirection"] = "";
elem.style[alice.prefixJS + "AnimationPlayState"] = "";

alice.keyframeDelete(animId);

return;

},

After those modifications I have the same number of css rules insertions and deletes.

Modularize the code in the src folder

Currently we only have 2 files:

https://github.com/blackberry/Alice/blob/master/js/src/alice.core.js
and
https://github.com/blackberry/Alice/blob/master/js/src/alice.plugins.cheshire.js

We should further break these down and reorganize the src folder.

I would expect something like the bounce plugin:
https://github.com/blackberry/Alice/blob/master/js/src/alice.plugins.cheshire.js#L279-310

To be in a file called bounce.js and have it included into the final build result automatically.

This will require changes to building and such to include all the files together in the proper order.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.