All Projects → Antrikshy → Tinseltown.js

Antrikshy / Tinseltown.js

Licence: mit
A lightweight CSS/JS library for faux hacker-movie-style page loading effects

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Tinseltown.js

Scssphp
SCSS compiler written in PHP
Stars: ✭ 309 (+173.45%)
Mutual labels:  hacktoberfest, sass
Node Sass Magic Importer
Custom node-sass importer for selector specific imports, module importing, globbing support and importing files only once.
Stars: ✭ 273 (+141.59%)
Mutual labels:  hacktoberfest, sass
Aquila
🎨 An Advanced WordPress theme
Stars: ✭ 204 (+80.53%)
Mutual labels:  hacktoberfest, sass
Ripple Without Js
Create Material Design ripple effect in your HTML without using a single line of JS.
Stars: ✭ 53 (-53.1%)
Mutual labels:  hacktoberfest, css-animations
Backslide
💦 CLI tool for making HTML presentations with Remark.js using Markdown
Stars: ✭ 679 (+500.88%)
Mutual labels:  hacktoberfest, sass
Magento2 Theme Blank Sass
SASS based version of Magento 2 Blank theme
Stars: ✭ 373 (+230.09%)
Mutual labels:  hacktoberfest, sass
Stylesheet
The GTK Stylesheet for elementary OS
Stars: ✭ 260 (+130.09%)
Mutual labels:  hacktoberfest, sass
Magento2 Frontools
Set of front-end tools for Magento 2 based on Gulp.js
Stars: ✭ 416 (+268.14%)
Mutual labels:  hacktoberfest, sass
Boilerplate
Responsive CSS, HTML and JavaScript front-end starting point.
Stars: ✭ 48 (-57.52%)
Mutual labels:  hacktoberfest, sass
Generator Ngx Rocket
🚀 Extensible Angular 11+ enterprise-grade project generator
Stars: ✭ 1,329 (+1076.11%)
Mutual labels:  hacktoberfest, sass
Inkscape Applytransforms
An Inkscape extension which removes all matrix transforms by applying them recursively to shapes
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Git Client Plugin
Jenkins git client plugin
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Webpack Seed
🚀 A Multi-Page Application base on webpack and babel. webpack搭建基于ES6,支持模板的多页面项目
Stars: ✭ 113 (+0%)
Mutual labels:  sass
Pac
科学上网,智能分流,使用 GFWList 和 IP 地址双重判断。现在已有 113 颗 ★
Stars: ✭ 113 (+0%)
Mutual labels:  hacktoberfest
Zpm
ZPM — Zsh Plugin Manager
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Xgo
Go CGO cross compiler
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Abaplint
Standalone linter for ABAP
Stars: ✭ 111 (-1.77%)
Mutual labels:  hacktoberfest
Mdl Ext
Material Design Lite Ext: Components built with Google Material Design Lite framework. http://leifoolsen.github.io/mdl-ext/
Stars: ✭ 112 (-0.88%)
Mutual labels:  sass
Lab Workshops
Materials for workshops on text mining, machine learning, and data visualization
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Sp Dev Site Scripts
Repository for sample SharePoint site designs and site scripts
Stars: ✭ 113 (+0%)
Mutual labels:  hacktoberfest

Tinseltown.js

Tinseltown is a small (< 4KB) JS and CSS front-end library to add faux flicker loading effects, a la Hollywood hacker movies, to various elements on a web page.

Visit the website for a demo. Or clone this repo and take a look at examples/basic.html.

Tinseltown uses CSS animations for the effects themselves, but needs to have a small JavaScript component (< 1KB) to actually make it work. What makes these effects work is randomness. When the animations aresec initiated, they are given random animation-delay values as offsets; otherwise they would all play in sync, invalidating the purpose.

Getting Started

The easiest method is to simply drop the compiled tinseltown.min.js and tinseltown.min.css files from the root folder of this repo into the front-end of whatever web project you are working on. You can now skip to the Usage section and use everything as-is.

Customizing Animation Timings (Advanced)

It is possible to use Sass variables to customize animation timings if you want to dive deeper and only use this library for its randomization features.

In your Sass file, set any of the variables in the following example to CSS time values of your choice before importing tinseltown.min.css.

$tnsl-flicker-duration: 1s;             // default 0.5s
$tnsl-flickerQuick-duration: 0.5s;      // default 0.2s
$tnsl-slideFromLeft-duration: 0.2s;     // default 0.1s
$tnsl-slideFromRight-duration: 0.2s;    // default 0.1s

@import 'tinseltown.scss'               // place *after* overriden variables

Note: The default values above were chosen to look good when used with the default maxDelay value of 1 second and vice versa.

Of course, feel free to download the tinseltown.scss file directly from the src folder in this repo and place it in your project.

Usage

Once the JS and CSS files are available to use in your project's front-end, use the following CSS classes to set animations.

tnsl-flicker            // standard Hollywood-style flicker effect
tnsl-flickerQuick       // shorter variant of flicker
tnsl-slideFromLeft      // quick slide from left (using translate3d(-100%, 0, 0))
tnsl-slideFromRight     // quick slide from right (using translate3d(100%, 0, 0))

In many cases, however, your design may benefit from some randomness. This is why a special, random animation class is included as well.

tnsl-random

When you trigger the basic case (described in the next section), all elements with the tnsl-random class are first randomly assigned one of the above animation classes before playing. Every time the page loads, your tnsl-random classes may get a different set of effects.

Basic Trigger

Once you are ready to trigger the animations, call

tnslInit([maxDelay])

where maxDelay is the longest time (in seconds) that you want to allow any single animation-delay value to be.

This means that the start of each effect will be between 0 and maxDelay seconds from when the function is called. This does not guarantee that all the effects will be spread across the first maxDelay seconds, because randomness can still cause them to bunch up and trigger in the first second... or even half that.

You can omit the argument if you want, and a default of 1 second will be used.

Note: The default animation timings in the compiled CSS were tuned to look good when used with the default maxDelay value of 1 second and vice versa.

If you want to trigger the animations at page load time, simply use

window.onload = function() { tnslInit(); }      // without jQuery
$(document).ready(function() { tnslInit(); });  // with jQuery

or otherwise add the function call to whatever handles your page load scripts.

More Granular Control (Advanced)

If you want more granular control over the animations on your page, you can use some convenient utility functions included in Tinseltown.

tnslReplaceRandom([animations])

Processes all elements that have the tnsl-random class, assigning them random animations.

Optionally provide it an array of animation names, esp. if you do not want it to assign a certain animation or two. Pick from strings flicker, flickerQuick, slideFromLeft and slideFromRight. All animations used if no argument given.

Note: It's highly recommended that you process any tnsl-random elements before calling animation functions, or they will simply not be animated. Calling animation trigger functions before and after processing all randoms may cause all animations to play twice, unless you perform JavaScript trickery to prevent this.

The maxDelay argument

For info on the optional maxDelay argument accepted by the following functions, refer to the Basic Trigger section.

tnslPlayFlicker([maxDelay])

Triggers all flicker animations.

tnslPlayFlickerQuick([maxDelay])

Triggers all flickerQuick animations.

tnslPlaySlideFromLeft([maxDelay])

Triggers all slideFromLeft animations.

tnslPlaySlideFromRight([maxDelay])

Triggers all slideFromRight animations.

tnslPlayAllFlicker([maxDelay])

Triggers all flicker and flickerQuick animations.

tnslPlayAllSlide([maxDelay])

Triggers all slideFromLeft and slideFromRight animations.

tnslPlayAll([maxDelay])

Triggers all animations.

tnslInit([maxDelay])

Processes all tnsl-random elements and triggers all animations.

Contribute

Tinseltown.js could use some help. If you find issues, or just want to contribute improvements, feel free to clone, modify, test and send pull requests. When developing locally:

  1. Have Node.js and npm installed.
  2. Clone this repo and run npm install at the top level.
  3. Edit src/tinseltown.js and src/tinseltown.scss.
  4. Run npx gulp to build the tinseltown.min.* files (do not edit these files directly). Optionally, run npx gulp watch to update the minified files as you make your edits in src.
  5. Open example/basic.html in your browser or import these minified files into your own local HTML file to test visually.

You can contact me @Antrikshy or via private messaging on reddit.

Potential Features

  1. Add support for scrolling. It would be nice to either support scroll-activated animation triggers natively, or at least allow users to trigger all animations inside a supplied DOM element, so that they can set it up themselves.
  2. Maybe allow users to select a random flicker animation only or slide animation only.
  3. Come up with more hacker-style CSS animations.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].