Skip to content

Commit

Permalink
4.16.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Yair Even Or authored and Yair Even Or committed Sep 1, 2022
1 parent 02aae13 commit ada4473
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 33 deletions.
10 changes: 5 additions & 5 deletions dist/jQuery.tagify.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/react.tagify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 33 additions & 10 deletions dist/tagify.esm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Tagify (v 4.16.2) - tags input component
* By Yair Even-Or
* Tagify (v 4.16.3) - tags input component
* By undefined
* https://github.com/yairEO/tagify
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -348,7 +348,7 @@ var DEFAULTS = {
// after selecting a suggetion, should the typed text input remain or be cleared
position: 'all',
// 'manual' / 'text' / 'all'
appendTarget: null // defaults to document.body one DOM has been loaded
appendTarget: null // defaults to document.body once DOM has been loaded

},
hooks: {
Expand Down Expand Up @@ -597,17 +597,20 @@ var _dropdown = {
parentsPositions,
ddElm = this.DOM.dropdown,
placeAbove = _sd.placeAbove,
viewportHeight = document.documentElement.clientHeight,
viewportWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0),
isDefaultAppendTarget = _sd.appendTarget === document.body,
appendTargetScrollTop = isDefaultAppendTarget ? window.pageYOffset : _sd.appendTarget.scrollTop,
root = document.fullscreenElement || document.webkitFullscreenElement || document.documentElement,
viewportHeight = root.clientHeight,
viewportWidth = Math.max(root.clientWidth || 0, window.innerWidth || 0),
positionTo = viewportWidth > 480 ? _sd.position : 'all',
ddTarget = this.DOM[positionTo == 'input' ? 'input' : 'scope'];
ddHeight = ddHeight || ddElm.clientHeight;

function getParentsPositions(p) {
var left = 0,
top = 0;
top = 0; // when in element-fullscreen mode, do not go above the fullscreened-element

while (p) {
while (p && p != root) {
left += p.offsetLeft || 0;
top += p.offsetTop || 0;
p = p.parentNode;
Expand All @@ -619,6 +622,18 @@ var _dropdown = {
};
}

function getAccumulatedAncestorsScrollTop() {
var scrollTop = 0,
p = _sd.appendTarget.parentNode;

while (p) {
scrollTop += p.scrollTop || 0;
p = p.parentNode;
}

return scrollTop;
}

if (!this.state.dropdown.visible) return;

if (positionTo == 'text') {
Expand All @@ -628,19 +643,26 @@ var _dropdown = {
left = rect.left;
width = 'auto';
} else {
parentsPositions = getParentsPositions(this.settings.dropdown.appendTarget);
parentsPositions = getParentsPositions(_sd.appendTarget);
rect = ddTarget.getBoundingClientRect();
top = rect.top - parentsPositions.top;
bottom = rect.bottom - 1 - parentsPositions.top;
left = rect.left - parentsPositions.left;
width = rect.width + 'px';
} // if the "append target" isn't the default, correct the `top` variable by ignoring any scrollTop of the target's Ancestors


if (!isDefaultAppendTarget) {
let accumulatedAncestorsScrollTop = getAccumulatedAncestorsScrollTop();
top += accumulatedAncestorsScrollTop;
bottom += accumulatedAncestorsScrollTop;
}

top = Math.floor(top);
bottom = Math.ceil(bottom);
placeAbove = placeAbove === undefined ? viewportHeight - rect.bottom < ddHeight : placeAbove; // flip vertically if there is no space for the dropdown below the input

ddElm.style.cssText = "left:" + (left + window.pageXOffset) + "px; width:" + width + ";" + (placeAbove ? "top: " + (top + window.pageYOffset) + "px" : "top: " + (bottom + window.pageYOffset) + "px");
ddElm.style.cssText = "left:" + (left + window.pageXOffset) + "px; width:" + width + ";" + (placeAbove ? "top: " + (top + appendTargetScrollTop) + "px" : "top: " + (bottom + appendTargetScrollTop) + "px");
ddElm.setAttribute('placement', placeAbove ? "top" : "bottom");
ddElm.setAttribute('position', positionTo);
},
Expand All @@ -658,7 +680,7 @@ var _dropdown = {
var _CB = this.dropdown.events.callbacks,
// callback-refs
_CBR = this.listeners.dropdown = this.listeners.dropdown || {
position: this.dropdown.position.bind(this),
position: this.dropdown.position.bind(this, null),
onKeyDown: _CB.onKeyDown.bind(this),
onMouseOver: _CB.onMouseOver.bind(this),
onMouseLeave: _CB.onMouseLeave.bind(this),
Expand Down Expand Up @@ -911,6 +933,7 @@ var _dropdown = {
setTimeout(() => {
this.DOM.input.focus();
this.toggleFocusClass(true);
this.setRangeAtStartEnd(false);
});
closeOnSelect && setTimeout(this.dropdown.hide.bind(this)); // hide selected suggestion

Expand Down
43 changes: 33 additions & 10 deletions dist/tagify.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Tagify (v 4.16.2) - tags input component
* By Yair Even-Or
* Tagify (v 4.16.3) - tags input component
* By undefined
* https://github.com/yairEO/tagify
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -354,7 +354,7 @@
// after selecting a suggetion, should the typed text input remain or be cleared
position: 'all',
// 'manual' / 'text' / 'all'
appendTarget: null // defaults to document.body one DOM has been loaded
appendTarget: null // defaults to document.body once DOM has been loaded

},
hooks: {
Expand Down Expand Up @@ -603,17 +603,20 @@
parentsPositions,
ddElm = this.DOM.dropdown,
placeAbove = _sd.placeAbove,
viewportHeight = document.documentElement.clientHeight,
viewportWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0),
isDefaultAppendTarget = _sd.appendTarget === document.body,
appendTargetScrollTop = isDefaultAppendTarget ? window.pageYOffset : _sd.appendTarget.scrollTop,
root = document.fullscreenElement || document.webkitFullscreenElement || document.documentElement,
viewportHeight = root.clientHeight,
viewportWidth = Math.max(root.clientWidth || 0, window.innerWidth || 0),
positionTo = viewportWidth > 480 ? _sd.position : 'all',
ddTarget = this.DOM[positionTo == 'input' ? 'input' : 'scope'];
ddHeight = ddHeight || ddElm.clientHeight;

function getParentsPositions(p) {
var left = 0,
top = 0;
top = 0; // when in element-fullscreen mode, do not go above the fullscreened-element

while (p) {
while (p && p != root) {
left += p.offsetLeft || 0;
top += p.offsetTop || 0;
p = p.parentNode;
Expand All @@ -625,6 +628,18 @@
};
}

function getAccumulatedAncestorsScrollTop() {
var scrollTop = 0,
p = _sd.appendTarget.parentNode;

while (p) {
scrollTop += p.scrollTop || 0;
p = p.parentNode;
}

return scrollTop;
}

if (!this.state.dropdown.visible) return;

if (positionTo == 'text') {
Expand All @@ -634,19 +649,26 @@
left = rect.left;
width = 'auto';
} else {
parentsPositions = getParentsPositions(this.settings.dropdown.appendTarget);
parentsPositions = getParentsPositions(_sd.appendTarget);
rect = ddTarget.getBoundingClientRect();
top = rect.top - parentsPositions.top;
bottom = rect.bottom - 1 - parentsPositions.top;
left = rect.left - parentsPositions.left;
width = rect.width + 'px';
} // if the "append target" isn't the default, correct the `top` variable by ignoring any scrollTop of the target's Ancestors


if (!isDefaultAppendTarget) {
let accumulatedAncestorsScrollTop = getAccumulatedAncestorsScrollTop();
top += accumulatedAncestorsScrollTop;
bottom += accumulatedAncestorsScrollTop;
}

top = Math.floor(top);
bottom = Math.ceil(bottom);
placeAbove = placeAbove === undefined ? viewportHeight - rect.bottom < ddHeight : placeAbove; // flip vertically if there is no space for the dropdown below the input

ddElm.style.cssText = "left:" + (left + window.pageXOffset) + "px; width:" + width + ";" + (placeAbove ? "top: " + (top + window.pageYOffset) + "px" : "top: " + (bottom + window.pageYOffset) + "px");
ddElm.style.cssText = "left:" + (left + window.pageXOffset) + "px; width:" + width + ";" + (placeAbove ? "top: " + (top + appendTargetScrollTop) + "px" : "top: " + (bottom + appendTargetScrollTop) + "px");
ddElm.setAttribute('placement', placeAbove ? "top" : "bottom");
ddElm.setAttribute('position', positionTo);
},
Expand All @@ -664,7 +686,7 @@
var _CB = this.dropdown.events.callbacks,
// callback-refs
_CBR = this.listeners.dropdown = this.listeners.dropdown || {
position: this.dropdown.position.bind(this),
position: this.dropdown.position.bind(this, null),
onKeyDown: _CB.onKeyDown.bind(this),
onMouseOver: _CB.onMouseOver.bind(this),
onMouseLeave: _CB.onMouseLeave.bind(this),
Expand Down Expand Up @@ -917,6 +939,7 @@
setTimeout(() => {
this.DOM.input.focus();
this.toggleFocusClass(true);
this.setRangeAtStartEnd(false);
});
closeOnSelect && setTimeout(this.dropdown.hide.bind(this)); // hide selected suggestion

Expand Down
6 changes: 3 additions & 3 deletions dist/tagify.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/tagify.polyfills.min.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Tagify (v 4.16.2) - tags input component
* By Yair Even-Or
* Tagify (v 4.16.3) - tags input component
* By undefined
* https://github.com/yairEO/tagify
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yaireo/tagify",
"version": "4.16.2",
"version": "4.16.3",
"homepage": "https://github.com/yairEO/tagify",
"description": "lightweight, efficient Tags input component in Vanilla JS / React / Angular [super customizable, tiny size & top performance]",
"keywords": [
Expand Down

0 comments on commit ada4473

Please sign in to comment.