Coder Social home page Coder Social logo

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

Stargazers

Elvis avatar leeho avatar Mya Lau avatar  avatar  avatar  avatar  avatar 宝昌 avatar Sah Utsiev avatar Tasuhanov Muhammad avatar Heesu Jung avatar scart88 avatar Ramya Mahendran avatar champion avatar pedoc avatar LGD.HuaFEEng avatar  avatar Henry Walton avatar  avatar Kohei Ito avatar  avatar Scott Boudreaux avatar  avatar Yottaline avatar rob bee avatar yatohiyori avatar hiragiayako  avatar Vijay avatar  avatar Ali Malik avatar  avatar bstone avatar Antonio Lima avatar jarzzzi avatar seyyah avatar C avatar Eugenio Cervantes avatar  avatar Ramaseshan S avatar Bo Zhao avatar Bogdan avatar Maria Paras avatar Swimmer avatar 马 avatar Dillon Burns avatar 老C(ㆁωㆁ*)²³³ avatar Andrei Ruban avatar Insecteens avatar Sam avatar Mohan Liu avatar Mohammadreza moghimi avatar Marvin avatar Dallington Augusto avatar Bao Quoc Doan avatar arkii avatar  avatar Mimi Kim avatar Hazrat Gadjikerimov avatar  avatar Tony Yet avatar  avatar  avatar LittleWisdom avatar 谢瑞卿 avatar Ahmed Noor E Alam avatar Brian Faust avatar Rita Zerrizuela avatar Roy Jossfolk avatar  avatar Federico avatar  avatar zhai avatar  avatar Vignesh M avatar Hiten Sharma avatar  avatar  avatar Anton Vasiliev avatar Suchan An avatar ThanhHt avatar Vemula Vamshi Krishna avatar  avatar Pascal Tbf avatar KATO Kei avatar Theresa Ma avatar  avatar Sahil Kapur avatar zhangmz avatar Andrew Heinke avatar Donar Development avatar Jonathan Zúñiga avatar Keron avatar  avatar Alex Shchekin avatar John Gracey avatar Michael avatar Alucard avatar Luiz Jacques avatar Eric Butler avatar Kitisak Thossaensin avatar

Watchers

evandrix avatar iamist avatar yury avatar MTX avatar Alexandre Enkerli avatar Fred avatar Nemesis Fixx Da JWL avatar Jenux avatar Luiz Jacques avatar Christian Knappke avatar Jirka Dvorak avatar Jonath Lee Eng Sing avatar  avatar  avatar SUGAWARA Masaya avatar James Cloos avatar Emiliya Sokolova avatar Ladislav Soukup avatar Manoela Ilic avatar Purusothaman Ramanujam avatar Carlos Olmos avatar shenzlx avatar  avatar Yahia Mansouri avatar Hsuching avatar Michael Anthony avatar mori avatar Emmanuel Ulloa Arguello avatar Takayuki Kumagai avatar  avatar Fx_demon avatar Yared Getachew avatar Francisco J Casillas avatar  avatar Alexandro avatar Whoami avatar  avatar Duy Ngo avatar Thanh Le avatar 斐龙 avatar  avatar Sergei Topunov avatar Nikolay Viknyansky avatar  avatar Ivan avatar kale avatar Mykhailo Hladchenko avatar  avatar  avatar Veritas IRB Inc. avatar  avatar Gregory Farley avatar Vemula Vamshi Krishna avatar  avatar  avatar

space.js's Issues

Accessibility considerations: Screenreaders

Use of display: none removes an element from not just being seen visually, but also from a screenreader like VoiceOver or JAWS. In order to accommodate these users we need to use one of two methods:

  1. Use the clipping method mentioned in this article: http://a11yproject.com/posts/how-to-hide-content/, on scrolling into view by the non-SR user we simple remove the .visually-hidden class at the same time it is currently made display: block (recommended method)
  2. Using ARIA Live Regions to inform the user that new content is on the screen when the new frame is made visible. While this controls the story a bit more, it is more complicated to implement and you'd be doing this primarily for people who can't see the story reveal process.

Nav menu?

Hi... Very nice work!
Is it possible to use a navigation menu in addition to scroll, to reach a specific frame?

What is the license applied to this repo?

Hi,

I cannot see any license. Can you add the license which apply to this repository? if it's one, can you make it clear in the README or adding a LICENSE file?

Many thanks.

Demo 2 typo

Heya, you misspelled where as were at the end of Demo 2.

Bind to custom selector?

Heyyo, this plugin looks awesome. Quick q: is there an option to use space.js with a custom selector? It's a pretty common jQuery plugin pattern, I believe. Just for clarity, I'm imagining something along these lines:

$('.custom-spaceframe-class').space()

or by overriding the plugin's default options, like:

$.space({
   selector: '.custom-spaceframe-class'
});

Any chance this is possible, or will be implemented at some future point? Maybe I missed something in the documentation, or possibly I'm just being dumb! But I'd appreciate being pointed in the right direction, or really any input/advice! Thanks.

Space as a react component

Have you thought about making space.js into a react component? For a sample of such a conversion checkout react-swipe below. If there is interest then I would like to contribute further ideas on how to create a innovative UI navigation solution.

https://github.com/jed/react-swipe

Scroll speed on touch devices

On desktop, demo 1 seems a little fast, but on an iPhone (Safari) it's super fast and you have to concentrate to not blow past the content. I assume speed can be controlled, but is there any way to fix this (perceived) disparity between desktop and mobile scroll speeds? I wouldn't want to slow down Desktop so much that the effect is diminished.

Last space-frame remains stuck at opacity: 0.6257

Space.js rocks, and though it's been said it's not "ready" for production, well, it's too cool not to put to use already! However, I have so far encountered this problem while using space.js on an experimental rendering of a e-book here.

In this book, each chapter is nested inside of

 <div class="space-frame" data-enter="fadeIn" data-exit="zoomOut fadeOut" data-duration="1">
     <section class="space-inner-frame">
             <!--  chapter goes here -->
     </section>
 </div>

But what I have noticed, is that upon reaching the very last chapter (without even attempting to scroll beyond it), it is rendered/displayed with nonoptimal opacity - this last .space-frame is stuck at opacity: 0.6257;.

Can't it progress to opacity:1; once we've hit the very last .space-frame? Or is this a feature?

Checkout the book linked above, and scroll to the last chapter to see my concern. Otherwise, I see lots of potential in this technology!


Oh, btw, could I remedy this by omitting the fadeOut on the very last space-frame?

Transition "Wiggling" in Chrome

Thanks for making space.js! I've been testing it out, and I wanted to note a visual glitch I see in Chrome, but not Firefox:

<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <script type="text/javascript" src="jquery-2.0.2.min.js"></script>
  </head>
  <body>
    <div class="space-frame" data-duration="1">
      <section class="space-inner-frame">
        <!-- Clear frame -->
      </section>
    </div>

    <div class="space-frame" data-enter="fadeIn" data-exit="fadeOut" data-transition="fadeIn" data-duration="5">
      <section class="space-inner-frame">
        <p>Demo 1</p>
      </section>
    </div>

    <div class="space-frame" data-enter="slideInRight" data-transition="rotate360" data-duration="5">
      <section class="space-inner-frame">
        <p>Demo 2</p>
      </section>
    </div>

    <div class="space-frame" data-enter="slideInLeft" data-transition="rotate360" data-duration="5">
      <section class="space-inner-frame">
        <p>Demo 3</p>
      </section>
    </div>

    <script type="text/javascript" src="space.min.js"></script>
  </body>
</html>

The text tends to "wiggle" up and down while scrolling to the 2nd and 3rd transitions, and I'm trying to hone down what's causing it.

Multiple frames

Hi,
is there any way to create two frames animated at the same time? For example, two elements that goes in different direction or one frame that stays longer on the screen while others appear.

Thanks and great work!

A little more time between transitions?

Is there a way to leave the content hanging on the screen a while longer before transitioning out? In poking around based on the demos, it starts to exit just as soon as it has finished entering. We'd like a little more time to see, read, etc without having to scroll too slowly.

Thanks!

Accessibility considerations: on/off switch

First, let me say this is well done and I really like it. But as a developer who suffers from a vestibular disorder and motion sickness, this kind of framework can cause physical pain to users.

I am recommending giving the user some control in case they, like me, can get sick with this kind of animation. The simple solution is including a switch in the framework rendered to the screen (preferably at the top) where the user can turn off the animation. When off all the content is stacked as it would be by default and all space-frame elements would be display: block and visible. This then lets the user still get the story experience while not becoming ill from motion.

I have a simple switch prototype I made on Codepen

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.