Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
velocityjs
Advanced tools
Velocity.js is a fast, feature-rich animation engine for JavaScript. It allows you to animate HTML elements with a variety of effects, providing a more performant alternative to jQuery's $.animate() method. Velocity.js is designed to work seamlessly with jQuery but can also be used as a standalone library.
Basic Animations
This feature allows you to animate basic CSS properties like opacity and position. The code sample animates an element's opacity to 0.5 and moves it to 50% from the left over a duration of 1000 milliseconds.
document.getElementById('element').velocity({ opacity: 0.5, left: '50%' }, { duration: 1000 });
Color Animations
Velocity.js supports color animations, allowing you to animate CSS color properties. The code sample changes the background color of an element to red over a duration of 1000 milliseconds.
document.getElementById('element').velocity({ backgroundColor: '#ff0000' }, { duration: 1000 });
Scroll Animations
This feature allows you to animate scrolling to a specific element. The code sample scrolls the page to the element with an offset of -50 pixels over a duration of 1000 milliseconds.
document.getElementById('element').velocity('scroll', { duration: 1000, offset: -50 });
Easing
Velocity.js provides various easing functions to control the animation's acceleration and deceleration. The code sample animates an element's opacity to 1 using a 'spring' easing function over a duration of 1000 milliseconds.
document.getElementById('element').velocity({ opacity: 1 }, { duration: 1000, easing: 'spring' });
Chaining Animations
You can chain multiple animations together in sequence. The code sample first animates an element's opacity to 0.5 and then moves it to 50% from the left, each over a duration of 1000 milliseconds.
document.getElementById('element').velocity({ opacity: 0.5 }, { duration: 1000 }).velocity({ left: '50%' }, { duration: 1000 });
Anime.js is a lightweight JavaScript animation library with a simple, yet powerful API. It supports a wide range of animations, including CSS properties, SVG, DOM attributes, and JavaScript objects. Compared to Velocity.js, Anime.js offers more advanced animation capabilities and a more modern API.
GSAP (GreenSock Animation Platform) is a robust JavaScript library for creating high-performance animations. It is widely used in the industry for its flexibility and power, supporting complex animations and timelines. GSAP is more feature-rich and versatile compared to Velocity.js, making it suitable for more complex animation needs.
Popmotion is a functional, flexible JavaScript animation library. It provides a range of tools for creating animations and interactions, including physics-based animations. Popmotion is more modular and functional compared to Velocity.js, offering a different approach to building animations.
Velocityjs is velocity template engine for javascript.
via npm:
$ npm install velocityjs
Compatible all modern broswer, You can try test case on your browser to test it.
For other lower version broswer, you need have those polyfill function.
You can find a lot of examples from the tests directory. There is no different between the use of browser and NodeJs.
{
// render method
render(vm: string, context?: Object, macros?: Object): string;
parse(vm: string, config?: Object, ignorespace?: boolean): Array<Ast>;
Compile: {
(asts: Array<Ast>, config?: Object): {
render(context?: Object, macros?: Object);
};
};
}
params:
#include('path/xxx')
, you can define you inlcude
macro functionvar Velocity = require('velocityjs');
Velocity.render('string of velocity', context, macros);
context
is an object or undefined, for vm $foo.bar
, data look up path will be context.foo.bar
.
context
can have method, and call it just on velocity string.
The method of context, will have eval
method on this
of inner method body. You can eval
to rerender velocity string, such as test code $control.setTemplate.
parse
method can parse vm, and return ast tree of velocity.
Compile
will render asts to result string.
var Compile = Velocity.Compile;
var asts = Velocity.parse('string of velocity');
(new Compile(asts)).render(context, macros);
params:
true
, default escape variable to html encode, you can set false to close it.{control: true}
, so $control.html
will not escape.development
will throw error when null values are usedparams:
#cms(1) hello #end
, you can set {cms: true}
Syntax you can find from velocity user guide。
Directives supports have set
, foreach
, if|else|elseif
, macro
, break
, stop
.
Some othe directive evaluate
, define
, parse
, do not supported default, but You can realize by context or macros, for example parse
You can find help from those ways:
Recommend an other velocity.
(The MIT License)
1.0.1 2018-03-08
FAQs
Velocity Template Language(VTL) for JavaScript
The npm package velocityjs receives a total of 293,152 weekly downloads. As such, velocityjs popularity was classified as popular.
We found that velocityjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.