GithubHelp home page GithubHelp logo

plainspace / dom-animator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tholman/dom-animator

0.0 2.0 0.0 195 KB

A nifty javascript library to run animations, hidden in comment nodes, within the dom.

Home Page: http://tholman.com/dom-animator/

CSS 15.15% HTML 46.68% JavaScript 38.17%

dom-animator's Introduction

Dom Animator

A nifty JavaScript library, used to show small ascii animations within comments in your dom. It's a little easter egg for anyone inspecting your code. Nothing more, nothing less.

Instructions

dom-animator.js is a stand alone library (no jQuery, or the likes) so usage is pretty straight forward. You won't need any CSS, or HTML... just JavaScript. (since the animations live in comment nodes, in the dom, only)

JS

DomAnimator.js can be simple, or complex, depending on what you're trying to achieve with your animation. You'll need to create a new instance of domanimator (having already included the script in the page). Here is the most simple example, a winking face.

<script>
	var domAnimator = new DomAnimator();
	domAnimator.addFrame('o_o');
	domAnimator.addFrame('-_o');
	domAnimator.animate();
</script>

The above animation, exists on a single line. If you want multiple levels, you can pass in a list of strings to the frame. Or include your own carriage returns (\n's)

<script>
	var domAnimator = new DomAnimator();
	domAnimator.addFrame(['0_0', ' | ', ' | ']);
	domAnimator.addFrame(['0_-', ' | ', ' | ']);
	domAnimator.animate();
</script>

If you like, you can set the one speed, for all of the frames. Otherwise they will default to 500ms intervals. (these are ascii animations, no need for 60fps)

<script>
	var domAnimator = new DomAnimator();
	domAnimator.addFrame('o_o');
	domAnimator.addFrame('-_o');
	domAnimator.animate(1000); //ms
</script>

If you want to stop the animation, for any given reason, just call stop

<script>
	// Setup
	var domAnimator = new DomAnimator();
	domAnimator.addFrame('o_o');
	domAnimator.addFrame('-_o');
	domAnimator.animate();

	// After 10 seconds.
	setTimeout(function() {
		domAnimator.stop(); // Stop the animation
	}, 10000);
</script>

Examples / In the wild!

You can see the animation in the console on the demo page. There's also a video, if you're really confused.

###Browser support

Dom Animator has been tested in the latest stable builds of Safari, Chrome & Firefox... Chrome displays the a little cleaner, since it supports newlines in the console. But all the browsers work.

License

The MIT License (MIT)

Copyright (C) 2015 ~ Tim Holman ~ [email protected]

dom-animator's People

Contributors

tholman avatar jackrugile avatar

Watchers

Jared avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.