How to use velocity - 10 common examples

To help you get started, we’ve selected a few velocity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ember-animation / ember-animated / addon / animate.js View on Github external
/* jshint newcap: false */
import Promise from "./promise";
import Ember from "ember";
import Velocity from "velocity";

// Make sure Velocity always has promise support by injecting our own
// RSVP-based implementation if it doesn't already have one.
if (!Velocity.Promise) {
  Velocity.Promise = Promise;
}

export function animate(elt, props, opts, label) {
  // These numbers are just sane defaults in the probably-impossible
  // case where somebody tries to read our state before the first
  // 'progress' callback has fired.
  var state = { percentComplete: 0, timeRemaining: 100, timeSpent: 0 };

  if (!elt || elt.length === 0) {
    return Promise.resolve();
  }

  if (!opts) {
    opts = {};
  } else {
github ember-animation / ember-animated / addon / animate.js View on Github external
/* jshint newcap: false */
import Promise from "./promise";
import Ember from "ember";
import Velocity from "velocity";

// Make sure Velocity always has promise support by injecting our own
// RSVP-based implementation if it doesn't already have one.
if (!Velocity.Promise) {
  Velocity.Promise = Promise;
}

export function animate(elt, props, opts, label) {
  // These numbers are just sane defaults in the probably-impossible
  // case where somebody tries to read our state before the first
  // 'progress' callback has fired.
  var state = { percentComplete: 0, timeRemaining: 100, timeSpent: 0 };

  if (!elt || elt.length === 0) {
    return Promise.resolve();
  }

  if (!opts) {
    opts = {};
  } else {
    opts = Ember.copy(opts);
github nkholski / phaser-tiled-extras / src / imageLayer.js View on Github external
// Flip with Scale<0 not working! --> Need to adjust position!!!
                if (layers[i].properties.hasOwnProperty('scale')) {
                    object.scale.x = parseFloat(layers[i].properties.scale);
                    object.scale.y = parseFloat(layers[i].properties.scale);
                    object.width /= object.scale.x;
                    object.height /= object.scale.y;
                }
                if (layers[i].properties.hasOwnProperty('scale.x')) {
                    object.scale.x = parseFloat(layers[i].properties["scale.x"], 10);
                }
                if (layers[i].properties.hasOwnProperty('scale.y')) {
                    object.scale.y = parseFloat(layers[i].properties["scale.y"], 10);
                }

                // TODO: Make velocity work for non tileSprites:
                object.velocity.x = layers[i].properties.hasOwnProperty('velocity.x') ? parseFloat(layers[i].properties["velocity.x"]) : object.velocity.x;
                object.velocity.y = layers[i].properties.hasOwnProperty('velocity.y') ? parseFloat(layers[i].properties["velocity.y"]) : object.velocity.y;

                if (layers[i].properties.hasOwnProperty('parallax') && parseFloat(layers[i].properties.parallax) > 0) {
                    object.parallax = {
                        x: parseFloat(layers[i].properties.parallax),
                        y: parseFloat(layers[i].properties.parallax)
                    };
                    object.canBeSprite = false;
                }

                if (object.canBeSprite) {
                    var graphicalObject = game.add.sprite(object.x, object.y, object.imageKey);

                } else {
                    var graphicalObject = game.add.tileSprite(object.x, object.y, object.width, object.height, object.imageKey);
                }
github nkholski / phaser-tiled-extras / build / phaser-tiled-extras.js View on Github external
// Flip with Scale<0 not working! --> Need to adjust position!!!
                if (layers[i].properties.hasOwnProperty('scale')) {
                    object.scale.x = parseFloat(layers[i].properties.scale);
                    object.scale.y = parseFloat(layers[i].properties.scale);
                    object.width /= object.scale.x;
                    object.height /= object.scale.y;
                }
                if (layers[i].properties.hasOwnProperty('scale.x')) {
                    object.scale.x = parseFloat(layers[i].properties["scale.x"], 10);
                }
                if (layers[i].properties.hasOwnProperty('scale.y')) {
                    object.scale.y = parseFloat(layers[i].properties["scale.y"], 10);
                }

                // TODO: Make velocity work for non tileSprites:
                object.velocity.x = layers[i].properties.hasOwnProperty('velocity.x') ? parseFloat(layers[i].properties["velocity.x"]) : object.velocity.x;
                object.velocity.y = layers[i].properties.hasOwnProperty('velocity.y') ? parseFloat(layers[i].properties["velocity.y"]) : object.velocity.y;

                if (layers[i].properties.hasOwnProperty('parallax') && parseFloat(layers[i].properties.parallax) > 0) {
                    object.parallax = {
                        x: parseFloat(layers[i].properties.parallax),
                        y: parseFloat(layers[i].properties.parallax)
                    };
                    object.canBeSprite = false;
                }

                if (object.canBeSprite) {
                    var graphicalObject = game.add.sprite(object.x, object.y, object.imageKey);

                } else {
                    var graphicalObject = game.add.tileSprite(object.x, object.y, object.width, object.height, object.imageKey);
                }
github nkholski / phaser-tiled-extras / src / imageLayer.js View on Github external
if (layers[i].properties.hasOwnProperty('scale')) {
                    object.scale.x = parseFloat(layers[i].properties.scale);
                    object.scale.y = parseFloat(layers[i].properties.scale);
                    object.width /= object.scale.x;
                    object.height /= object.scale.y;
                }
                if (layers[i].properties.hasOwnProperty('scale.x')) {
                    object.scale.x = parseFloat(layers[i].properties["scale.x"], 10);
                }
                if (layers[i].properties.hasOwnProperty('scale.y')) {
                    object.scale.y = parseFloat(layers[i].properties["scale.y"], 10);
                }

                // TODO: Make velocity work for non tileSprites:
                object.velocity.x = layers[i].properties.hasOwnProperty('velocity.x') ? parseFloat(layers[i].properties["velocity.x"]) : object.velocity.x;
                object.velocity.y = layers[i].properties.hasOwnProperty('velocity.y') ? parseFloat(layers[i].properties["velocity.y"]) : object.velocity.y;

                if (layers[i].properties.hasOwnProperty('parallax') && parseFloat(layers[i].properties.parallax) > 0) {
                    object.parallax = {
                        x: parseFloat(layers[i].properties.parallax),
                        y: parseFloat(layers[i].properties.parallax)
                    };
                    object.canBeSprite = false;
                }

                if (object.canBeSprite) {
                    var graphicalObject = game.add.sprite(object.x, object.y, object.imageKey);

                } else {
                    var graphicalObject = game.add.tileSprite(object.x, object.y, object.width, object.height, object.imageKey);
                }
                var ObjectKeys = Object.keys(object);
github nkholski / phaser-tiled-extras / build / phaser-tiled-extras.js View on Github external
if (layers[i].properties.hasOwnProperty('scale')) {
                    object.scale.x = parseFloat(layers[i].properties.scale);
                    object.scale.y = parseFloat(layers[i].properties.scale);
                    object.width /= object.scale.x;
                    object.height /= object.scale.y;
                }
                if (layers[i].properties.hasOwnProperty('scale.x')) {
                    object.scale.x = parseFloat(layers[i].properties["scale.x"], 10);
                }
                if (layers[i].properties.hasOwnProperty('scale.y')) {
                    object.scale.y = parseFloat(layers[i].properties["scale.y"], 10);
                }

                // TODO: Make velocity work for non tileSprites:
                object.velocity.x = layers[i].properties.hasOwnProperty('velocity.x') ? parseFloat(layers[i].properties["velocity.x"]) : object.velocity.x;
                object.velocity.y = layers[i].properties.hasOwnProperty('velocity.y') ? parseFloat(layers[i].properties["velocity.y"]) : object.velocity.y;

                if (layers[i].properties.hasOwnProperty('parallax') && parseFloat(layers[i].properties.parallax) > 0) {
                    object.parallax = {
                        x: parseFloat(layers[i].properties.parallax),
                        y: parseFloat(layers[i].properties.parallax)
                    };
                    object.canBeSprite = false;
                }

                if (object.canBeSprite) {
                    var graphicalObject = game.add.sprite(object.x, object.y, object.imageKey);

                } else {
                    var graphicalObject = game.add.tileSprite(object.x, object.y, object.width, object.height, object.imageKey);
                }
                var ObjectKeys = Object.keys(object);
github ember-animation / ember-animated / addon / velocity-ext.js View on Github external
/*
  This makes it possible to animate outerHeight and outerWidth with
  Velocity, which is much more convenient for our purposes. Submitted
  to Velocity as PR #485.
*/

import Velocity from "velocity";
var VCSS = Velocity.CSS;

function augmentDimension(name, element) {
  var sides = name === 'width' ? ['Left', 'Right' ] : ['Top', 'Bottom'];

  if (VCSS.getPropertyValue(element, "boxSizing").toString().toLowerCase() === 'border-box') {
    /* in box-sizing mode, the VCSS width / height accessors already give the outerWidth / outerHeight. */
    return 0;
  } else {
    var augment = 0;
    var fields = ['padding'+sides[0], 'padding'+sides[1], 'border'+sides[0]+'Width', 'border'+sides[1]+'Width'];
    for (var i = 0; i < fields.length; i++) {
      var value = parseFloat(VCSS.getPropertyValue(element, fields[i]));
      if (!isNaN(value)) {
        augment += value;
      }
    }
github wix / wix-height-updater / test / mock / vm.ts View on Github external
export function renderVM(template, data) {
  const engine = new Engine({template});
  const velocityDataPrivate = loadJson('../../velocity.private.data.js');
  return engine.render(Object.assign({}, velocityData, velocityDataPrivate, data));
}
github winnieBear / gulp-velocity / index.js View on Github external
}
    if(file.isStream()){
      return this.emit('error',new Error(PLUGIN_NAME + ": Streaming not supported"));
    }

    if (file.isBuffer()) {
      opt.filePath = file.path;
      opt.template = String(file.contents);
      try{
        var context = getContext(opt);
      }catch(err){
        return this.emit('error',err)
      }
     
      try{
        var renderResult = new vEngine(opt).render(context);
      }catch(err){
        console.log("[gulp-velocity]",colors.red('Error:'),colors.yellow(err.stack));
        return this.emit('error',err)
      }
      file.contents = new Buffer(renderResult);
      this.emit('data', file);
    }
  }