Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
Fixes CommonJS module loading. Closes #232. Closes #238.

Allow animating with the raw utility function (Velocity) instead of its
property (Velocity.animate), e.g. $.Velocity(element, propertiesMap,
options);

Copy over _cacheValues option for the UI pack. Closes #239.

Reverts Velocity.mock to original (asynchronous) behavior. Closes #237.

Fixes IE7 error throwing in UI pack. Closes #246.
  • Loading branch information
julianshapiro authored and Rycochet committed Aug 2, 2020
1 parent 9c981ec commit 9d3f672
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 37 deletions.
2 changes: 1 addition & 1 deletion packages/velocity/bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "velocity",
"version": "0.11.2",
"version": "0.11.3",
"homepage": "http://velocityjs.org",
"authors": [
{ "name" : "Julian Shapiro",
Expand Down
2 changes: 1 addition & 1 deletion packages/velocity/component.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "velocity",
"repository": "julianshapiro/velocity",
"version": "0.11.2",
"version": "0.11.3",
"description": "Accelerated JavaScript animation.",
"keywords": [
"animation",
Expand Down
64 changes: 34 additions & 30 deletions packages/velocity/jquery.velocity.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@

/*!
* Velocity.js: Accelerated JavaScript animation.
* @version 0.11.2
* @version 0.11.3
* @docs http://VelocityJS.org
* @license Copyright 2014 Julian Shapiro. MIT License: http://en.wikipedia.org/wiki/MIT_License
*/

/****************
Overview
Structure
****************/

/*
Velocity's structure:
- CSS Stack: Works independently from the rest of Velocity.
- Velocity.animate(): Core method that iterates over the targeted elements and queues the incoming call onto each element individually. Consists of:
- CSS: CSS stack that works independently from the rest of Velocity.
- animate(): Core animation method that iterates over the targeted elements and queues the incoming call onto each element individually.
- Pre-Queueing: Prepare the element for animation by instantiating its data cache and processing the call's options.
- Queueing: The logic that runs once the call has reached its point of execution in the element's $.queue() stack.
Most logic is placed here to avoid risking it becoming stale (if the element's properties have changed).
Expand All @@ -30,16 +29,16 @@ Velocity's structure:
******************/

;(function (factory) {
/* CommonJS module. */
if (typeof module === "object" && typeof module.exports === "object") {
module.exports = factory(window.Velocity ? undefined : require("jquery"));
/* AMD module. */
if (typeof define === "function" && define.amd) {
} else if (typeof define === "function" && define.amd) {
if (window.Velocity) {
define(factory);
define("velocity", factory);
} else {
define(["jquery"], factory)
define("velocity", [ "jquery" ], factory)
}
/* CommonJS module. */
} else if (typeof exports === "object") {
factory(window.Velocity ? undefined : require("jquery"));
/* Browser globals. */
} else {
factory(window.jQuery);
Expand Down Expand Up @@ -166,13 +165,14 @@ return function (global, window, document, undefined) {
*****************/

/* Local to our Velocity scope, assign $ to jQuery or the jQuery shim. (The shim is a port of the jQuery utility functions that Velocity uses.) */
var $;
var $;

/* The argument passed in by the module loader can either be jQuery (if it was required) or a helper function provided by the module loader
(in the case that Velocity's jQuery shim is being used). We check for jQuery by sniffing its unique .fn property. */

if (jQuery && jQuery.fn !== undefined) {
$ = jQuery;
} else if (window.Velocity && window.Velocity.Utilities) {

$ = window.Velocity.Utilities;
}

Expand Down Expand Up @@ -288,7 +288,7 @@ return function (global, window, document, undefined) {
});
},
/* Velocity's core animation method, later aliased to $.fn if a framework (jQuery or Zepto) is detected. */
animate: function () { /* Defined below. */ },
animate: null, /* Defined below. */
/* A reimplementation of jQuery's $.css(), used for getting/setting Velocity's hooked CSS properties. */
hook: function (elements, arg2, arg3) {
var value = undefined;
Expand Down Expand Up @@ -327,7 +327,7 @@ return function (global, window, document, undefined) {
},
/* Set to true to force a duration of 1ms for all animations so that UI testing can be performed without waiting on animations to complete. */
mock: false,
version: { major: 0, minor: 11, patch: 2 },
version: { major: 0, minor: 11, patch: 3 },
/* Set to 1 or 2 (most verbose) to output debug info to console. */
debug: false
};
Expand Down Expand Up @@ -1555,11 +1555,11 @@ return function (global, window, document, undefined) {
CSS.Hooks.register();
CSS.Normalizations.register();

/**********************
Velocity.animate
**********************/
/*****************
Animation
*****************/

Velocity.animate = function() {
var animate = function() {

/******************
Call Chain
Expand Down Expand Up @@ -1587,7 +1587,7 @@ return function (global, window, document, undefined) {
var syntacticSugar = (arguments[0] && (($.isPlainObject(arguments[0].properties) && !arguments[0].properties.names) || Type.isString(arguments[0].properties))),
/* Whether Velocity was called via the utility function (as opposed to on a jQuery/Zepto object). */
isUtility,
/* When Velocity is called via the utility function ($.Velocity.animate()/Velocity.animate()), elements are explicitly
/* When Velocity is called via the utility function ($.Velocity()/Velocity()), elements are explicitly
passed in as the first parameter. Thus, argument positioning varies. We normalize them here. */
elementsWrapped,
argumentIndex;
Expand Down Expand Up @@ -2806,7 +2806,7 @@ return function (global, window, document, undefined) {
reverseOptions.complete = opts.complete;
}

Velocity.animate(elements, "reverse", reverseOptions);
Velocity(elements, "reverse", reverseOptions);
}
}

Expand All @@ -2818,6 +2818,11 @@ return function (global, window, document, undefined) {
return getChain();
};

/* Turn Velocity into the animation function, extended with the pre-existing Velocity object. */
Velocity = $.extend(animate, Velocity);
/* For legacy support, also expose the literal animate method. */
Velocity.animate = animate;

/**************
Timing
**************/
Expand Down Expand Up @@ -3062,8 +3067,7 @@ return function (global, window, document, undefined) {

/* Note: completeCall() sets the isTicking flag to false when the last call on Velocity.State.calls has completed. */
if (Velocity.State.isTicking) {
/* If mock is on (http://VelocityJS.org/#mock), use synchronous code (with mock's forced duration of 0) to immediately toggle end values. */
Velocity.mock ? tick(true) : ticker(tick);
ticker(tick);
}
}

Expand Down Expand Up @@ -3094,7 +3098,7 @@ return function (global, window, document, undefined) {
var element = call[i].element;

/* If the user set display to "none" (intending to hide the element), set it now that the animation has completed. */
/* Note: display:none isn't set when calls are manually stopped (via Velocity.animate("stop"). */
/* Note: display:none isn't set when calls are manually stopped (via Velocity("stop"). */
/* Note: Display gets ignored with "reverse" calls and infinite loops, since this behavior would be undesirable. */
if (!isStopped && !opts.loop) {
if (opts.display === "none") {
Expand Down Expand Up @@ -3151,7 +3155,7 @@ return function (global, window, document, undefined) {
*********************/

/* Complete is fired once per call (not once per element) and is passed the full raw DOM element set as both its context and its first argument. */
/* Note: Callbacks aren't fired when calls are manually stopped (via Velocity.animate("stop"). */
/* Note: Callbacks aren't fired when calls are manually stopped (via Velocity("stop"). */
if (!isStopped && opts.complete && !opts.loop && (i === callLength - 1)) {
/* We throw callbacks in a setTimeout so that thrown errors don't halt the execution of Velocity itself. */
try {
Expand All @@ -3177,7 +3181,7 @@ return function (global, window, document, undefined) {
****************************/

if (opts.loop === true && !isStopped) {
Velocity.animate(element, "reverse", { loop: true, delay: opts.delay });
Velocity(element, "reverse", { loop: true, delay: opts.delay });
}

/***************
Expand Down Expand Up @@ -3228,7 +3232,7 @@ return function (global, window, document, undefined) {
If either framework is loaded, register a "velocity" extension pointing to Velocity's core animate() method. */
var framework;

if (jQuery && jQuery.fn) {
if (jQuery && jQuery.fn !== undefined) {
framework = jQuery;
} else if (window.Zepto) {
framework = window.Zepto;
Expand All @@ -3241,7 +3245,7 @@ return function (global, window, document, undefined) {

if (framework) {
/* Assign the element function to Velocity's core animate() method. */
framework.fn.velocity = Velocity.animate;
framework.fn.velocity = animate;
/* Assign the object function's defaults to Velocity's global defaults object. */
framework.fn.velocity.defaults = Velocity.defaults;
}
Expand Down Expand Up @@ -3379,7 +3383,7 @@ return function (global, window, document, undefined) {
};

/* Animation triggering. */
Velocity.animate(element, originalValues, opts);
Velocity(element, originalValues, opts);
};
});

Expand Down Expand Up @@ -3413,7 +3417,7 @@ return function (global, window, document, undefined) {
opts.display = opts.display || ((direction === "In") ? "auto" : "none");
}

Velocity.animate(this, propertiesMap, opts);
Velocity(this, propertiesMap, opts);
};
});

Expand Down
2 changes: 1 addition & 1 deletion packages/velocity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "velocity-animate",
"version": "0.11.2",
"version": "0.11.3",
"description": "Accelerated JavaScript animation.",
"keywords": [
"velocity",
Expand Down
9 changes: 5 additions & 4 deletions packages/velocity/velocity.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

/*!
* velocity.ui.js: UI effects pack for Velocity. Load this file after jquery.velocity.js.
* @version 4.1.0
* @version 4.1.1
* @docs http://velocityjs.org/#uiPack
* @support <=IE8: Callouts will have no effect, and transitions will simply fade in/out. IE9/Android 2.3: Most effects are fully supported, the rest fade in/out. All other browsers: Full support.
* @support <=IE8: Callouts will have no effect, and transitions will simply fade in/out. IE9/Android 2.3: Most effects are fully supported, the rest fade in/out. All other browsers: full support.
* @license Copyright Julian Shapiro. MIT License: http://en.wikipedia.org/wiki/MIT_License
* @license Indicated portions adapted from Animate.css, copyright Daniel Eden. MIT License: http://en.wikipedia.org/wiki/MIT_License
* @license Indicated portions adapted from Magic.css, copyright Christian Pucci. MIT License: http://en.wikipedia.org/wiki/MIT_License
Expand All @@ -21,7 +21,7 @@
var Container = (window.jQuery || window.Zepto || window);

if (!Container.Velocity || !Container.Velocity.Utilities) {
console.log("Velocity UI Pack: Velocity must be loaded first. Aborting.");
window.console && console.log("Velocity UI Pack: Velocity must be loaded first. Aborting.");

return;
}
Expand All @@ -34,7 +34,7 @@
}

/******************
Registration
Register UI
******************/

Container.Velocity.RegisterUI = function (effectName, properties) {
Expand Down Expand Up @@ -83,6 +83,7 @@
opts.queue = sequenceOptions.queue || "";
opts.easing = callOptions.easing || "ease";
opts.delay = callOptions.delay || 0;
opts._cacheValues = callOptions._cacheValues || true;

/* Special processing for the first effect call. */
if (callIndex === 0) {
Expand Down

0 comments on commit 9d3f672

Please sign in to comment.