How to use the velocity.CSS function in velocity

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 / 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;
      }
    }