1.3.5 • Published 7 years ago

exploded-dom-js v1.3.5

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

exploded-dom-js

A light-weight JavaScript library that adds simple, interactive 3D layering effects to HTML elements based on the cursor position.

NPM

How to include?

npm install exploded-dom-js

Demo

Example Gif

How to use?

ExplodedDOMJS.initialise(options, parent)

You can have multiple exploded views on the same page. The benefit of this library over a traditional canvas-based one is that the display elements are not obfuscated into a rendering pipeline, but instead leverage CSS 3D transformations (see support) on regular HTML elements.

Structure

Parents

To the element containing the item(s) you wish to add the effect to, add the class ed-parent.

Children

To the element(s) that you wish to animate, add the class ed-child-z, with z denoting their depth as an index.

Triggers

By default, animation will occur on the parent element, however you can define a bounding rect to the parent by enclosing it with an element classed as el-trigger

Example

trigger
    parent
        child
        child
        child
        ...

Style

For 3D effects, Parents should have a transform-origin and perspective, both parents and children should have transform-style: preserve-3d. These will default in CSS.

Absolute positioning of these elements will help prevent unexpected behaviour.

Options

Initialise takes an optional object containing options that affect how the DOM elements should appear and animate. There are accessor methods for all of the fields of these classes (let your IDE do its magic!).

There are also some templates for options in ExplodedDOMJS.SETTINGS:

  • DEFAULT
  • PARALLAX_X
  • PARALLAX_Y
FieldTypeDefaultDescription
triggerClassstring'ed-trigger'The class name identifying triggers for mouse events to nested parents.
parentsClassstring'ed-parent'The class name identifying parent containers.
childClassstring'ed-child'The class name identifying children of parents.
maxRotateYnumber10The maximum amount of vertical rotation in degrees to pitch a parent view.
maxRoateXnumber-20The maximum amount of horizontal rotation in degrees to yaw a parent view.
maxSlideYnumber0The maximum amount of vertical translation in pixels to move children within a parent view.
maxSlideXnumber0The maximum amount of vertical translation in pixels to move children within a parent view.
layerDepthnumber20The pixel value denoting the gap between layers (higher produces more extreme effect).
is3dbooleantrueAllow translation of child elements along the z-axis.
animatebooleantrueAllow animation of element.

Other Useful Methods

MethodDescription
getParentsReturns all parent views.
getChildrenReturns all child view.

Distributed under MIT license (see LICENSE), 2017, Josh Hills

1.3.5

7 years ago

1.3.4

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago