How to use the tether function in tether

To help you get started, we’ve selected a few tether examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github danreeves / react-tether / src / Tether.jsx View on Github external
_initTether(props) {
    // initialize tether with respective elements
    this._tether = new Tether({
      element: this._node,
      target: props.target,
      ...props.options
    })

    // update DOM
    this._update(props)

    this._tetherInitialized = true
  }
github react-paper / react-paper-bindings / demo / src / Paper / Toolbar / Menu / Dropdown.js View on Github external
onOpen = (portalNode) => {
    const { align, offset } = this.props
    const [ay,ax,ty,tx] = align.split('').map(a => a && POS[a]).filter(a => a)
    const [oy,ox] = offset.split(' ').map(o => parseInt(o, 10))

    portalNode.classList.add('Dropdown')

    this._tether = new Tether({
      element: portalNode,
      target: this.ref,
      attachment: `${ay} ${ax}`,
      targetAttachment: `${ty} ${tx}`,
      offset: `${oy} ${ox}`,
      constraints: [{
        to: 'window',
        pin: true,
      }],
    })

    portalNode.style.opacity = 1
  }
github cerner / kaiju / rails / client / app / bundles / kaiju / components / Component / utilities / overlay.js View on Github external
if (!target) {
    return;
  }

  const rect = target.getBoundingClientRect();
  const overlayReference = getOverlay();

  overlayReference.innerHTML = '';
  overlayReference.style.display = '';
  overlayReference.style.height = `${rect.height}px`;
  overlayReference.style.width = `${rect.width}px`;

  overlayReference.appendChild(getTargetLabel(target, rect));

  tether = new Tether({
    element: overlayReference,
    target,
    attachment: 'top left',
    targetAttachment: 'top left',
  });
};
github tochoromero / aurelia-bootstrap / dist / es2015 / utils / tooltip-service.js View on Github external
if (position === 'top') {
            attachment = 'bottom center';
            targetAttachment = "top center";
        } else if (position === 'bottom') {
            attachment = 'top center';
            targetAttachment = "bottom center";
        } else if (position === 'left') {
            attachment = 'center right';
            targetAttachment = "center left";
        } else {
            attachment = 'center left';
            targetAttachment = "center right";
        }

        return new Tether({
            element: element,
            target: target,
            attachment: attachment,
            targetAttachment: targetAttachment
        });
    }
github byte-foundry / prototypo / app / scripts / components / onboarding.components.jsx View on Github external
createTether() {
		if (this.tether) {
			this.tether.destroy();
		}

		const target = this.step ? document.getElementById(this.step.props.target) : undefined;

		if (this.step && this.step.props.target && target) {
			this.tether = new Tether({
				target,
				element: this.refs.onboarding,
				attachment: this.step.props.elementAlign || 'middle left',
				targetAttachment: this.step.props.targetAlign || 'middle right',
				offset: this.step.props.offset || '-10px -50px',
			});
		}
		else if (this.tether) {
			this.setState({
				reset: (new Date()).getTime(),
			});
			this.tether = undefined;
		}
	}
	componentDidMount() {
github pivotal-cf / pivotal-ui / src / react / react-tether / TetherComponent.js View on Github external
if (id) {
      this._elementParentNode.id = id;
    }

    if (className) {
      this._elementParentNode.className = className;
    }

    if (style) {
      Object.keys(style).forEach(key => {
        this._elementParentNode.style[key] = style[key];
      });
    }

    if (!this._tether) {
      this._tether = new Tether(tetherOptions);
      this._registerEventListeners();
    } else {
      this._tether.setOptions(tetherOptions);
    }

    this._tether.position();
  }
github epam / NGB / client / client / app / shared / components / ngbVariantDetails / ngbVariantVisualizer / ngbVariantVisualizer.controller.js View on Github external
displayTooltip(position, content) {
        if (content) {
            this._tooltipContent = content;
            this._scope.$apply();
            if ($(this._tooltipElement).hasClass('hidden')) {
                $(this._tooltipElement).removeClass('hidden');
            }
            this._tooltipTarget.style.left = `${position.x}px`;
            this._tooltipTarget.style.top = `${position.y}px`;
            if (!this._tetherElement) {
                this._tetherElement = new Tether({
                    target: this._tooltipTarget,
                    element: this._tooltipElement,
                    attachment: 'top left',
                    targetAttachment: 'middle middle',
                    offset: '-25 0'
                });
            }
            this._tetherElement.position();
        }
        else {
            this._tooltipContent = [];
            if (!$(this._tooltipElement).hasClass('hidden')) {
                $(this._tooltipElement).addClass('hidden');
            }
            if (this._tetherElement) {
                this._tetherElement.destroy();
github prometheusresearch-archive / react-autocomplete / src / Autocomplete.js View on Github external
_layerDidMount = (element: HTMLElement) => {
    const target = ReactDOM.findDOMNode(this._search);
    invariant(target instanceof HTMLElement, 'Invalid DOM state');
    const size = target.getBoundingClientRect();
    element.style.width = `${size.width}px`;
    this._tether = new Tether({element, target, ...TETHER_CONFIG});
  };
github KawashiroNitori / Anubis / anubis / ui / pages / problem_detail.page.js View on Github external
async function createSidebar() {
        $floatingSidebar = $('.section--problem-sidebar')
            .clone()
            .addClass('scratchpad__sidebar visible')
            .appendTo('body');
        $floatingSidebar.find('a').attr('target', '_blank');
        $floatingSidebar.tether = new Tether({
            element: $floatingSidebar,
            offset: '-20px 20px',
            target: '.scratchpad__problem',
            attachment: 'top right',
            targetAttachment: 'top right',
        });
        await delay(100);
        $floatingSidebar.tether.position();
    }

tether

A client-side library to make absolutely positioned elements attach to elements in the page efficiently.

MIT
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis

Popular tether functions