0.5.5 • Published 5 years ago

gyrobackground v0.5.5

Weekly downloads
14
License
MIT
Repository
github
Last release
5 years ago

Installation

npm

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

builds

<script src="https://unpkg.com/gyrobackground@0.5.5/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

OptionTypeDefault ValueDescription
parallaxBooleanfalseEnable parallax on devices that don't have WebVR support.
parallaxSpeedFloat-2How slow/fast the image moves while scrolling
sensitivityFloat0.5The "image's" responsiveness to movement.
landscapeSensitivityFloatsensitivityThe "image's" responsiveness to movement when the device is in landscape mode.
portraitSensitivityFloatsensitivityThe "image's" responsiveness to movement when the device is in portrait mode.
zoomint0This value is added to the camera's z-distance from the image.
landscapeZoomint0This value is added to the camera's z-distance when the device is in landscape mode.
portraitZoomint0This value is added to the camera's z-distance when the device is in portrait mode.
offsetXint0The image's offset from the auto-calculated X position.
portraitOffsetXintoffsetXThe image's offset from the auto-calculated X position when the device is in portrait mode.
landscapeOffsetXintoffsetXThe image's offset from the auto-calculated X position when the device is in landscape mode.
offsetYint0The image's offset from the auto-calculated Y position.
portraitOffsetYintoffsetYThe image's offset from the auto-calculated Y position when the device is in portrait mode.
landscapeOffsetYintoffsetYThe image's offset from the auto-calculated Y position when the device is in landscape mode.
invertedBooleanfalseReverse movement on the X & Y axis.
visualizeBooleanfalseShow a 3D representation of the phone's original position vs current.
classNameStringnulladd a css class to identify the parallax containers

Library Credits