Skip to content

Commit

Permalink
Merge branch 'master' into unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
taye committed Nov 4, 2017
2 parents 9bce799 + b292cf2 commit c3e9da1
Show file tree
Hide file tree
Showing 24 changed files with 236 additions and 172 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Upcoming Changes
## v1.3.0

Most notably:

Expand All @@ -9,8 +9,7 @@ Most notably:
- `Interactable` - `squareResize`, `snap`, `restrict`, `inertia`,
`autoScroll`, `accept`, `dropzone` - `interact` - `enabbleDragging`,
`enableResizing`, `enableGesturing`, `margin`
- new `delay` option for starting actions
([f688eba](https://github.com/taye/interact.js/commit/f688eba))
- new `hold` option for starting actions
- new `interaction.end()` method
([df963b0](https://github.com/taye/interact.js/commit/df963b0))
- `snap.offset` `self` option ([issue
Expand Down
9 changes: 7 additions & 2 deletions build/docs.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
const fs = require('fs-extra');
const destination = require('../jsdoc.conf').opts.destination;
const path = require('path');

const confPath = require.resolve('../docs/jsdoc.conf');
const destination = path.join(confPath, '..', require(confPath).opts.destination);

module.exports = ({ stdio = 'inherit' } = {}) => {
process.stdout.write('Docs...');

fs.removeSync(destination);
fs.copySync('img', `${destination}/img`);

require('child_process').spawnSync('jsdoc', ['-c', 'jsdoc.conf.js'], {
stdio,
cwd: 'docs',
});

fs.copySync('img', `${destination}/img`);

console.log(' done.');
};

Expand Down
3 changes: 2 additions & 1 deletion build/pre-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ fi
npm run build || exit $?

# commit and add new version tag
git commit -m "v$NEW_VERSION" -- package.json dist
git add -- package.json distc
git commit -m "v$NEW_VERSION"
git tag $NEW_TAG

# push branch and tags to git origin and publish to npm
Expand Down
4 changes: 2 additions & 2 deletions jsdoc-index.md → docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# API Reference

<img
style="background-color: #272822; display: block; margin: auto; max-height: 8em; width: 100%"
alt="interact.js"
src="img/ijs-anim-short.svg">

# API Reference
13 changes: 8 additions & 5 deletions jsdoc.conf.js → docs/jsdoc.conf.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
module.exports = {
source: {
include: ['src'],
include: ['../src'],
},

opts: {
destination: 'dist/docs/',
readme: 'jsdoc-index.md',
destination: '../dist/docs/',
recurse: true,
template: 'node_modules/minami',
},

plugins: ['plugins/markdown'],
plugins: [
'plugins/markdown',
'jsdoc-stale',
],

markdown: {
idInHeadings: true,
},

articles: ['**/*.md'],

templates: {
cleverLinks: true,
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
"fs-extra": "^4.0.2",
"husky": "^0.13.1",
"istanbul": "^0.4.5",
"jsdoc": "^3.5.5",
"jsdoc": "github:taye/jsdoc#master",
"jsdoc-stale": "github:taye/jsdoc-stale#master",
"jsdom": "^9.11.0",
"lodash": "^3.10.1",
"minami": "^1.2.3",
"mkdirp": "^0.5.1",
"semver": "^5.3.0",
"tap-spec": "^4.1.1",
Expand Down
3 changes: 3 additions & 0 deletions src/InteractEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const defaults = require('./defaultOptions');
const signals = require('./utils/Signals').new();

class InteractEvent {
/** */
constructor (interaction, event, action, phase, element, related, preEnd = false) {
const target = interaction.target;
const deltaSource = (target && target.options || defaults).deltaSource;
Expand Down Expand Up @@ -131,10 +132,12 @@ class InteractEvent {

preventDefault () {}

/** */
stopImmediatePropagation () {
this.immediatePropagationStopped = this.propagationStopped = true;
}

/** */
stopPropagation () {
this.propagationStopped = true;
}
Expand Down
4 changes: 1 addition & 3 deletions src/Interactable.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ const { wheelEvent } = require('./utils/browser');
// all set interactables
scope.interactables = [];

/**
* Object type returned by {@link interact}
*/
class Interactable {
/** */
constructor (target, options) {
options = options || {};

Expand Down
53 changes: 29 additions & 24 deletions src/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let prevTouchTime = 0;
scope.interactions = [];

class Interaction {
/** */
constructor ({ pointerType }) {
this.target = null; // current interactable being interacted with
this.element = null; // the target element of the interactable
Expand Down Expand Up @@ -94,19 +95,7 @@ class Interaction {
}

/**
* Start an action with the given Interactable and Element as tartgets. The
* action must be enabled for the target Interactable and an appropriate
* number of pointers must be held down - 1 for drag/resize, 2 for gesture.
*
* Use it with `interactable.<action>able({ manualStart: false })` to always
* [start actions manually](https://github.com/taye/interact.js/issues/114)
*
* @param {object} action The action to be performed - drag, resize, etc.
* @param {Interactable} target The Interactable to target
* @param {Element} element The DOM Element to target
* @return {object} interact
*
* @example
* ```js
* interact(target)
* .draggable({
* // disable the default drag start by down->move
Expand All @@ -122,6 +111,19 @@ class Interaction {
* event.currentTarget);
* }
* });
* ```
*
* Start an action with the given Interactable and Element as tartgets. The
* action must be enabled for the target Interactable and an appropriate
* number of pointers must be held down - 1 for drag/resize, 2 for gesture.
*
* Use it with `interactable.<action>able({ manualStart: false })` to always
* [start actions manually](https://github.com/taye/interact.js/issues/114)
*
* @param {object} action The action to be performed - drag, resize, etc.
* @param {Interactable} target The Interactable to target
* @param {Element} element The DOM Element to target
* @return {object} interact
*/
start (action, target, element) {
if (this.interacting()
Expand Down Expand Up @@ -200,11 +202,7 @@ class Interaction {
}

/**
* Force a move of the current action at the same coordinates. Useful if
* snap/restrict has been changed and you want a movement with the new
* settings.
*
* @example
* ```js
* interact(target)
* .draggable(true)
* .on('dragmove', function (event) {
Expand All @@ -215,6 +213,11 @@ class Interaction {
* event.interaction.doMove();
* }
* });
* ```
*
* Force a move of the current action at the same coordinates. Useful if
* snap/restrict has been changed and you want a movement with the new
* settings.
*/
doMove (signalArg) {
signalArg = utils.extend({
Expand Down Expand Up @@ -255,12 +258,7 @@ class Interaction {
}

/**
* Stop the current action and fire an end event. Inertial movement does
* not happen.
*
* @param {PointerEvent} [event]
*
* @example
* ```js
* interact(target)
* .draggable(true)
* .on('move', function (event) {
Expand All @@ -271,6 +269,12 @@ class Interaction {
* event.stopImmediatePropagation();
* }
* });
* ```
*
* Stop the current action and fire an end event. Inertial movement does
* not happen.
*
* @param {PointerEvent} [event]
*/
end (event) {
event = event || this.prevEvent;
Expand All @@ -293,6 +297,7 @@ class Interaction {
return this._interacting;
}

/** */
stop () {
signals.fire('stop', { interaction: this });

Expand Down
21 changes: 10 additions & 11 deletions src/actions/drag.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/** @module */

const actions = require('./base');
const utils = require('../utils');
const InteractEvent = require('../InteractEvent');
Expand Down Expand Up @@ -82,15 +80,7 @@ InteractEvent.signals.on('new', function ({ iEvent, interaction }) {
});

/**
* Get or set whether drag actions can be performed on the target
*
* @param {boolean | object} [options] true/false or An object with event
* listeners to be fired on drag events (object makes the Interactable
* draggable)
* @return {boolean | Interactable} boolean indicating if this can be the
* target of drag events, or this Interctable
*
* @example
* ```js
* interact(element).draggable({
* onstart: function (event) {},
* onmove : function (event) {},
Expand All @@ -116,6 +106,15 @@ InteractEvent.signals.on('new', function ({ iEvent, interaction }) {
* });
*
* var isDraggable = interact('element').draggable(); // true
* ```
*
* Get or set whether drag actions can be performed on the target
*
* @param {boolean | object} [options] true/false or An object with event
* listeners to be fired on drag events (object makes the Interactable
* draggable)
* @return {boolean | Interactable} boolean indicating if this can be the
* target of drag events, or this Interctable
*/
Interactable.prototype.draggable = function (options) {
if (utils.is.object(options)) {
Expand Down
40 changes: 21 additions & 19 deletions src/actions/drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,27 @@ function fireDropEvents (interaction, dropEvents) {
}

/**
* ```js
* interact(target)
* .dropChecker(function(dragEvent, // related dragmove or dragend event
* event, // TouchEvent/PointerEvent/MouseEvent
* dropped, // bool result of the default checker
* dropzone, // dropzone Interactable
* dropElement, // dropzone elemnt
* draggable, // draggable Interactable
* draggableElement) {// draggable element
*
* return dropped && event.target.hasAttribute('allow-drop');
* }
* ```
*
* ```js
* interact('.drop').dropzone({
* accept: '.can-drop' || document.getElementById('single-drop'),
* overlap: 'pointer' || 'center' || zeroToOne
* }
* ```
*
* Returns or sets whether draggables can be dropped onto this target to
* trigger drop events
*
Expand Down Expand Up @@ -297,25 +318,6 @@ function fireDropEvents (interaction, dropEvents) {
*
* @param {boolean | object | null} [options] The new options to be set.
* @return {boolean | Interactable} The current setting or this Interactable
*
* @example
* interact(target)
* .dropChecker(function(dragEvent, // related dragmove or dragend event
* event, // TouchEvent/PointerEvent/MouseEvent
* dropped, // bool result of the default checker
* dropzone, // dropzone Interactable
* dropElement, // dropzone elemnt
* draggable, // draggable Interactable
* draggableElement) {// draggable element
*
* return dropped && event.target.hasAttribute('allow-drop');
* }
*
* @example
* interact('.drop').dropzone({
* accept: '.can-drop' || document.getElementById('single-drop'),
* overlap: 'pointer' || 'center' || zeroToOne
* }
*/
Interactable.prototype.dropzone = function (options) {
if (utils.is.object(options)) {
Expand Down
17 changes: 9 additions & 8 deletions src/actions/gesture.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,7 @@ InteractEvent.signals.on('new', function ({ iEvent, interaction }) {
});

/**
* Gets or sets whether multitouch gestures can be performed on the target
*
* @param {boolean | object} [options] true/false or An object with event
* listeners to be fired on gesture events (makes the Interactable gesturable)
* @return {boolean | Interactable} A boolean indicating if this can be the
* target of gesture events, or this Interactable
*
* @example
* ```js
* interact(element).gesturable({
* onstart: function (event) {},
* onmove : function (event) {},
Expand All @@ -74,6 +67,14 @@ InteractEvent.signals.on('new', function ({ iEvent, interaction }) {
* });
*
* var isGestureable = interact(element).gesturable();
* ```
*
* Gets or sets whether multitouch gestures can be performed on the target
*
* @param {boolean | object} [options] true/false or An object with event
* listeners to be fired on gesture events (makes the Interactable gesturable)
* @return {boolean | Interactable} A boolean indicating if this can be the
* target of gesture events, or this Interactable
*/
Interactable.prototype.gesturable = function (options) {
if (utils.is.object(options)) {
Expand Down
Loading

0 comments on commit c3e9da1

Please sign in to comment.