Giter Site home page Giter Site logo

cube3power / space.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gopatrik/space.js

0.0 1.0 0.0 8.01 MB

A HTML-driven JavaScript-library for narrative 3D-scrolling.

Home Page: www.slashie.org/space.js

License: MIT License

CSS 46.35% HTML 41.77% JavaScript 11.88%

space.js's Introduction

Space.js

A HTML-driven JavaScript-library for narrative 3D-scrolling.

See the demos here

NOTE THAT SHOULD BE CONSIDERED TO BE BETA SOFTWARE Production use is not recommended at this point.

Usage

Import the library

<head>
	<script type="text/javascript" src="[jquery]"></script>
	...
</head>
<body>
	[Your contents]
	<script type="text/javascript" src="space.min.js"></script>
</body>

The library is HTML-driven, which means that you don't need to write a single line of JavaScript to use it on your site and still have a lot of flexibility!

The core of the library is to divide our HTML into frames, or space-frames as we call them her (to not conflict the common class name "frame").

Creating a frame

<div class="space-frame">[contents]</div>

I would also strongly recommend using an inner-frame inside the space-frame, which provides some helpful CSS to make things centered both vertically and horizontally inside the frame.

<div class="space-frame">
	<section class="space-inner-frame">
		[contents]
	</section>
</div>

Custom duration

If we want we can provide a custom duration for our frames with the data-duration attribute, which multiplies the default duration of the transition.

<section class="space-frame" data-duration="1.4">...</section>
<section class="space-frame" data-duration="0.6">...</section>

Options

Space.js has a default default transition - which is to enter by fading in and exit by scaling up and fading out. We can also provide a custom transition override to the library from predefined transitions. (We can also create our own transitions from scratch, but we'll get to that later.)

<section class="space-frame" data-transition="rotate360">...</section>

Multiple values are supported!

<section class="space-frame" data-transition="rotate360 fadeOut slideInLeft">...</section>

Custom entry and exit

If we really want to get into detail, we can provide how we wish the frame to enter (first half of the frame duration) and exit (second half).

<section class="space-frame" data-enter="fadeIn" data-exit="fadeOut zoomOut">...</section>

What a complete frame could look like

<div class="space-frame" data-enter="fadeIn" data-exit="zoomOut fadeOut" data-duration="1.3">
	<section class="space-inner-frame">
		<div style="background-image:url(img/splash.png); padding:150px 200px;" class="bg">
			<section>
				<p>Demo 1</p>
				<h1>The Gallery</h1>
			</section>
		</div>
	</section>
</div>

Custom transitions

You can add your own transitions with the ```addTransitions`` method. Make sure it is done after the library is loaded.

<script src="space.js"></script>

<script type="text/javascript">
	var transitions = {
		rotate720: {
			'rotate':{from:0, to:720}
		},
		fadeOutHalf: {
			'opacity':{from:1, to:0.5}
		}
	};
	Space.addTransitions(transitions);
</script>

Currently supported transitions

Note that these might come to change during the beta-phase of the library.

  • scaleIn
  • fadeIn
  • scaleOut
  • fadeOut
  • rotateQuarterRight
  • rotateInQuarterClockwise
  • zoomOut
  • slideInBottom
  • slideOutDown
  • slideOutLeft
  • slideOutRight
  • slideInRight
  • slideOutUp
  • slideInTop
  • slideInLeft
  • slideBottomRight
  • rotate360
  • rotate3dOut

space.js's People

Contributors

gopatrik avatar albert-iv avatar

Watchers

 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.