├── .browserslistrc
├── .codeclimate.yml
├── .eslintignore
├── .eslintrc.js
├── .github
├── dependabot.yml
└── workflows
│ └── main.yml
├── .gitignore
├── .hsdoc
├── .npmignore
├── .npmrc
├── .prettierrc.js
├── .release-it.js
├── CHANGELOG.md
├── CONTRIBUTING.md
├── HISTORY.md
├── LICENSE
├── README.md
├── RELEASE.md
├── __mocks__
└── styleMock.js
├── babel.config.js
├── cypress.config.cjs
├── docs
├── 1-Overview
│ ├── 1-why_you_should_use_tether.md
│ ├── 2-repositioning.md
│ └── 3-why_we_dont_support_IE_8.md
├── 2-Examples
│ ├── 1-list_of_examples.md
│ └── 2-projects_using_tether.md
├── 3-Advanced
│ ├── 1-embedding_tether.md
│ └── 2-extending_tether.md
├── css
│ └── intro.css
├── intro.md
├── js
│ └── intro.js
├── sass
│ └── intro.sass
└── welcome
│ ├── browser-demo.html
│ ├── css
│ ├── browser-demo.css
│ ├── prism.css
│ └── welcome.css
│ ├── index.html
│ ├── js
│ ├── drop.js
│ ├── jquery.js
│ ├── log.js
│ └── welcome.js
│ └── sass
│ ├── _inline-block.sass
│ ├── browser-demo.sass
│ └── welcome.sass
├── examples
├── common
│ └── css
│ │ └── style.css
├── content-visible
│ └── index.html
├── dolls
│ ├── dolls.css
│ ├── dolls.js
│ └── index.html
├── element-scroll
│ └── index.html
├── enable-disable
│ └── index.html
├── index.html
├── out-of-bounds
│ └── index.html
├── pin
│ └── index.html
├── resources
│ └── css
│ │ └── base.css
├── scroll
│ └── index.html
├── simple
│ └── index.html
├── testbed
│ └── index.html
└── viewport
│ ├── colors.css
│ └── index.html
├── jest.config.js
├── package.json
├── rollup.config.js
├── src
├── css
│ ├── helpers
│ │ ├── _tether-theme-arrows.scss
│ │ ├── _tether-theme-basic.scss
│ │ └── _tether.scss
│ ├── mixins
│ │ ├── _inline-block.scss
│ │ └── _pie-clearfix.scss
│ ├── tether-theme-arrows-dark.scss
│ ├── tether-theme-arrows.scss
│ ├── tether-theme-basic.scss
│ └── tether.scss
└── js
│ ├── abutment.js
│ ├── constraint.js
│ ├── evented.js
│ ├── shift.js
│ ├── tether.js
│ └── utils
│ ├── bounds.js
│ ├── classes.js
│ ├── deferred.js
│ ├── general.js
│ ├── offset.js
│ ├── parents.js
│ └── type-check.js
├── test
├── .eslintrc.js
├── cypress
│ ├── integration
│ │ ├── content-visible.cy.js
│ │ ├── enable-disable.cy.js
│ │ ├── out-of-bounds.cy.js
│ │ ├── pin.cy.js
│ │ ├── scroll.cy.js
│ │ ├── simple.cy.js
│ │ └── testbed.cy.js
│ ├── plugins
│ │ └── index.js
│ └── support
│ │ ├── commands.js
│ │ └── index.js
└── unit
│ ├── constraint.spec.js
│ ├── evented.spec.js
│ ├── setupTests.js
│ ├── tether.spec.js
│ └── utils
│ ├── classes.spec.js
│ ├── deferred.spec.js
│ └── offset.spec.js
└── yarn.lock
/.browserslistrc:
--------------------------------------------------------------------------------
1 | # Browsers that we support
2 |
3 | last 2 Chrome versions
4 | last 2 Firefox versions
5 | last 2 Safari versions
6 | last 2 Edge versions
7 | ie >= 10
8 |
--------------------------------------------------------------------------------
/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | version: "2"
2 | checks:
3 | argument-count:
4 | config:
5 | threshold: 10
6 | method-count:
7 | config:
8 | threshold: 25
9 | method-lines:
10 | config:
11 | threshold: 30
12 | exclude_patterns:
13 | - "demo/"
14 | - "dist/"
15 | - "docs/"
16 | - "examples/"
17 | - "jsdoc-template/"
18 | - "**/node_modules/"
19 | - "**/test/"
20 | - "**/tests/"
21 | - "**/vendor/"
22 | - "babel.config.js"
23 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | /coverage/
2 | /dist/
3 | /docs/
4 | /examples/
5 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | parserOptions: {
4 | ecmaVersion: 2020,
5 | sourceType: 'module'
6 | },
7 | extends: [
8 | 'eslint:recommended'
9 | ],
10 | env: {
11 | browser: true,
12 | es6: true
13 | },
14 | rules: {
15 | 'complexity': ['warn', 6],
16 | 'max-lines': ['warn', { max: 250, skipBlankLines: true, skipComments: true }],
17 | 'no-console': 'off',
18 | 'no-unused-vars': 'off',
19 | 'prefer-const': 'off'
20 | },
21 | overrides: [
22 | // node files
23 | {
24 | files: [
25 | '.eslintrc.js',
26 | 'babel.config.js',
27 | 'jest.config.js',
28 | 'rollup.config.js',
29 | '__mocks__/styleMock.js'
30 | ],
31 | parserOptions: {
32 | sourceType: 'module',
33 | ecmaVersion: 2020
34 | },
35 | env: {
36 | node: true
37 | }
38 | }
39 | ]
40 | };
41 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: npm
4 | directory: "/"
5 | schedule:
6 | interval: weekly
7 | time: "10:00"
8 | open-pull-requests-limit: 10
9 | labels:
10 | - dependencies
11 | versioning-strategy: increase
12 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 |
2 | name: CI Build
3 |
4 | on:
5 | pull_request: {}
6 | push:
7 | branches:
8 | - master
9 | tags:
10 | - v*
11 |
12 | jobs:
13 | test:
14 | name: Tests
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | - uses: volta-cli/action@v1
20 | with:
21 | node-version: 16.x
22 | - run: yarn
23 | - run: yarn test
24 |
25 | automerge:
26 | needs: [test]
27 | runs-on: ubuntu-latest
28 | permissions:
29 | pull-requests: write
30 | contents: write
31 | steps:
32 | - uses: fastify/github-action-merge-dependabot@v3.2.0
33 | with:
34 | github-token: ${{secrets.GITHUB_TOKEN}}
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Editors
2 | /.idea/
3 | /.vscode/
4 |
5 | /.log/
6 | /.nyc_output/
7 | /coverage/
8 | /cypress/
9 | /docs/
10 | /dist/
11 | /node_modules/
12 | /test/unit/dist
13 | /.DS_Store
14 | /.sass-cache
15 | /npm-debug.log*
16 | /stats.html
17 | /yarn-error.log
18 |
--------------------------------------------------------------------------------
/.hsdoc:
--------------------------------------------------------------------------------
1 | name: "Tether"
2 | description: "Marrying DOM elements for life"
3 | domain: "tetherjs.dev"
4 | source: "src/**/*.js"
5 | examples: "**/*.md"
6 | assets: "{dist/js/*.js,dist/css/*.css,docs/css/*.css,docs/js/*,js,docs/welcome/*,examples/*}"
7 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vscode/
3 |
4 | coverage/
5 | cypress/
6 | docs/
7 | examples/
8 | esdoc/
9 | jsdoc-template/
10 | test/
11 | tests/
12 |
13 | .codeclimate.yml
14 | .eslintignore
15 | .eslintrc.js
16 | .gitignore
17 | .hsdoc
18 | .stylelintrc.js
19 | .travis.yml
20 | babel.config.js
21 | cypress.json
22 | index.html
23 | rollup.config.js
24 | yarn.lock
25 | yarn-error.log
26 |
27 | CONTRIBUTING.md
28 | HISTORY.md
29 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | scripts-prepend-node-path=true
2 |
--------------------------------------------------------------------------------
/.prettierrc.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | singleQuote: true,
5 | trailingComma: 'none'
6 | };
--------------------------------------------------------------------------------
/.release-it.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | hooks: {
5 | 'after:bump': 'yarn build'
6 | },
7 | plugins: {
8 | 'release-it-lerna-changelog': {
9 | infile: 'CHANGELOG.md',
10 | launchEditor: true
11 | }
12 | },
13 | git: {
14 | tagName: 'v${version}'
15 | },
16 | github: {
17 | release: true,
18 | tokenRef: 'GITHUB_AUTH',
19 | assets: ['dist/**/*.css', 'dist/**/*.js', 'dist/**/*.map']
20 | },
21 | npm: {
22 | publish: true
23 | }
24 | };
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guide
2 |
3 | You will need:
4 |
5 | - [Yarn](https://yarnpkg.com/)
6 |
7 | Windows users will need additional setup to enable build capabilities in NPM.
8 | From an administrative command window:
9 |
10 | ```sh
11 | yarn global add windows-build-tools
12 | ```
13 |
14 | ## Getting started
15 |
16 | 1. Fork the project
17 | 2. Clone your forked project by running `git clone git@github.com:{
18 | YOUR_USERNAME }/tether.git`
19 | 3. Run `yarn` to install node modules
20 | 4. Test that you can build the source by running `yarn build` and ensure the `dist` directory appears.
21 |
22 | ## Writing code!
23 |
24 | We use `rollup` to facilitate things like transpilation, minification, etc. so
25 | you can focus on writing relevant code. If there is a fix or feature you would like
26 | to contribute, we ask that you take the following steps:
27 |
28 | 1. Most of the _editable_ code lives in the `src` directory while built code
29 | will end up in the `dist` directory upon running `yarn build`.
30 |
31 | 2. Some examples are served out of the `examples` directory. Running `yarn start` will open the list in your browser and initiate a live-reloading session as you make changes.
32 |
33 |
34 | ## Opening Pull Requests
35 |
36 | 1. Please Provide a thoughtful commit message and push your changes to your fork using
37 | `git push origin master` (assuming your forked project is using `origin` for
38 | the remote name and you are on the `master` branch).
39 |
40 | 2. Open a Pull Request on GitHub with a description of your changes.
41 |
42 |
43 | ## Testing
44 |
45 | All PRs, that change code functionality, are required to have accompanying tests.
46 |
47 | ### Acceptance Tests
48 |
49 | Acceptance tests are run using [`cypress`](https://github.com/cypress-io/cypress). A number of different testing configurations can be found in [`package.json`](/package.json), but you can simply run `yarn test:ci:watch` to build your latest changes and begin running the tests inside a Chrome browser instance.
50 |
51 | ⚠️ The acceptance tests are set up to run on `localhost` port `9002`. If you'd like to change this port, make sure to change the `baseUrl` option inside of [`cypress.json`](/cypress.json), and change any references to port `9002` in [`package.json`](/package.json) accordingly.
52 |
53 |
--------------------------------------------------------------------------------
/HISTORY.md:
--------------------------------------------------------------------------------
1 | ## v1.3.0
2 | - Tether instances now fire an 'update' event when attachments change due to constraints (#119)
3 |
4 | ## v1.0.1
5 | - Update arrow mixin to change arrow pointer event
6 |
7 |
8 | ## v1.0.0
9 | - Coffeescript -> ES6
10 | - Proper UMD Wrapper
11 | - Update build steps
12 | - Add changelog
13 | - Provide minified CSS
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014-2019 HubSpot, Inc.
2 | Copyright (c) 2019-2022 Ship Shape Consulting LLC
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 |
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tether
2 |
3 |
4 |
5 |
6 |
7 |
8 | **[Tether is maintained by Ship Shape. Contact us for web app consulting, development, and training for your project](https://shipshape.io/services/app-development/)**.
9 |
10 |
11 | [](http://badge.fury.io/js/tether)
12 | 
13 | []()
14 | 
15 | [](https://travis-ci.com/shipshapecode/tether)
16 | [](https://codeclimate.com/github/shipshapecode/tether/maintainability)
17 | [](https://codeclimate.com/github/shipshapecode/tether/test_coverage)
18 |
19 | ## 🐙 Project status 🐙
20 |
21 | We at Ship Shape have recently taken over Tether's maintenance and hope to modernize and revitalize it. Stay tuned for updates!
22 |
23 | ## Install
24 |
25 | __npm__
26 | ```sh
27 | npm install tether
28 | ```
29 |
30 | For the latest beta:
31 |
32 | ```sh
33 | npm install tether@next
34 | ```
35 |
36 | __download__
37 |
38 | Or download from the [releases](https://github.com/shipshapecode/tether/releases).
39 |
40 | ## Introduction
41 |
42 | [Tether](http://tetherjs.dev/) is a small, focused JavaScript library for defining and managing the position of user interface (UI) elements in relation to one another on a web page. It is a tool for web developers building features that require certain UI elements to be precisely positioned based on the location of another UI element.
43 |
44 | There are often situations in UI development where elements need to be attached to other elements, but placing them right next to each other in the [DOM tree](https://en.wikipedia.org/wiki/Document_Object_Model) can be problematic based on the context. For example, what happens if the element we’re attaching other elements to is fixed to the center of the screen? Or what if the element is inside a scrollable container? How can we prevent the attached element from being clipped as it disappears from view while a user is scrolling? Tether can solve all of these problems and more.
45 |
46 | Some common UI elements that have been built with Tether are [tooltips](http://github.hubspot.com/tooltip/docs/welcome), [select menus](http://github.hubspot.com/select/docs/welcome), and [dropdown menus](http://github.hubspot.com/drop/docs/welcome). Tether is flexible and can be used to [solve](http://tetherjs.dev/examples/out-of-bounds/) [all](http://tetherjs.dev/examples/content-visible) [kinds](http://tetherjs.dev/examples/element-scroll) [of](http://tetherjs.dev/examples/enable-disable) interesting [problems](http://tetherjs.dev/examples/viewport); it ensures UI elements stay where they need to be, based on the various user interactions (click, scroll, etc) and layout contexts (fixed positioning, inside scrollable containers, etc).
47 |
48 | Please have a look at the [documentation](http://tetherjs.dev/) for a more detailed explanation of why you might need Tether for your next project.
49 |
50 | ## What to Use Tether for and When to Use It
51 |
52 | Tether is a small, focused JavaScript library. For those who might be new to JavaScript, a library is simply a JavaScript file (or files) that contain useful JavaScript code to help achieve tasks easier and faster. Since Tether is a JavaScript user interface (**UI**) library, it contains code to help you to manage the way your website or web app appears.
53 |
54 | Tether’s goal to is to help you position your elements side-by-side when needed.
55 |
56 | Let’s say you’ve started working on your dream project—a fancy web app that’s sure to become the next big thing! An important feature of your new app is to allow users to comment on shared photos. However, due to limited vertical space and the overall layout of your new app, you’d like to display the comments **next** to the image, similar to how Instagram does it.
57 |
58 | Your HTML code might look something like this:
59 |
60 | ```html
61 |