Code Monkey home page Code Monkey logo

gyrobackground's Introduction

Gyroscopic Background Images

This is a javascript library that uses the WebVR API to create web backgrounds that move with your phone. I have a vision for it to be the next "parallax" of the web. Feel free to contribute!

license version

Only supported on WebVR compatible devices.

Installation

npm

npm install --save gyrobackground
# Or yarn add gyrobackground
require('gyrobackground')  // e.g., with Browserify or Webpack.

builds

<script src="https://unpkg.com/[email protected]/dist/gyroBackground.min.js"></script>

Local Development

git clone https://github.com/Tino-F/gyroBackground.git  # Clone the repository.
cd gyroBackground && npm install  # Install dependencies.
npm start  # Start the local development server.

Generating builds

>npm run build

Usage

//new GyroBackground( containerEl, imageURL, options )

var background = new GyroBackground('#myImage', 'imgs/4.jpg', {
  sensitivity: 3,
  parallax: true,
  parallaxSpeed: -4
});

Methods

.add( imageURL, config )

This method allows you to add multiple images with different settings to the same target element.

.visualize()

Displays a visualization on the Phone relative to it's orientation when GyroBackground was initialized.

Config options

Option Type Default Value Description
parallax Boolean false Enable parallax on devices that don't have WebVR support.
parallaxSpeed Float -2 How slow/fast the image moves while scrolling
sensitivity Float 0.5 The "image's" responsiveness to movement.
landscapeSensitivity Float sensitivity The "image's" responsiveness to movement when the device is in landscape mode.
portraitSensitivity Float sensitivity The "image's" responsiveness to movement when the device is in portrait mode.
zoom int 0 This value is added to the camera's z-distance from the image.
landscapeZoom int 0 This value is added to the camera's z-distance when the device is in landscape mode.
portraitZoom int 0 This value is added to the camera's z-distance when the device is in portrait mode.
offsetX int 0 The image's offset from the auto-calculated X position.
portraitOffsetX int offsetX The image's offset from the auto-calculated X position when the device is in portrait mode.
landscapeOffsetX int offsetX The image's offset from the auto-calculated X position when the device is in landscape mode.
offsetY int 0 The image's offset from the auto-calculated Y position.
portraitOffsetY int offsetY The image's offset from the auto-calculated Y position when the device is in portrait mode.
landscapeOffsetY int offsetY The image's offset from the auto-calculated Y position when the device is in landscape mode.
inverted Boolean false Reverse movement on the X & Y axis.
visualize Boolean false Show a 3D representation of the phone's original position vs current.
className String null add a css class to identify the parallax containers

Donations

BTC: 14QoRj5Ex5aHCNhJGMoZZ5P9BsLY1a4dfu

XMR: 49pgRecAfychSR9dhd7gQyiaZjQGJyt6B1hVxJdGYYvmRR7VAJurDFSE3qZeui1AFAENKRw8EiB9nc5AYBPSBwrP9uSE9g2

Library Credits

gyrobackground's People

Contributors

tino-f avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

deawx zmania

gyrobackground's Issues

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.