Coder Social home page Coder Social logo

rehabstudio / rehab-saucyjack Goto Github PK

View Code? Open in Web Editor NEW
0.0 21.0 0.0 52 KB

Scroll position detection and triggering module, for simple scroll-triggered CSS animations and transitions.

License: MIT License

JavaScript 77.17% HTML 8.34% CSS 14.49%

rehab-saucyjack's Introduction

SaucyJack

What is it?

SaucyJack is a scroll position detection & triggering module. Example available to view here.

Usage

// require SausyJack module
var SaucyJack = require('../path/to/saucy-jack.js');

// Optional options
var options = {
    DEBUG: false,
    TRIGGER_LINE_POS: 0.85,
    ENTITY_SELECTOR: '.saucy-el',
    ACTIVE_CLASS: 'saucy-active',
    INVERT_BEHAVIOUR: false,
}

saucyJack = new SaucyJack.SaucyJack(options);

Methods

saucyJack.addElement(el)

Adds an element that triggers the event when this element enters the trigger zone.

Compiling

Install requirements using the following from the terminal in the project root directory:

npm install

SaucyJack is build using ES2015. To compile to ES5 compatible code use the following from the :

npm run compile

This will create both a /dist/build.js and /dist/build.min.js file, an un compressed file for development and a minified and uglified version for production.

Example

An example file is available in /example/index.html. To compile the latest version of the module code use:

npm run compile-example

To compile /src/saucy-jack.js for both the example and development/production use:

npm run compile-all

Testing

SaucyJack come with complete unit testing and code coverage. Tests are created in the /tests/spec.js file. To run the test use:

npm test

This will create a basic report in the terminal showing if any tests have failed and the total code coverage. To view the full coverage report open /tests/test-results/html/index.html

rehab-saucyjack's People

Contributors

adamatrehabstudio avatar njmcode avatar

Watchers

Peter Gasston avatar robotlabs avatar Josh Noble avatar Eoghan O'Keeffe avatar James Cloos avatar  avatar  avatar Roger Simms avatar Rafael Magalhaes avatar Mark McConnell avatar Mick Coelho avatar Daniel Skelton avatar 0800robin avatar Juan Camilo Rojas avatar  avatar Lucas Lucas avatar Kirsty McCrystal avatar Ciaran Hurley avatar Caroline Wilson avatar  avatar  avatar

rehab-saucyjack's Issues

Reformat options object & reduce code duplication in constructor

The options are formatted constant-style e.g. ENTITY_SELECTOR, when they should really be camelCased e.g. entitySelector. Probably worth renaming them too.

Also the code that applies the passed options or the defaults in the constructor is too repetitive. Need to clean this up.

Add option to trigger from center or bottom edge of elements

The current behaviour reads the top edge position of affected elements. Would like an option to allow triggering to happen from the bottom edge or the center of elements instead.

The option should be global and affect the behaviour of the library for all elements. We can look at allowing this to be specified per-element later.

Nicer example page

Needs a more involved and sexy-looking example than what we currently have. :)

Add inline styles to debug element

The 'debug line' has no styling applied by default so it doesn't behave as expected.

Need to add some inline styling when the debug line is created in order for it to be seen.

[API design] Per-element options

Want to be able to specify things like trigger point and other options on a per-element basis.

Potential options:

  • trigger point ('top' [default], 'center', 'bottom', percentile, or pixel value)
  • class to add/remove
  • multiple trigger point logic e.g. 'add class X when top edge passed, remove it when bottom edge passed'
  • single-use triggers vs re-triggerable
  • callbacks/events to fire when trigger points are hit

Implementation ideas:

  • data- params on DOM elements
  • Additional param to addElement passing in extra options
  • Additional methods to manipulate element options after registration

Ideas wanted!

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.