Jump to content
Search Community

OSUblake last won the day on September 16 2023

OSUblake had the most liked content!

OSUblake

Moderators
  • Posts

    9,196
  • Joined

  • Last visited

  • Days Won

    708

Posts posted by OSUblake

  1. I think Firefox is becoming the new IE. I've noticed lots of unexpected behaviors when dealing with it lately. Jitters and jaggies everywhere.

     

    I've never really tested my animations, but Yearofmoo said to use a timeout instead of using GSAP's onComplete to call the done function. I think he wrote the animation module, so he should know.

     

    http://www.yearofmoo.com/2013/08/remastered-animation-in-angularjs-1-2.html#testing-animations

    http://www.yearofmoo.com/2013/05/enhanced-animations-in-angularjs.html#greensock-integration

     

    • Like 1
  2. Good job!
     
    With the way it is setup now, creating a fade transition between the info and person tile won't look right because the ng-switch is only showing 1 element at a time. This would leave the back tile completely blank while one tile is being removed and the other is being added.
     
    If you use the animation module, you can have 2 elements being shown in the ng-switch during a transition, the element being removed (leave animation), and the element being added (enter animation). 
     
    I created a class for the info and person tiles called switch-tile. It is positioned absolute so that both tiles are at the same position while visible, and not stacked on top of each other. The .switch-tile animation module will now animate these tiles at the same time when they are are being added/removed from the back tile.
     
    I also noticed that if you quickly press the info and person buttons on the case tile, it can mess up the resize/flip animation. I added ng-disabled to the case tile's buttons, which is controlled by calling the setTransitioning function. Because this function is called by the timeline, it uses a $timeout to make Angular update the scope. Here's a post I made about getting GreenSock to work with Angular by using $timeout.
     
    CodePen:

    See the Pen pvgvYv by osublake (@osublake) on CodePen

    • Like 2
  3. +1 for Michael's recommendation on Phaser.io, which uses the awesome Pixi.js library. I will never attempt to build another game from scratch.
     
    Viewport scaling can be real tricky because the aspect ratio can vary greatly across different devices. What I have done in the past is to scale the game's viewable area and the actual game content independently, creating a responsive layout. The view and the game content will scale at the same ratio until a certain aspect ratio is broken, at which point the viewable area will scale to the viewport's aspect ratio. This will eliminate the need to letterbox or crop parts of your game. However, this approach may not be ideal for games where you must maintain a certain aspect ratio, like in a platformer.
     
    Here's some screenshots showing this technique in practice. Even when set to a ridiculous proportion, the game elements, shown in red by their bounding boxes, still maintain their original aspect ratio.
     

    rws5jc.jpg

     

    30j69aa.jpg

    • Like 2
  4. The best way to setup what you have right now is probably to put the info and person tile inside an ng-switch. To control the switch, create a new scope variable called selectedType.

     

    How is it going to transition between an info and person tile, flip, fade, etc? Once I know the type of transition, I can offer more detailed advice.

    <div class="cardWrapper">
      <div class="card">
                  
        <div ng-switch="selectedType" class="cardFace backTile">
    
          <div ng-switch-when="info" class="infoTile">
            info tile...
          </div>
    
          <div ng-switch-when="person" class="personTile">
            person tile...
          </div>
    
        </div>
    
        <div class="cardFace caseTile">
          case tile...
        </div>
    
      </div>
    </div>
  5. Prepending/appending dummy elements to the container won't interfere with the repeater or your data. Although it might mess up some of your logic if you are tracking elements by their $index instead of an id. But I don't think that approach is necessary after messing around with your codepen.

     

    I didn't use the animation module, but I did use ng-class to sort out which tiles to hide, which cut out a lot of code. I couldn't get consistent positioning using scrollLeft, so I ended up using getBoundingClientRect. Lots of weird behaviors just kept popping up, but I think I got it fixed.

     

    Another thing I noticed is that you were rotating the .card div instead of the individual card faces, which won't work in IE. Rotating the .cardface divs with a relative angle fixes that.

     

    CodePen: 

    See the Pen vENgOO by osublake (@osublake) on CodePen

     

     

    • Like 1
  6. Hey Flex,

     

    Have you used the animation module before? There are a lot of built-in Angular directives that will automatically trigger an animation. You can streamline a lot of your code by using some conditional directives like:

    Also, you might be better off creating a directive for each of your items/cases so you can have more control over what each one is doing.

     

    I created an example showing how you can incorporate some of those built-in directives. I wasn't sure what you were trying to do with the MAX_NUMBER_VIEWABLE_TILES, so I just used a filter to limit the number of tiles based on the screen width.

     

    Plunker Demo: http://plnkr.co/edit/yOtalOY51OusVZl5uGOU?p=preview

    • Like 1
  7. Those are the gzip sizes, and they're accurate. Look above the kb size, 420 B and 414 B. It only download the headers because you have an up to date version cached. That's what that 304 status code means.

    • Like 2
  8. Thanks. Those demos are trending pretty well on Plunker so hopefully it will bring in some new people.
     
    Yeah. They're randomly rotated 180 degrees. It's sort of like a game where you have to flip the tiles in the right order to get the picture to display right. I didn't provide any notification once you got it right because some of tiles can be all black, and you really can't tell if you have it rotated correctly. 
     
    All the logic to flip the tiles is in the tile.js file, and is pretty straightforward even if you don't know Angular. You can test it out in an unjumbled state by commenting out line 47.
     

    TweenMax.set(back, {
     //rotation  : _.sample([0, 180]),
     rotationY : -180,
     backgroundPosition: -scope.x + "px " + -scope.y + "px"
    });
    
    • Like 1
  9. Creating dynamic animations in Angular 1.3 has dramatically improved. You no longer need to inject a service or access your scope to get values for your animation. All animation methods now have an options parameter where you can pass in values to your animation modules.  There is also a new inline animate method where you can pass in from and to values and no longer have to deal with toggling a CSS class name.

     

     

    // In a directive
    link: function(scope, element, attrs) {      
      scope.moveToMouse = function($event) {        
        var from = { autoAlpha: 0, x: 0, y: 0 };
        var to =   { autoAlpha: 1, x: $event.pageX, y: $event.pageX };     
        $animate.animate(element, from, to);
    }
    
    // In your animation module
    animate: function(element, className, from, to, done) {
      TweenMax.fromTo(element, 0.5, from, to);
      done();
    }
    
     

     

    Here's a simple demo of that code in use

    http://plnkr.co/edit/midHzP?p=preview

     

    And a more involved demo showing how to flip a card in the direction of the mouse and creating random bezier curves

    Demo: http://embed.plnkr.co/CIiLR4/preview

    Code: http://plnkr.co/edit/CIiLR4

    • Like 2
  10. I love using TypeScript! It's not another language like Coffee or Dart, but a superset of JavaScript similar to how LESS and SASS are to CSS. TypeScript also lets you use a lot of ES6 features like fat arrow functions and modules.
     
    I'm working on another definition file because the one on DefinitelyTyped is out of date, missing types, and doesn't include any overloads for get/set methods. I'm also including JSDoc comments so a description with all the arguments will popup. I'll post here when I'm done and will also send a pull request to DefinitelyTyped so they can update the definition.
     
    To get around errors because a definition is missing, you can just declare it.
     

    declare var SplitText;
    declare var Draggable;
    

    You might also get errors on your targets with the current definition, so you should update the targets in the definition file to be type any instead of Object
     

    static to(target: any, duration: number, vars: Object): TweenMax;
    
    • Like 2
  11. I saw other posts where people used the _gsTransform object to get some values. However, that object is not present in my targets :/

     

    GSAP has to do a transform on the element before the _gsTransform object will be available. You could do something like this to setup the initial transform.

    TweenMax.set(target, { x: "+=0" });
    
     

     

     

    If you have already done a transform and still cannot find the _gsTransform object, you're probably looking at a jQuery wrapped element, which is an array. The DOM element will be the first item in the array, so try this.

     

    var xPos = target[0]._gsTransform.x;
    
    • Like 3
  12. One thing to consider is that performance on a lot of mobile devices is pretty bad with canvas unless you use an accelerated canvas wrapper like CocoonJS. The problem with that approach is that the user has to download an app that you deploy.

     

    Fortunately WebGL is becoming more of the standard now, which can greatly improve performance over the 2D canvas, especially on mobile devices. The downside is that programming for WebGL can get pretty complicated without a library.  

    • Like 3
  13. If you want to target them all, you could just give them all the same class or target the element type.  You don't even have to use jQuery to do that with the latest version of GSAP.

    // By element
    TweenMax.to("button", .25, {opacity:0, ease: Linear.easeNone});
    
    // By class
    TweenMax.to(".my-class", .25, {opacity:0, ease: Linear.easeNone});
    
×
×
  • Create New...