diff --git a/.browserslistrc b/.browserslistrc
new file mode 100644
index 000000000..f13183ef8
--- /dev/null
+++ b/.browserslistrc
@@ -0,0 +1,2 @@
+defaults and fully supports es6-module
+node >= 16
\ No newline at end of file
diff --git a/.codeclimate.yml b/.codeclimate.yml
new file mode 100644
index 000000000..657ec0641
--- /dev/null
+++ b/.codeclimate.yml
@@ -0,0 +1,25 @@
+plugins:
+ eslint:
+ enabled: false
+ channel: eslint-6
+ extensions:
+ - .ts
+ - .js
+ duplication:
+ enabled: false
+ config:
+ languages:
+ - javascript
+ - typescript
+
+ratings:
+ paths:
+ - "packages/**/*.ts"
+
+exclude_paths:
+ - "**/examples/"
+ - "**/build/"
+ - "**/docs/"
+ - "**/_*"
+ - "**/*.spec.ts"
+ - "**/*.d.ts"
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 000000000..ee5c3201a
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,4 @@
+dist
+coverage
+**/node_modules/**
+_angular
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
new file mode 100644
index 000000000..3eda457dc
--- /dev/null
+++ b/.eslintrc.cjs
@@ -0,0 +1,109 @@
+module.exports = {
+ extends: [
+ 'plugin:import/errors',
+ 'plugin:import/warnings',
+ 'plugin:import/typescript',
+ 'plugin:react/all',
+ 'standard',
+ 'prettier',
+ ],
+ settings: {
+ 'import/resolver': { typescript: null },
+ react: { version: '16' },
+ },
+ env: {
+ commonjs: true,
+ es6: true,
+ node: true,
+ },
+ parser: '@typescript-eslint/parser',
+ parserOptions: {
+ sourceType: 'module',
+ ecmaVersion: 2020,
+ },
+ plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc', 'markdown'],
+ globals: {
+ globalThis: false,
+ },
+ rules: {
+ 'linebreak-style': ['error', 'unix'],
+ 'lines-between-class-members': 'off',
+ 'no-caller': 'error',
+ 'no-console': 'off',
+ 'no-empty': 'off',
+ 'no-prototype-builtins': 'off',
+ 'no-shadow': 'error',
+ 'no-useless-constructor': 'off',
+ 'no-var': 'error',
+ 'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
+ 'import/order': [
+ 'error',
+ {
+ alphabetize: { order: 'asc', caseInsensitive: true },
+ 'newlines-between': 'always',
+ groups: ['builtin', 'external', 'internal', 'parent', 'index', 'sibling'],
+ pathGroups: [{ pattern: '@interactjs/**', group: 'internal' }],
+ },
+ ],
+ 'operator-linebreak': 'off',
+ 'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
+ 'prefer-const': 'error',
+ 'standard/array-bracket-even-spacing': 'off',
+ 'standard/computed-property-even-spacing': 'off',
+ 'standard/object-curly-even-spacing': 'off',
+ 'tsdoc/syntax': 'warn',
+ '@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
+ '@typescript-eslint/consistent-type-imports': 'error',
+ '@typescript-eslint/explicit-member-accessibility': 'off',
+ '@typescript-eslint/member-accessibility': 'off',
+ '@typescript-eslint/no-empty-interface': 'error',
+ '@typescript-eslint/no-inferrable-types': 'error',
+ '@typescript-eslint/no-use-before-define': 'off',
+ },
+ overrides: [
+ {
+ files: '*.{ts{,x},vue}',
+ rules: {
+ 'import/named': 'off',
+ 'import/no-named-as-default': 'off',
+ 'import/no-unresolved': 'off',
+ 'no-redeclare': 'off',
+ 'no-shadow': 'off',
+ 'no-undef': 'off',
+ 'no-unused-vars': 'off',
+ 'no-use-before-define': 'off',
+ },
+ },
+ {
+ files: '{,.md/}*.vue',
+ extends: ['plugin:vue/vue3-essential'],
+ parserOptions: { parser: '@typescript-eslint/parser' },
+ },
+ {
+ files: '*.spec.ts',
+ extends: ['plugin:jest/recommended', 'plugin:jest/style'],
+ rules: {
+ 'array-bracket-spacing': 'off',
+ 'import/no-extraneous-dependencies': 'off',
+ 'jest/consistent-test-it': ['error', { fn: 'test' }],
+ },
+ },
+ { files: '**/*.md', processor: 'markdown/markdown' },
+ {
+ files: '**/*.md/*.{{ts,js}{,x},vue}',
+ rules: {
+ 'arrow-parens': 'off',
+ 'import/no-named-as-default': 'off',
+ 'import/no-unresolved': 'off',
+ 'no-console': 'off',
+ 'no-redeclare': 'off',
+ 'no-shadow': 'off',
+ 'no-undef': 'off',
+ 'no-unused-vars': 'off',
+ 'no-use-before-define': 'off',
+ 'no-var': 'off',
+ 'prefer-arrow-callback': 'off',
+ },
+ },
+ ],
+}
diff --git a/.github/stale.yml b/.github/stale.yml
new file mode 100644
index 000000000..d70c4b5ed
--- /dev/null
+++ b/.github/stale.yml
@@ -0,0 +1,19 @@
+# Number of days of inactivity before an issue becomes stale
+daysUntilStale: 14
+# Number of days of inactivity before a stale issue is closed
+daysUntilClose: 7
+# Issues with these labels will never be considered stale
+exemptLabels:
+ - pinned
+ - security
+only: issues
+# Label to use when marking an issue as stale
+staleLabel: stale
+# Comment to post when marking an issue as stale. Set to `false` to disable
+markComment: >
+ This issue has been automatically marked as stale because it has not had
+ recent activity. It will be closed if no further activity occurs. Thank you
+ for your contributions.
+# Comment to post when closing a stale issue. Set to `false` to disable
+closeComment: false
+exemptProjects: true
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 000000000..3dc13be0a
--- /dev/null
+++ b/.github/workflows/publish.yml
@@ -0,0 +1,28 @@
+on:
+ push:
+ branches:
+ - main
+ - next
+
+jobs:
+ test:
+ uses: ./.github/workflows/test.yml
+
+ publish-npm:
+ name: '๐ฆ Build and Publish ๐'
+ needs: [test]
+ runs-on: ubuntu-latest
+ environment: production
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v4
+ with:
+ node-version-file: '.nvmrc'
+ registry-url: https://registry.npmjs.org/
+ cache: yarn
+ - name: โ bootstrap
+ run: 'npm run bootstrap && git fetch --tags'
+ - name: ๐ฆ build and publish ๐
+ run: npx _release
+ env:
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 000000000..bf05e68af
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,20 @@
+on:
+ pull_request:
+ workflow_dispatch:
+ workflow_call:
+
+jobs:
+ test:
+ name: '๐งช Test'
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: ianwalter/playwright-container@43940dfa7d309fe3569b9df407ae9e84dcbf2e7f
+ - name: โ bootstrap
+ run: 'npm run bootstrap && npx _check_deps && npx _add_plugin_indexes'
+ - name: ๐ types
+ run: npx tsc -b -f
+ - name: ๐ lint
+ run: npx _lint
+ - name: ๐งช tests
+ run: npm test
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..ff3700d55
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,30 @@
+*.d.ts
+*.d.ts.map
+!interactjs/index.d.ts
+!shims.d.ts
+packages/@interactjs/**/index.ts
+packages/@interactjs/*/use/**/*.ts
+!packages/@interactjs/types/index.ts
+!packages/@interactjs/interact/index.ts
+!packages/@interactjs/interactjs/index.ts
+!packages/@interactjs/rebound/index.ts
+packages/**/*.js
+packages/**/*.js.map
+!packages/@interactjs/dev-tools/babel-plugin-prod.js
+node_modules
+!test/fixtures/**/node_modules
+dist
+.projectroot
+.env
+.envrc
+.nyc_output
+yarn-error.log
+.yarn-cache
+.pnpm-store
+npm-debug.log
+pnpm-debug.log
+coverage
+cc-test-reporter
+lerna-debug.log
+.vim
+.cjsescache
\ No newline at end of file
diff --git a/.husky/.gitignore b/.husky/.gitignore
new file mode 100644
index 000000000..31354ec13
--- /dev/null
+++ b/.husky/.gitignore
@@ -0,0 +1 @@
+_
diff --git a/.husky/pre-commit b/.husky/pre-commit
new file mode 100755
index 000000000..d2ae35e84
--- /dev/null
+++ b/.husky/pre-commit
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+yarn lint-staged
diff --git a/.npmignore b/.npmignore
index 0ac2dd313..d5cdeb8b3 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,5 +1,7 @@
-.git*
-demo/
-docs/
-img/
-test/
+*.ts
+!*.d.ts
+*.map.*
+*.spec.ts
+*.spec.js
+dist/docs
+guide
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 000000000..13e187a19
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1,3 @@
+link-workspace-packages = true
+shared-workspace-lockfile = true
+prefer-frozen-lockfile = true
diff --git a/.nvmrc b/.nvmrc
new file mode 100644
index 000000000..790e1105f
--- /dev/null
+++ b/.nvmrc
@@ -0,0 +1 @@
+v20.10.0
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 000000000..5bcb6fe81
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,3 @@
+dist
+coverage
+node_modules
diff --git a/.prettierrc.json b/.prettierrc.json
new file mode 100644
index 000000000..ce263c63e
--- /dev/null
+++ b/.prettierrc.json
@@ -0,0 +1,6 @@
+{
+ "printWidth": 110,
+ "semi": false,
+ "singleQuote": true,
+ "trailingComma": "all"
+}
diff --git a/.stylelintrc.cjs b/.stylelintrc.cjs
new file mode 100644
index 000000000..365cb852f
--- /dev/null
+++ b/.stylelintrc.cjs
@@ -0,0 +1,4 @@
+module.exports = {
+ extends: ['stylelint-config-standard', 'stylelint-config-recess-order', 'stylelint-config-css-modules'],
+ ignoreFiles: ['dist/**/*', 'coverage/**/*'],
+}
diff --git a/.yarnrc b/.yarnrc
new file mode 100644
index 000000000..142dad817
--- /dev/null
+++ b/.yarnrc
@@ -0,0 +1 @@
+registry "https://registry.npmjs.org"
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 000000000..b48a59f2b
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,847 @@
+## v1.10.27
+
+- fix(types): fix issues with `skipLibCheck: false`
+
+## v1.10.26
+
+- fix: improve build; check output for ES2018 compatibility
+
+## v1.10.25
+
+- fix: bundle to ES5 syntax
+
+## v1.10.24
+
+- chore: generate api docs
+
+## v1.10.23
+
+- fix: transform nullish coalescing; fix symbol-tree build
+
+## v1.10.22
+
+- fix(actions/gesture): fix error when inertia is enabled for gestures #995
+
+## v1.10.21
+
+- fix(actions/drop): fix regression with drop event targets #1016
+
+## v1.10.20
+
+- fix(types): import plugins for module augmentations #933
+
+## v1.10.19
+
+- fix(core/scope): remove duplicate Interactable super.unset
+- fix(utils/pointerExtend): skip all vendor-prefixed props. Close #978
+
+## v1.10.18
+
+- fix(interact): remove types dependency
+- fix: set "type": "module" for scoped packages
+- fix(modifiers): allow toggling aspectRatio modifier during interaction
+- fix(types): import plugins for module augmentations
+- fix(interactjs): don't assign module.exports in esm package
+
+## v1.10.17
+
+- fixed missing typings when only the `@interactjs/interactjs` package is
+ installed and imported
+- added index to vue package for installing with side effect import
+
+## v1.10.16
+
+- remove vue and react deps fron pro `@interactjs/interactjs` package
+
+## v1.10.15
+
+- fixed an issue with broken `@interactjs/types` #972
+
+## v1.10.14
+
+- fixed an issue with iframes on Webkit #942. Thanks, @tulps, for PR #943
+- fixed top-right and bottom-left resizing with aspectRatio with sub-modifiers #944. Thanks again, @tulps, for PR #963
+- fixed typings for `@itneractjs/` scoped module packages #933
+- added `doubletap.double === true` event prop for consistency with `tap.double`
+- fixed a bug with calling `interactable.unset()` in a `drop` listener #919
+
+## v1.10.13
+
+- Added `.d.ts` files to all `@interactjs/*` packages
+
+## v1.10.12
+
+- fixed incorrect behaviour when `interactable.unset()` is called multiple
+ times
+
+## v1.10.11
+
+- fixed incorrect "module" field in package.json https://github.com/taye/interact.js/issues/894#issuecomment-811046898
+
+## v1.10.10
+
+- fixed issue with unresolved stub files #894
+- fixed commonjs import of `interactjs` package
+
+## v1.10.9
+
+- improved support for SSR environments
+
+## v1.10.8
+
+- fixed imports of missing modules #891
+
+## v1.10.7
+
+- correctly replace `process.env.npm_package_version` in min bundle #890
+
+## v1.10.6
+
+- fix packaging error
+
+## v1.10.5
+
+- fix packaging error
+
+## v1.10.4
+
+- fix NPE in indexOfDeepestElement if first element has no parent #887
+- improve babel-plugin-prod on windows #885
+
+## v1.10.3
+
+- fixed issue with TS strict null checks #882
+- fixed issue with type imports being emitted in JS modules #881
+
+## v1.10.2
+
+- marked interact.{on,off} methods as deprecated
+
+## v1.10.1
+
+- fixed mouseButtons option typings #865
+- removed plugin index module warnings
+
+## v1.10.0
+
+- changed production files extension from '.min.js' to '.prod.js' #857
+- added experimental `@interactjs/dev-tools/babel-plugin-prod` babel plugin to
+ change `@interactjs/*` imports to production versions
+- added `sideEffects` fields to package.json files
+
+## v1.9.22
+
+- fixed inertia issue with arbitrary plugin order #834
+- fixed inertia regression #853
+
+## v1.9.21
+
+- used findIndex polyfill to support 1E11 #852
+- fixed issue where resize reflow increased element size #817
+- fixed drop event order: fire `dropmove` after `dragenter` #841 and final
+ drop events before `dragend` #842
+- updated docs #844 #829
+
+## v1.9.20
+
+- fixed ordering of plugins
+
+## v1.9.19
+
+- exposed `DropEvent` type
+
+## v1.9.18
+
+- fixed further issues with types
+
+## v1.9.17
+
+- fixed missing types for interactjs package
+
+## v1.9.16
+
+- fixed missing types for interactjs package
+
+## v1.9.15
+
+- fixed missing types for interactjs package
+
+## v1.9.15
+
+- fixed further regression breaking typescript builds #816
+
+## v1.9.14
+
+- fixed regression breaking typescript builds #816
+
+## v1.9.13
+
+- fixed regression breaking es5 compatibility of .min.js bundle #814
+
+## v1.9.12
+
+- fixed regression breaking commonjs imports withotu .default
+
+## v1.9.11
+
+- fixed issue with missing width/height on rectChecker result
+- fixed resize checker with negative sizes
+- moved generated plugin use modules to @interactjs/_/{use/,}_/index.ts #800
+- changed snap function args to provide interaction proxy
+- restored dev-tools helpers in development bundle
+
+## v1.9.10
+
+- fixed issue with uninitialized scope in non browser env #803
+
+## v1.9.9
+
+- fixed typescript issue #807
+
+## v1.9.8
+
+- fixed minified bundle #802
+- fixed issue with removing delegated events #801
+
+## v1.9.7
+
+- fixed typing issues
+
+## v1.9.6
+
+- improved package dependencies
+
+## v1.9.5
+
+- made `core` and `utils` packages dependencies of `interact`
+
+## v1.9.4
+
+- restored `@interactjs/*/use/*.js*` builds
+
+## v1.9.2
+
+- fixed imports within generated modules
+
+## v1.9.1
+
+- added `@interactjs/*/use/*.min.js` builds
+- fixed issue with webpack minifier #800
+- fixed typescript issues
+
+## v1.9.0
+
+- added various `@interactjs/*/use` packages for simpler selective imports
+ #800
+- fixed endOnly modifiers without inertia
+
+## v1.8.5
+
+- fixed a but causing incorrect modifications after resuming inertia #790
+
+## v1.8.4
+
+- fixed bug when calling interaction.move() from start event #791
+
+## v1.8.3
+
+- fixed bug when calling interaction.move() from start event #791
+- fixed invalid non-array argument spread types #789
+- fixed missing typescript definition of some interactable methods #788
+- disabled `.d.ts.map` files output since the `.ts` source files are not
+ published
+- fixed typings for modifiers
+
+## v1.8.2
+
+- enabled `.d.ts.map` files output
+- added license field to @interactjs/interact package.json
+
+## v1.8.1
+
+- fixed an issue causing flickering a cursor on Firefox for Windows #781
+
+## v1.8.0
+
+Changes from prerelease versions listed below. See
+https://github.com/taye/interact.js/projects/4#column-7093512 for a list of
+issues and pull requests.
+
+## v1.8.0-rc.3
+
+- fixed incorrect publish
+
+## v1.8.0-rc.2
+
+- refactoring
+
+## v1.8.0-rc.1
+
+- fixed `interact.snappers.grid` arg typings
+ (https://twitter.com/ksumarine/status/1204457347856424960)
+- removed "?" from definitions for interact.{modifiers,snappers,createSnapGrid}
+
+## v1.8.0-rc.0
+
+- fixed `modifiers.restrictSize` #779
+- fixed option types in typescript and fixed devTools options #776
+
+## v1.8.0-alpha.7
+
+- reverted to typescript@3.6 to avoid backwards compatibility issues #775
+
+## v1.8.0-alpha.6
+
+- fixed dev scripts
+
+## v1.8.0-alpha.5
+
+- moved `interact.dynamicDrop` definition in order to avoid compilation errors
+
+## v1.8.0-alpha.4
+
+- added `main` field to interactjs package.json #774
+- removed baseUrl from project tsconfig to avoid relative imports in generated
+ declarations
+
+## v1.8.0-alpha.3
+
+- added missing typescript declaration files
+
+## v1.8.0-alpha.2
+
+- used non relative imports in .ts files with correct config for
+ babel-plugin-bare-import-rewrite
+
+## v1.8.0-alpha.1
+
+- added `event.modifiers` array #772
+
+## v1.8.0-alpha.0
+
+- added `aspectRatio` modifier #638
+
+## v1.7.4
+
+- fixed `interact.snappers.grid` arg typings
+ (https://twitter.com/ksumarine/status/1204457347856424960)
+- removed "?" from definitions for interact.{modifiers,snappers,createSnapGrid}
+
+## v1.7.3
+
+- fixed interactjs package main and browser fields #774
+- reverted to typescript@3.6 to avoid backwards compatibility issues #775
+
+## v1.7.2
+
+- fixed typescript definition files #771
+
+## v1.7.1
+
+- reorganized modules for esnext resolution
+
+## v1.7.0
+
+- fixed hold repeat `event.count`
+- added esnext js builds #769
+
+## v1.6.3
+
+- fixed issue with inertia resume with `endOnly: false` #765
+
+## v1.6.2
+
+- @mlucool added license field to package.json of sub modules #755
+- added `rect`, `deltaRect` and `edges` to resizestart and resizeend events #754
+
+## v1.6.1
+
+- fixed resize without invert
+
+## v1.6.0
+
+- avoided accessing deprecated event.mozPressure #751
+- changed typings to use `HTMLElement | SVGElement` for `event.target` #747
+- added `interacting` arg to cursorChecker #739
+- added zIndex compare for sibling dropzones
+
+## v1.5.4
+
+- fixed broken modifiers #746
+
+## v1.5.3
+
+- fixed issues with old modifiers API
+
+## v1.5.2
+
+- fixed null restriction issue #737
+- improved typings for modifiers
+
+## v1.5.1
+
+- fixed typing issues #738
+
+## v1.5.0
+
+- added `cursorChecker` option for drag and resize #736
+- allowed restrictions larger than the target element #735
+- added `interact.modifiers.restrictRect` with pre-set elementRect #735
+
+## v1.4.14
+
+- fixed issue with string restriction values that don't resolve to a rect
+ #731
+- changed plugin order so that `pointer-events` is installed before `inertia`
+
+## v1.4.13
+
+- fixed restrictSize min and max function restrictions
+
+## v1.4.12
+
+- fixed errors from calling `interaction.stop()` in start event #725
+
+## v1.4.11
+
+- fixed hold events #730
+
+## v1.4.10
+
+- fixed regression of preventing native drag behaviour #729
+
+## v1.4.9
+
+- fixed modifiers with inertia action-resume #728
+- fixed docs for snap grid limits #717
+
+## v1.4.8
+
+- fixed exports in generated typings #727
+
+## v1.4.7
+
+- fixed exports in generated typings #726
+
+## v1.4.6
+
+- fixed pointerEvents currentTarget
+
+## v1.4.5
+
+- @0xflotus fixed typos in docs #724
+- fixed error on iOS #682
+
+## v1.4.4
+
+- fixed an issue with interactions lingering on removed elements #723
+
+## v1.4.3
+
+- destroy only relevant interactions on interactable.unset()
+
+## v1.4.2
+
+- @jf-m fixed memory leaks and a bug on interactions stop [PR #715](https://github.com/taye/interact.js/pull/715)
+- fixed dropzones in shadow DOM [PR #722](https://github.com/taye/interact.js/pull/722)
+
+## v1.4.1
+
+- fixed scripts to run bundle optimizations and fix issues with browserify
+
+# v1.4.0
+
+Most notablly:
+
+- `interactable.reflow(action)` to re-run modifiers, drop, etc [PR #610](https://github.com/taye/interact.js/pull/610)
+- `dropEvent.reject()` [PR #613](https://github.com/taye/interact.js/pull/613)
+- snapEdges modifier [PR #620](https://github.com/taye/interact.js/pull/620)
+- per-action modifiers array [PR #625](https://github.com/taye/interact.js/pull/625)
+- autoStart set cursor on both target and <html> [PR #639](https://github.com/taye/interact.js/pull/639)
+- inertia: rename resume event to `${action}resume`
+- `interactable.reflow(action)` to re-run modifiers, drop, etc [PR #610](https://github.com/taye/interact.js/pull/610)
+- added `options.listeners` array/object for actions
+- `snapEdges` modifier [PR #620](https://github.com/taye/interact.js/pull/620)
+- fixed iOS preventDefault passive event issue ([issue #631](https://github.com/taye/interact.js/issues/631))
+- added `console.warn` messages for common, easily detected issues
+- improved docs
+- various fixes
+
+Full list of [changes on Github](https://github.com/taye/interact.js/compare/1.3.4...v1.4.0).
+
+## v1.3.3
+
+- fixed issues with action options ([PR #567](https://github.com/taye/interact.js/pull/567), [issue #570](https://github.com/taye/interact.js/issues/570))
+
+## v1.3.2
+
+- fixed iOS preventDefault passive event issue ([issue #561](https://github.com/taye/interact.js/issues/561))
+
+## v1.3.1
+
+- allowed calling `draggable.unset()` during `dragend` and `drop` event
+ listeners ([issue #560](https://github.com/taye/interact.js/issues/560))
+- allowed snap to be enabled with falsey targets value [issue #562](https://github.com/taye/interact.js/issues/562)
+
+## v1.3.0
+
+Most notably:
+
+- changed the npm and bower package names to "interactjs" ([issue
+ #399](https://github.com/taye/interact.js/issues/399)
+- major refactor with [PR #231](https://github.com/taye/interact.js/pull/231).
+- removed deprecated methods:
+ - `Interactable`: `squareResize`, `snap`, `restrict`, `inertia`,
+ `autoScroll`, `accept`
+ - `interact`: `enabbleDragging`, `enableResizing`, `enableGesturing`,
+ `margin`
+- new `hold` option for starting actions
+- new `interaction.end()` method
+ ([df963b0](https://github.com/taye/interact.js/commit/df963b0))
+- `snap.offset` `self` option ([issue
+ #204](https://github.com/taye/interact.js/issues/204/#issuecomment-154879052))
+- `interaction.doMove()`
+ ([3489ee1](https://github.com/taye/interact.js/commit/3489ee1))
+ ([c5c658a](https://github.com/taye/interact.js/commit/c5c658a))
+- snap grid limits
+ ([d549672](https://github.com/taye/interact.js/commit/d549672))
+- improved iframe support ([PR
+ #313](https://github.com/taye/interact.js/pull/313))
+- `actionend` event dx/dy are now `0`, not the difference between start and
+ end coords ([cbfaf00](https://github.com/taye/interact.js/commit/cbfaf00))
+- replaced drag `axis` option with `startAxis` and `lockAxis`
+- added pointerEvents options:
+ - `holdDuration`
+ ([1c58f92](https://github.com/taye/interact.js/commit/1c58f927)),
+ - `ignoreFrom` and `allowFrom`
+ ([6cbaad6](https://github.com/taye/interact.js/commit/6cbaad6d))
+ - `origin` ([7823bb9](https://github.com/taye/interact.js/commit/7823bb95))
+- action events set with action method options (eg.
+ `target.draggable({onmove})` are removed when that action is disabled with a
+ method call ([cca4e26](https://github.com/taye/interact.js/commit/cca4e260))
+- `context` option now works for Element targets
+ ([8f64a7a](https://github.com/taye/interact.js/commit/8f64a7a4))
+- added an action `mouseButtons` option and allowed actions only with the left
+ mouse button by default
+ ([54ebdc3](https://github.com/taye/interact.js/commit/54ebdc3e))
+- added repeating `hold` events
+ ([fe11a8e](https://github.com/taye/interact.js/commit/fe11a8e5))
+- fixed `Interactable.off` ([PR
+ #477](https://github.com/taye/interact.js/pull/477))
+- added `restrictEdges`, `restrictSize` and `snapSize` resize modifiers ([PR
+ #455](https://github.com/taye/interact.js/pull/455))
+
+Full list of [changes on Github](https://github.com/taye/interact.js/compare/v1.2.6...v1.3.0).
+
+## 1.2.6
+
+### resize.preserveAspectRatio
+
+```javascript
+interact(target).resizable({ preserveAspectRatio: true })
+```
+
+See [PR #260](https://github.com/taye/interact.js/pull/260).
+
+### Deprecated
+
+- `interact.margin(number)` - Use `interact(target).resizable({ margin: number });` instead
+
+### Fixed
+
+- incorrect coordinates of the first movement of every action ([5e5a040](https://github.com/taye/interact.js/commit/5e5a040))
+- warning about deprecated "webkitForce" event property ([0943290](https://github.com/taye/interact.js/commit/0943290))
+- bugs with multiple concurrent interactions ([ed53aee](http://github.com/taye/interact.js/commit/ed53aee))
+- iPad 1, iOS 5.1.1 error "undefined is not a function" when autoScroll is set
+ to true ([PR #194](https://github.com/taye/interact.js/pull/194))
+
+Full list of [changes on Github](https://github.com/taye/interact.js/compare/v1.2.5...v1.2.6)
+
+## 1.2.5
+
+### Changed parameters to actionChecker and drop.checker
+
+- Added `event` as the first argument to actionCheckers. See commit [88dc583](https://github.com/taye/interact.js/commit/88dc583)
+- Added `dragEvent` as the first parameter to drop.checker functions. See
+ commits [16d74d4](https://github.com/taye/interact.js/commit/16d74d4) and [d0c4b69](https://github.com/taye/interact.js/commit/d0c4b69)
+
+### Deprecated methods
+
+interactable.accept - instead, use:
+
+```javascript
+interact(target).dropzone({ accept: stringOrElement })
+```
+
+interactable.dropChecker - instead, use:
+
+```javascript
+interact(target).dropzone({ checker: function () {} })
+```
+
+### Added resize.margin
+
+See https://github.com/taye/interact.js/issues/166#issuecomment-91234390
+
+### Fixes
+
+- touch coords on Presto Opera Mobile - see commits [886e54c](https://github.com/taye/interact.js/commit/886e54c) and [5a3a850](https://github.com/taye/interact.js/commit/5a3a850)
+- bug with multiple pointers - see commit [64882d3](https://github.com/taye/interact.js/commit/64882d3)
+- accessing certain recently deprecated event properties in Blink - see
+ commits [e91fbc6](https://github.com/taye/interact.js/commit/e91fbc6) and [195cfe9](https://github.com/taye/interact.js/commit/195cfe9)
+- dropzones with `accept: 'pointer'` in scrolled pages on iOS6 and lower - see
+ commit [0b94aac](https://github.com/taye/interact.js/commit/0b94aac)
+- setting styleCursor through Interactable options object - see [PR
+ #270](https://github.com/taye/interact.js/pull/270)
+- one missed interaction element on stop triggered - see [PR
+ #258](https://github.com/taye/interact.js/pull/258)
+- pointer dt on touchscreen devices - see [PR
+ #215](https://github.com/taye/interact.js/pull/215)
+- autoScroll with containers with fixed position - see commit [3635840](https://github.com/taye/interact.js/commit/3635840)
+- autoScroll for mobile - see #180
+- preventDefault - see commits [1984c80](https://github.com/taye/interact.js/commit/1984c80) and [6913959](https://github.com/taye/interact.js/commit/6913959)
+- occasional error - see [issue
+ #183](https://github.com/taye/interact.js/issue/183)
+- Interactable#unset - see [PR
+ #178](https://github.com/taye/interact.js/pull/178)
+- coords of start event after manual start - see commit [fec73b2](https://github.com/taye/interact.js/commit/fec73b2)
+- bug with touch and selector interactables - see commit [d8df3de](https://github.com/taye/interact.js/commit/d8df3de)
+- touch doubletap bug - see [273f461](https://github.com/taye/interact.js/commit/273f461)
+- event x0/y0 with origin - see [PR
+ #167](https://github.com/taye/interact.js/pull/167)
+
+## 1.2.4
+
+### Resizing from all edges
+
+With the new [resize edges API](https://github.com/taye/interact.js/pull/145),
+you can resize from the top and left edges of an element in addition to the
+bottom and right. It also allows you to specify CSS selectors, regions or
+elements as the resize handles.
+
+### Better `dropChecker` arguments
+
+The arguments to `dropChecker` functions have been expanded to include the
+value of the default drop check and some other useful objects. See [PR
+161](https://github.com/taye/interact.js/pull/161)
+
+### Improved `preventDefault('auto')`
+
+If manuanStart is `true`, default prevention will happen only while
+interacting. Related to [Issue
+138](https://github.com/taye/interact.js/issues/138).
+
+### Fixed inaccurate snapping
+
+This removes a small inaccuracy when snapping with one or more
+`relativeOffsets`.
+
+### Fixed bugs with multiple pointers
+
+## 1.2.3
+
+### ShadowDOM
+
+Basic support for ShadowDOM was implemented in [PR
+143](https://github.com/taye/interact.js/pull/143)
+
+### Fixed some issues with events
+
+Fixed Interactable#on({ type: listener }). b8a5e89
+
+Added a `double` property to tap events. `tap.double === true` if the tap will
+be followed by a `doubletap` event. See [issue
+155](https://github.com/taye/interact.js/issues/155#issuecomment-71202352).
+
+Fixed [issue 150](https://github.com/taye/interact.js/issues/150).
+
+## 1.2.2
+
+### Fixed DOM event removal
+
+See [issue 149](https://github.com/taye/interact.js/issues/149).
+
+## 1.2.1
+
+### Fixed Gestures
+
+Gestures were completely [broken in
+v1.2.0](https://github.com/taye/interact.js/issues/146). They're fixed now.
+
+### Restriction
+
+Fixed restriction to an element when the element doesn't have a rect (`display: none`, not in DOM, etc.). [Issue
+144](https://github.com/taye/interact.js/issues/144).
+
+## 1.2.0
+
+### Multiple interactions
+
+Multiple interactions have been enabled by default. For example:
+
+```javascript
+interact('.drag-element').draggable({
+ enabled: true,
+ // max : Infinity, // default
+ // maxPerElement: 1, // default
+})
+```
+
+will allow multiple `.drag-element` to be dragged simultaneously without having
+to explicitly set max: integerGreaterThan1. The default
+`maxPerElement` value is still 1 so only one drag would be able to happen on
+each `.drag-element` unless the `maxPerElement` is changed.
+
+If you don't want multiple interactions, call `interact.maxInteractions(1)`.
+
+### Snapping
+
+#### Unified snap modes
+
+Snap modes have been
+[unified](https://github.com/taye/interact.js/pull/127). A `targets` array
+now holds all the snap objects and functions for snapping.
+`interact.createSnapGrid(gridObject)` returns a function that snaps to the
+dimensions of the given grid.
+
+#### `relativePoints` and `origin`
+
+```javascript
+interact(target).draggable({
+ snap: {
+ targets: [{ x: 300, y: 300 }],
+ relativePoints: [
+ { x: 0, y: 0 }, // snap relative to the top left of the element
+ { x: 1, y: 1 }, // and also to the bottom right
+ ],
+
+ // offset the snap target coordinates
+ // can be an object with x/y or 'startCoords'
+ offset: { x: 50, y: 50 },
+ },
+})
+```
+
+#### snap function interaction arg
+
+The current `Interaction` is now passed as the third parameter to snap functions.
+
+```js
+interact(target).draggable({
+ snap: {
+ targets: [
+ function (x, y, interaction) {
+ if (!interaction.dropTarget) {
+ return { x: 0, y: 0 }
+ }
+ },
+ ],
+ },
+})
+```
+
+#### snap.relativePoints and offset
+
+The `snap.relativePoints` array succeeds the snap.elementOriign object. But
+backwards compatibility with `elementOrigin` and the old snapping interface is
+maintained.
+
+`snap.offset` lets you offset all snap target coords.
+
+See [this PR](https://github.com/taye/interact.js/pull/133) for more info.
+
+#### slight change to snap range calculation
+
+Snapping now occurs if the distance to the snap target is [less than or
+equal](https://github.com/taye/interact.js/commit/430c28c) to the target's
+range.
+
+### Inertia
+
+`inertia.zeroResumeDelta` is now `true` by default.
+
+### Per-action settings
+
+Snap, restrict, inertia, autoScroll can be different for drag, restrict and
+gesture. See [PR 115](https://github.com/taye/interact.js/pull/115).
+
+Methods for these settings on the `interact` object (`interact.snap()`,
+`interact.autoScroll()`, etc.) have been removed.
+
+### Space-separated string and array event list and eventType:listener object
+
+```javascript
+function logEventType(event) {
+ console.log(event.type, event.target)
+}
+
+interact(target).on('down tap dragstart gestureend', logEventType)
+
+interact(target).on(['move', 'resizestart'], logEventType)
+
+interact(target).on({
+ dragmove: logEvent,
+ keydown: logEvent,
+})
+```
+
+### Interactable actionChecker
+
+The expected return value from an action checker has changed from a string to
+an object. The object should have a `name` and can also have an `axis`
+property. For example, to resize horizontally:
+
+```javascript
+interact(target)
+ .resizeable(true)
+ .actionChecker(function (pointer, defaultAction, interactable, element) {
+ return {
+ name: 'resize',
+ axis: 'x',
+ }
+ })
+```
+
+### Plain drop event objects
+
+All drop-related events are [now plain
+objects](https://github.com/taye/interact.js/issues/122). The related drag
+events are referenced in their `dragEvent` property.
+
+### Interactable.preventDefault('always' || 'never' || 'auto')
+
+The method takes one of the above string values. It will still accept
+`true`/`false` parameters which are changed to `'always'`/`'never'`.
+
+## 1.1.3
+
+### Better Events
+
+Adding a function as a listener for an InteractEvent or pointerEvent type
+multiple times will cause that function to be fired multiple times for the
+event. Previously, adding the event type + function combination again had no
+effect.
+
+Added new event types [down, move, up, cancel,
+hold](https://github.com/taye/interact.js/pull/101).
+
+Tap and doubletap with multiple pointers was improved.
+
+Added a workaround for IE8's unusual [dblclick event
+sequence](http://www.quirksmode.org/dom/events/click.html) so that doubletap
+events are fired.
+
+Fixed a [tapping issue](https://github.com/taye/interact.js/issues/104) on
+Windows Phone/RT.
+
+Fixed a bug that caused the origins of all elements with tap listeners to be
+subtracted successively as a tap event propagated.
+
+[Fixed delegated events](https://github.com/taye/interact.js/commit/e972154)
+when different contexts have been used.
+
+### iFrames
+
+[Added basic support](https://github.com/taye/interact.js/pull/98) for sharing
+one instance of interact.js between multiplie windows/frames. There are still
+some issues.
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
new file mode 100644
index 000000000..1eb380c50
--- /dev/null
+++ b/ISSUE_TEMPLATE.md
@@ -0,0 +1,14 @@
+If you have questions about the [API](http://interactjs.io/api) that aren't answered in the [docs](http://interactjs.io/docs) or [FAQ](http://interactjs.io/docs/faq), try asking in the [Gitter chatroom](https://gitter.im/taye/interact.js) or on [Stackoverflow](https://stackoverflow.com/questions/tagged/interact.js).
+
+If you've found something that looks like a bug, include a link to a minimal demo on [JSFilddle](https://jsfiddle.net), [Codepen](https://codepen.io) with instructions to reproduce the bug with and roughly follow the following issue description format:
+
+### Expected behavior
+Tell us what should happen
+
+### Actual behavior
+Tell us what happens instead
+
+### System configuration
+**interact.js version**:
+**Browser name and version**:
+**Operating System**:
diff --git a/LICENSE b/LICENSE
index 3d9c609db..e4854f77d 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2012, 2013, 2014 Taye Adeyemi
+Copyright (c) 2012-present Taye Adeyemi
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated
diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 000000000..12bf4d1bf
--- /dev/null
+++ b/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1 @@
+Make sure to include tests in your pull request.
diff --git a/README.md b/README.md
index 53e6f69ee..1824b547d 100644
--- a/README.md
+++ b/README.md
@@ -1,263 +1,108 @@
-
+
+
+
+ JavaScript drag and drop, resizing and multi-touch gestures with inertia and snapping for modern browsers (and also IE9+).
+
+
+
+
+
+
+
+
+
+
+Features include:
+
+- **inertia** and **snapping**
+- **multi-touch**, simultaneous interactions
+- cross browser and device, supporting the **desktop and mobile** versions of
+ Chrome, Firefox and Opera as well as **Internet Explorer 9+**
+- interaction with [**SVG**](http://interactjs.io/#use_in_svg_files) elements
+- being **standalone and customizable**
+- **not modifying the DOM** except to change the cursor (but you can disable
+ that)
+
+## Installation
+
+- [npm](https://www.npmjs.org/): `npm install interactjs`
+- [jsDelivr CDN](https://cdn.jsdelivr.net/npm/interactjs/): ``
+- [unpkg CDN](https://unpkg.com/interactjs/): ``
+- [Rails 5.1+](https://rubyonrails.org/):
+ 1. `yarn add interactjs`
+ 2. `//= require interactjs/interact`
+- [Webjars SBT/Play 2](https://www.webjars.org/): `libraryDependencies ++= Seq("org.webjars.npm" % "interactjs" % version)`
+
+### Typescript definitions
+
+The project is written in Typescript and the npm package includes the type
+definitions, but if you need the typings alone, you can install them with:
-Javascript drag and drop, resizing and gestures for modern desktop and mobile browsers.
-
-Awesomeness includes:
-
- - **inertia**
- - [**snapping**](http://interactjs.io/repo/demo/snap.html) to a grid, custom
- anchors or paths.
- - cross browser and device, supporting the **desktop and mobile** versions of
- Chrome, Firefox and Opera as well as **Internet Explorer 8+**
- - interaction with [**SVG**](http://interactjs.io/repo/demo/star.svg) elements
- - being **lightweight and standalone** (not _yet another_ jQuery plugin)
- - **not modifying anything** it doesn't own (except to support IE8 and to
- change the cursor (but you can disable that))
-
-Demos
------
-
- - http://interactjs.io has some demos showing drag and drop, gestures,
- inertia, snap and some other things.
- - The [html & svg demo](http://interactjs.io/repo/demo/html_svg.html "drag, drop,
- resize and gesture demo") shows div elements which can be dragged and
- dropped onto each other and resized by dragging the bottom and right edges. The
- yellow elements are SVG elements (these won't show up on IE8).
- - [star.svg](http://interactjs.io/repo/demo/star.svg "editing an SVG document")
- demonstrates interact.js being used within an SVG document.
- - The [snapping demo](http://interactjs.io/repo/demo/snap.html "Oh snap!") shows
- how flexible the grid and anchor snapping system is and it's pretty fun.
- - This [blog post on path
- snapping](http://taye.me/blog/interact-js/snap/2013/09/29/interactjs-path-snapping.html)
- demonstrates and graphs some interesting path snapping functions.
-
-interact.js began as a [Google Summer of Code 2012 project]("http://www.google-melange.com/gsoc/project/details/google/gsoc2012/taye/5668600916475904") for
-[Biographer](https://code.google.com/p/biographer "Biographer on Google Code").
-
-Example
--------
-
-```javascript
-var // x and y to keep the position that's been dragged to
- x = 0,
- y = 0,
- // vendor prefixes (prefices?)
- transformProp = 'transform' in document.body.style?
- 'transform': 'webkitTransform' in document.body.style?
- 'webkitTransform': 'mozTransform' in document.body.style?
- 'mozTransform': 'oTransform' in document.body.style?
- 'oTransform': 'msTransform';
-
-// make an Interactable of the document body element
-interact(document.body)
- // make a draggable of the Interactable
- .draggable({
- // on(drag)move
- // could also have done interact(document.body).draggable(true).ondragmove = function...
- onmove: function (event) {
- x += event.dx;
- y += event.dy;
-
- // translate the document body by the change in pointer position
- document.body.style[transformProp] = 'translate(' + x + 'px, ' + y + 'px)';
- }
- })
- // you should really add listeners like this if you want to add multiple listeners
- .on('dragend', function (event) {
- console.log('dragged a distance of ' +
- Math.sqrt(event.dx*event.dx + event.dy*event.dy) +
- ' pixels to ' + event.pageX + ', ' + event.pageY);
- })
- // allow inertia throwing
- .inertia({
- resistance: 15,
- zeroResumeDelta: true
- });
- // snap to the corners of the specified grid
- .snap({
- mode: 'grid',
- grid: {
- x: 100,
- y: 5
- },
- gridOffset: {
- x: 20,
- y: 10
- },
- range: Infinity // can also use -1 which gets changed to Infinity
- });
-
-
-// you can also listen to InteractEvents for every Interactable
-interact.on('dragstart', function (event) {
- console.log('starting drag from ' + event.x0 + ', ' + event.y0);
-});
```
-
-Documentation
--------------
-http://interactjs.io/docs
-
-Usage
------
-Pass the element you want to interact with or a CSS selector string to
-`interact`. That returns an object with methods, notably `draggable`,
-`resizable`, `gesturable`, `dropzone` which let you allow or disallow the
-related actions and `on` which let's you add event listeners for InteractEvents
-and any DOM event.
-
-Details
--------
-
-### Interactables
-The `interact` function takes an Element or CSS selector and an optional
-`options` object. This returns an `Interactable` object which has several
-methods and properties to configure what events it can fire and to modify the
-reported coordinates. These methods have a fluent interface so method calls can
-be chained nicely.
-
-For example, to make a DOM element fire drag and resize events you can do:
-
-```javascript
-interact(document.getElementById('anElement'))
- .draggable (true)
- .resizable(true);
+npm install --save-dev @interactjs/types
```
-### Acting
-Now that the element has been made interactable, when it is clicked on or
-touched and then dragged, an action is determined depending on the input type
-and position of the event over the element. InteractEvents are then fired as
-the pointer moves around the page until it is finally released or the
-window loses focus.
-
-When a sequence of user actions results in an InteractEvent, that event type is
-fired and all listeners of that type which were bound to that Interactable or
-bound globally are called.
-
-Even though InteractEvents are being fired, the element is not actually
-modified by interact.js at all. To do that, you need to add listeners for
-InteractEvents either to each Interactable or globally for all Interacables and
-style the element according to event data.
-
-### Listening
- The `InteractEvent` types are:
+## Documentation
- - Draggable: `dragstart`, `dragmove`, `draginertiastart`, `dragend`
- - Dropzone: `dropactivate`, `dropdeactivate`, `dragenter`, `dragleave`,
- `dropmove`, `drop`
- - Resizable: `resizestart`, `resizemove`, `resizeinertiastart`, `resizeend`
- - Gesturable: `gesturestart`, `gesturemove`, `gestureinertiastart`,
- `gestureend`
-
-There are also the `tap` and `doubletap` events which are equivalent to `click`
-and `doubleclik`.
-
-To respond to an InteractEvent, you must add a listener for its event type
-either directly to an interactable
-
-``` javascript
-Interactable#on(eventType, listenerFunction)
-```
+http://interactjs.io/docs
-or globally for all events of that type
+## Example
```javascript
-interact.on('resizemove', resizeElement)`.
-```
-
-The `InteractEvent` object that was created is passed to these functions as the
-first parameter.
-
-InteractEvent properties include the usual properties of mouse/touch events
-such as pageX/Y, clientX/Y, modifier keys etc. but also some properties
-providing information about the change in coordinates and event specific data.
-The table below displays all of these events.
-
-#### InteractEvent properties
-| Common | |
-| ----------------------- | --------------------------------------------------|
-| target | The element that is being interacted with |
-| `x0`, `y0` | Page x and y coordinates of the starting event |
-| `clientX0`, `clientY0` | Client x and y coordinates of the starting event |
-| `dx`, `dy` | Change in coordinates of the mouse/touch |
-| `velocityX`, `velocityY`| The Velocity of the pointer |
-| `speed` | The speed of the pointer |
-| `timeStamp` | The time of creation of the event object |
-
-| Draggables | |
-| ----------------------- | --------------------------------------------------|
-| **dragmove** | |
-| `dragEnter` | The dropzone this Interactable was dragged over |
-| `dragLeave` | The dropzone this Interactable was dragged out of |
-| **dragenter, dragLeave**| |
-| `draggable` | The draggable that's over this dropzone |
-
-| Dropzones | |
-| ----------------------- | --------------------------------------------------|
-| **drop(de)activate**, **dropmove**, **drag(enter\|leave)**, **drop** | |
-| `draggable` | The draggable element that was dropped into this dropzone |
-| | |
-
-| Resize | |
-| ----------------------- | --------------------------------------------------|
-| `axes` | The axes the resizing is constrained to (x/y/xy) |
-
-| Gesture | |
-| ----------------------- | --------------------------------------------------|
-| `touches` | The array of touches that triggered the event |
-| `distance` | The distance between the event's first two touches|
-| `angle` | The angle of the line made by the two touches |
-| `da` | The change in angle since previous event |
-| `scale` | The ratio of the distance of the start event to the distance of the current event |
-| `ds` | The change in scale since the previous event |
-| `box` | A box enclosing all touch points |
-
-In gesture events, page and client coordinates are the averages of touch
-coordinates. Velocity is calculated from these averages.
-
-Tap and doubletap event coordinates are copied directly from the source
-mouseup/touchend/pointerup event and are not modified โ no snapping,
-restriction or origin for tap and doubletap.
-
-The [dropmove](https://github.com/taye/interact.js/issues/67) event is a plain
-object created like this:
+var pixelSize = 16;
+
+interact('.rainbow-pixel-canvas')
+ .origin('self')
+ .draggable({
+ modifiers: [
+ interact.modifiers.snap({
+ // snap to the corners of a grid
+ targets: [
+ interact.snappers.grid({ x: pixelSize, y: pixelSize }),
+ ],
+ })
+ ],
+ listeners: {
+ // draw colored squares on move
+ move: function (event) {
+ var context = event.target.getContext('2d'),
+ // calculate the angle of the drag direction
+ dragAngle = 180 * Math.atan2(event.dx, event.dy) / Math.PI;
+
+ // set color based on drag angle and speed
+ context.fillStyle = 'hsl(' + dragAngle + ', 86%, '
+ + (30 + Math.min(event.speed / 1000, 1) * 50) + '%)';
+
+ // draw squares
+ context.fillRect(event.pageX - pixelSize / 2, event.pageY - pixelSize / 2,
+ pixelSize, pixelSize);
+ }
+ }
+ })
+ // clear the canvas on doubletap
+ .on('doubletap', function (event) {
+ var context = event.target.getContext('2d');
+
+ context.clearRect(0, 0, context.canvas.width, context.canvas.height);
+ });
+
+ function resizeCanvases () {
+ [].forEach.call(document.querySelectorAll('.rainbow-pixel-canvas'), function (canvas) {
+ canvas.width = document.body.clientWidth;
+ canvas.height = window.innerHeight * 0.7;
+ });
+ }
-``` javascript
-dropMoveEvent = {
- target : dropElement,
- relatedTarget: dragEvent.target,
- dragmove : dragEvent,
- type : 'dropmove',
- timeStamp : dragEvent.timeStamp
-};
+ // interact.js can also add DOM event listeners
+ interact(document).on('DOMContentLoaded', resizeCanvases);
+ interact(window).on('resize', resizeCanvases);
```
-### Interacting
-One way to move an element in response to a dragmove is to add a listener that
-transforms the element according to `dy` and `dx` of the InteractEvent.
+See the above code in action at https://codepen.io/taye/pen/tCKAm
-```javascript
-// Set element and listen for dragmove events
-interact('.drag-element')
- .draggable({
- onmove: function(event) {
- var target = event.target,
- // use data-x, data-y to record the drag position
- x = (parseFloat(target.dataset.x) || 0) + event.dx,
- y = (parseFloat(target.dataset.y) || 0) + event.dy;
-
- // update the CSS transform
- target.style.transform =
- 'translate(' + x + 'px, ' + y + 'px)';
-
- // save the newly dragged position
- target.dataset.x = x;
- target.dataset.y = y;
- });
-```
-
-License
--------
+## License
interact.js is released under the [MIT License](http://taye.mit-license.org).
+
+[ijs-twitter]: https://twitter.com/interactjs
+[upcoming-changes]: https://github.com/taye/interact.js/blob/main/CHANGELOG.md#upcoming-changes
diff --git a/babel.config.cjs b/babel.config.cjs
new file mode 100644
index 000000000..eee873213
--- /dev/null
+++ b/babel.config.cjs
@@ -0,0 +1,3 @@
+module.exports = {
+ presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
+}
diff --git a/bin/_add_plugin_indexes b/bin/_add_plugin_indexes
new file mode 100755
index 000000000..1d05c113a
--- /dev/null
+++ b/bin/_add_plugin_indexes
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('../scripts/bin/add_plugin_indexes')
diff --git a/bin/_bundle b/bin/_bundle
new file mode 100755
index 000000000..5e62ec03d
--- /dev/null
+++ b/bin/_bundle
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('../scripts/bin/bundle')
diff --git a/bin/_check_deps b/bin/_check_deps
new file mode 100755
index 000000000..c84232f7c
--- /dev/null
+++ b/bin/_check_deps
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('../scripts/bin/_check_deps')
diff --git a/bin/_clean b/bin/_clean
new file mode 100755
index 000000000..40988c0e1
--- /dev/null
+++ b/bin/_clean
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('../scripts/bin/clean')
diff --git a/bin/_link b/bin/_link
new file mode 100755
index 000000000..353cbb4fa
--- /dev/null
+++ b/bin/_link
@@ -0,0 +1,29 @@
+#!/bin/bash
+ROOT=$(dirname $(dirname $(readlink -f $0)))
+if [ -z "$ROOT" ]
+then
+ ROOT=$(dirname $(dirname $0))
+fi
+
+modules_scope_dir=node_modules/@interactjs
+modules_bin_dir=node_modules/.bin
+
+mkdir -p $modules_scope_dir $modules_bin_dir
+
+rm $modules_scope_dir/* 2> /dev/null
+
+# link _dev package
+ln -sf $ROOT $modules_scope_dir/_dev
+
+# link all scoped packages from CWD
+for package in $(cd packages/@interactjs && ls -d *); do
+ ln -sf ../../packages/@interactjs/$package $modules_scope_dir
+done
+
+# link all packages from this repo
+for package in $(cd $ROOT/packages/@interactjs && ls -d *); do
+ ln -sf $ROOT/packages/@interactjs/$package $modules_scope_dir
+done
+
+# link all bins from this repo and from CWD
+cd node_modules/.bin && ln -sf $ROOT/bin/* ../../bin/* .
diff --git a/bin/_lint b/bin/_lint
new file mode 100755
index 000000000..b13364f38
--- /dev/null
+++ b/bin/_lint
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('../scripts/bin/lint')
diff --git a/bin/_release b/bin/_release
new file mode 100755
index 000000000..38e62e904
--- /dev/null
+++ b/bin/_release
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('../scripts/bin/release')
diff --git a/bin/_types b/bin/_types
new file mode 100755
index 000000000..0da7f76a8
--- /dev/null
+++ b/bin/_types
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('../scripts/bin/types')
diff --git a/bin/_version b/bin/_version
new file mode 100755
index 000000000..7c04d127b
--- /dev/null
+++ b/bin/_version
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('../scripts/bin/version')
diff --git a/bower.json b/bower.json
deleted file mode 100644
index adc935c1b..000000000
--- a/bower.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "name": "interact",
- "version": "1.1.2",
- "main": "interact.js",
- "description": "Drag and drop, resizing and multi-touch gestures with inertia and snapping for modern browsers (and also IE8+)",
- "homepage": "http://interactjs.io",
- "authors": [{
- "name" : "Taye Adeyemi",
- "email": "dev@taye.me",
- "url" : "http://taye.me"
- }],
- "keywords": [
- "interact.js",
- "draggable",
- "droppable",
- "drag",
- "drop",
- "drag and drop",
- "resize",
- "touch",
- "multi-touch",
- "gesture",
- "snap",
- "inertia",
- "grid",
- "autoscroll",
- "SVG"
- ],
- "devDependencies": {
- "mocha": "*",
- "chai": "*"
- },
- "moduleType": [
- "amd",
- "globals",
- "node"
- ],
- "license": "MIT",
- "ignore": [
- ".*",
- "test",
- "demo",
- "img",
- "docs"
- ]
-}
diff --git a/bundle.rollup.config.cjs b/bundle.rollup.config.cjs
new file mode 100644
index 000000000..b5342c743
--- /dev/null
+++ b/bundle.rollup.config.cjs
@@ -0,0 +1,90 @@
+/* eslint-disable import/no-extraneous-dependencies */
+const { resolve } = require('path')
+
+const babel = require('@rollup/plugin-babel')
+const commonjs = require('@rollup/plugin-commonjs')
+const nodeResolve = require('@rollup/plugin-node-resolve')
+const replace = require('@rollup/plugin-replace')
+const terser = require('@rollup/plugin-terser')
+const { defineConfig } = require('rollup')
+
+const headers = require('./scripts/headers')
+const { extendBabelOptions, getModuleDirectories, isPro } = require('./scripts/utils')
+
+const globals = {
+ react: 'React',
+ vue: 'Vue',
+}
+const external = Object.keys(globals)
+const INPUT_EXTENSIONS = ['.ts', '.tsx', '.vue']
+
+module.exports = defineConfig(async () => {
+ const variations = [
+ { env: { NODE_ENV: 'development' }, ext: '.js', minify: isPro },
+ { env: { NODE_ENV: 'production' }, ext: '.min.js', minify: true },
+ ]
+
+ return variations.map(({ minify, ext, env }) => {
+ const babelConfig = extendBabelOptions({
+ babelrc: false,
+ configFile: false,
+ browserslistConfigFile: false,
+ targets: { ie: 9 },
+ babelHelpers: 'bundled',
+ skipPreflightCheck: true,
+ extensions: INPUT_EXTENSIONS,
+ plugins: [[require.resolve('@babel/plugin-transform-runtime'), { helpers: false, regenerator: true }]],
+ })
+
+ return defineConfig({
+ input: resolve(__dirname, 'packages', 'interactjs', 'index.ts'),
+ external,
+ plugins: [
+ nodeResolve({
+ modulePaths: getModuleDirectories(),
+ extensions: INPUT_EXTENSIONS,
+ }),
+ commonjs({ include: '**/node_modules/{rebound,symbol-tree}/**' }),
+ babel(babelConfig),
+ replace({
+ preventAssignment: true,
+ values: Object.entries({
+ npm_package_version: process.env.npm_package_version,
+ IJS_BUNDLE: '1',
+ ...env,
+ }).reduce((acc, [key, value]) => {
+ acc[`process.env.${key}`] = JSON.stringify(value)
+ return acc
+ }, {}),
+ }),
+ minify &&
+ terser({
+ module: false,
+ mangle: true,
+ compress: {
+ ecma: 5,
+ unsafe: true,
+ unsafe_Function: true,
+ unsafe_arrows: false,
+ unsafe_methods: true,
+ },
+ format: {
+ preamble: headers?.min,
+ },
+ }),
+ ],
+ context: 'window',
+ moduleContext: 'window',
+ output: {
+ file: resolve(__dirname, 'packages', 'interactjs', 'dist', `interact${ext}`),
+ format: 'umd',
+ name: 'interact',
+ banner: minify ? headers.min : headers.raw,
+ minifyInternalExports: true,
+ inlineDynamicImports: true,
+ sourcemap: true,
+ globals,
+ },
+ })
+ })
+})
diff --git a/demo/css/html_svg.css b/demo/css/html_svg.css
deleted file mode 100644
index e8994ffcd..000000000
--- a/demo/css/html_svg.css
+++ /dev/null
@@ -1,39 +0,0 @@
-div.demo-node:before {
- content : attr(id);
- border-bottom : 2px solid red;
-}
-
-div.demo-node {
- position : absolute;
- border-radius : 10px;
- border : 5px solid #333333;
- border : 5px solid #333333;
- width : 200px;
- height : 200px;
- padding : 15px;
- margin : 15px;
- overflow : auto;
- background-color: #2288FF;
-
- touch-action: none;
-}
-
-ellipse {
- fill : #EEEE00;
- stroke : #000000;
- stroke-width : 3px;
-
- touch-action: none;
-}
-
-svg text.title {
- transform : translate(0px, 20px);
-
- touch-action: none;
-}
-
-svg text.eventData {
- transform : translate(0px, -10px);
-
- touch-action: none;
-}
diff --git a/demo/css/snap.css b/demo/css/snap.css
deleted file mode 100644
index 6bf792b3b..000000000
--- a/demo/css/snap.css
+++ /dev/null
@@ -1,73 +0,0 @@
-body {
- margin: 0;
- padding: 0;
- border: 0;
- font-family: "Arial", sans-serif;
-}
-
-canvas {
- position: absolute;
- top: 0;
- left: 0;
-
- margin: 20px;
- padding: 0;
-
- touch-action: none;
-}
-
-#status {
- width: 20%;
- height: 100%;
- position: fixed;
- right: 0;
- top: 0;
-
- padding: 5px 5px;
- border: none;
- border-left: solid 8px #3a6bff;
-
- background-color: rgba(0, 143, 179, 0.298);
- text-align: center;
- font-size: 1.4em;
-}
-
-#status h3 {
- font-size: 1.1em;
- margin: 3px 0px 0px 0px;
- padding: 0;
- line-height: 22px;
- text-transform: capitalize;
- font-weight: normal
-}
-
-#status input[type=radio], #status input[type=checkbox] {
- float: right;
-}
-
-#status [type=range] {
- margin: auto;
- width: 90%;
-}
-
-#status [disabled] {
- cursor: default;
-}
-
-#status label {
- float: left;
- cursor: pointer;
- width: 95%;
- text-align: left;
-}
-
-#modes,#sliders {
- overflow: hidden;
- width: 100%;
- margin: auto;
-}
-
-#modes.disabled label.snap-mode {
- cursor: default;
- color: gray;
-}
diff --git a/demo/gallery.html b/demo/gallery.html
deleted file mode 100644
index 1a176762d..000000000
--- a/demo/gallery.html
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-
-
-Image gallery with interact.js inertia and snapping
-
-
-
-
-
-
-
-
-
-
-
-
-