Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modularize the codebase and use ES6 features with Babel+browserify+gulp build #231

Merged
merged 141 commits into from
Oct 7, 2015

Conversation

taye
Copy link
Owner

@taye taye commented Jul 15, 2015

This branch splits the monolithic ./interact.js file into separate modules to be bundled together with browserify. It also makes actions (drag, resize, gesture), modifiers (snap, restrict), pointerEvents (down, tap, hold, etc.) and autoScroll optional and provides interfaces for adding new actions and modifiers.

An internal signals API been introduced which allows modules to hook into various points in the codebase without tight coupling, eg.:

signals.on('interactable-new', function (arg) { ... });

// in Interactable constructor
signals.fire('interactable-new', {
    interactable: this,
    element: element,
    options: options,
    win: _window
});

Eslint is now used for style checking instead of JSHint and the formatting style of the project has been changed. Most notably:

  • 2-space indentation instead of 4
  • the use of various ES6 features (see .babelrc)
  • let and const instead of var
  • only one let/const per identifier
  • multi-line trailing commas

One-time setup:

  • install Node.js if you don't have it
  • clone the interact.js repository
  • enter the directory into which it was cloned
  • on the command line, run npm install to install interact.js' development dependencies

To build interact.js, run:

npm run build

This will generate the following files in the ./dist directory:

interact.js
interact.js.map
interact.min.js
interact.min.js.map

Many thanks to @stephen-james for his help!

Closes #110

stephen-james and others added 30 commits May 25, 2015 12:18
…nd karma for testing

(this commit is scaffolding only and does not aim to split interact into modules)

- move interact.js source to a `src` folder and introduce a `build` folder
- get existing tests to run (mostly) with browserified karma, configured for mocha, chai and using fixture for html fixtures
- add dependencies for `gulp-starter` based build process
- remove icon font tasks from gulp process, while the others may be useful for docs/demo's folders, we won't be needing icons
events
extend
arr - indexOf, contains
domObjects - document, Element, etc.
isType - isArray, isString, isWindow, etc.
extract `Interaction` and `InteractionEvent` to modules
A subjective change, but takes out the repetition of `module.exports.`, may make it easier to grok
Since `typeof` always returns a string (ie. `typeof someUndefinedVar` renders `"undefined"`) we'll need to check against `"undefined"` not `undefined`
replaced with references to `browser`, `isType` and `InteractEvent`
Again a subjective change, but by having exports statements in conditional blocks it makes it unclear what values are being exported by the module, making it necessary to read all the code to get a grasp of what is happening.  Effectively, exporting inside conditionals is adding cyclomatic complexity to the module definition, its much clearer to the reader of the module if they can look in a single literal and see what they can expect to get from the module.

Cleaned up the Shadow DOM check to make it more self explanatory
getTouchPair, touchAngle, touchAverage, touchBBox, touchDistance
Requires changes from the next commit.
Replace getInteractionFromPointer with utils/interactionFinder module:

    interaction = finder.search(pointer, eventType, eventTarget);
@taye taye merged commit 24d31ea into master Oct 7, 2015
@taye taye deleted the modularization branch October 8, 2015 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants