5.0.1 • Published 6 years ago

rocket-flicker v5.0.1

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
6 years ago

Rocket Flicker

A module that lets you flick through content.

Getting Started

Install via NPM.

npm install rocket-flicker

NOTE that this module has a dependency Rocket Tools (28kb) which will automatically be installed as well.

Start by including the necessary files.

<head>
   <link href="node_modules/rocket-flicker/css/flicker.min.css" rel="stylesheet" type="text/css">
</head>
<body>
   /* Your content goes here */
   <script src="node_modules/rocket-tools/js/tools.min.js"></script>
   <script src="node_modules/rocket-flicker/js/flicker.min.js"></script>
</body>

Basic Example

See the setup of the HTML and Javascript call below.

<div class="mod-flicker">
   <ul>
      <li data-background="image-url.jpg">
         <div class="mod-flicker-title">Example Heading</div>
         <div class="mod-flicker-text">Sub Text</div>
      </li>
      <li data-background="image-url.jpg">
         <div class="mod-flicker-title">Example Heading</div>
         <div class="mod-flicker-text">Sub Text</div>
      </li>
   </ul>
</div>

<script>
Rocket.flicker();
</script>

Initialisation

Each initialisation will return an array of module objects (An array will always be returned even if the target is an id). This includes the flicker element itself as well as relevant methods. For example:

const flickers = Rocket.flicker();

// The flickers and all methods
for (let i = 0, len = flickers.length; i < len; i++) {
   console.log(flickers[i].flicker);
   flickers[i].move(3); // Move this flicker to position 3
   flickers[i].start(); // Start the auto flicker
   flickers[i].stop(); // Stop the auto flicker
}

Alternatively if you know the target is unique you can reference the flicker right away with the 0 index. For example:

const myFlicker = Rocket.flicker({
   target: '#flicker'
})[0]; // Reference the first item in the array right away.

myFlicker.stop();

Options

See the different options you have available on initialization.

NameDefaultOptionsDescription
target.rocket-flickerSet the flicker target elements.
animationtransformslidetransformslide transitionfade transitionslideChoose the animation type you want.
arrowstruetrue falseArrows are used to navigate back and forth between the flicks.
arrowsConstraintfalsetrue falseWhen you get to the end of the flicks pressing the next arrow will navigate you to the beginning again should you have a false constraint. The same applies to the previous arrow.
autoFlicktruetrue falseSets the flick to run automatically. A manual flick resets the delay.
autoFlickDelay10Set the delay (in seconds) between each auto flick.
dotAlignmentcentercenter left rightSet the horizontal alignment of the dot navigation.
dotstruetrue falseDot navigation is used to indicate and navigate between the flicks.
pauseOnHoverfalsetrue falsePause / Stop the autoFlick on hover. Restart it again when the mouse leaves.
position1Set the starting flick.

Defaults

You can also overwrite the module options globally by altering the defaults. To do so reference the defaults object property. For example:

Rocket.defaults.flicker.autoFlickDelay = 20;
Rocket.defaults.flicker.dots = false;

Advanced Example

See an advanced example below with options as per the above.

const myFlicker = Rocket.flicker({
   target: '.flicker-example',
   animation: 'transitionfade',
   autoFlick: false,
   dotAlignment: 'right'
});

Make It Touch Enabled

To make your flicker touch enabled, just included the Hammer library (Rocket Flicker comes with a copy). For example:

<body>
   /* Your content goes here */
   <script src="node_modules/rocket-flicker/js/hammer-v2.0.3.min.js"></script>
   <script src="node_modules/rocket-tools/js/tools.min.js"></script>
   <script src="node_modules/rocket-flicker/js/flicker.min.js"></script>
</body>

Flickerplate Deprecated

The original library, Flickerplate, has been deprecated. The entire Webplate project is being refactored and rebranded with a new development philosophy. Flickerplate will be maintained only with bug fixes under the flickerplate branch.

Author

Created and maintained by Chris Humboldt Website: chrishumboldt.com Twitter: twitter.com/chrishumboldt GitHub github.com/chrishumboldt

Contributors

dsuket

Copyright and License

Copyright 2018 Rocket Project

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

5.0.1

6 years ago

5.0.0

6 years ago

4.4.1

7 years ago

4.4.0

7 years ago

4.3.0

7 years ago

4.2.2

7 years ago

4.2.1

7 years ago

4.2.0

7 years ago

4.1.1

7 years ago

4.1.0

7 years ago

4.0.7

7 years ago

4.0.6

7 years ago

4.0.5

8 years ago

4.0.4

8 years ago

4.0.3

8 years ago

4.0.1

8 years ago

4.0.0

8 years ago