Socket
Socket
Sign inDemoInstall

advanced-ellipsis

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    advanced-ellipsis

Advanced ellipsis available in JS


Version published
Weekly downloads
2
decreased by-50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Advanced Ellipsis

It provides advanced ellipsis capabilities when the content box is small and only a part of the content needs to be shown, and part of the content is important.

Usage

Module usage without npm

npm i advanced-ellipsis
import AdvancedEllipsis from 'advanced-ellipsis';
const advancedEllipsis = new AdvancedEllipsis();
advancedEllipsis.start();

Module usage with CDN

<script type="module">
	import AdvancedEllipsis from 'https://cdn.jsdelivr.net/npm/advanced-ellipsis/dist/advanced-ellipsis.esm.js';
	const advancedEllipsis = new AdvancedEllipsis();
	advancedEllipsis.start();
</script>

<script> tag Usage with CDN

<script src="https://cdn.jsdelivr.net/npm/advanced-ellipsis/dist/advanced-ellipsis.js"></script>
<script>
	var advancedEllipsis;
	window.onload = function () {
		advancedEllipsis = new AdvancedEllipsis();
		advancedEllipsis.start();
	};
</script>



Demo

https://chae-sumin.github.io/advanced-ellipsis/



Methods

constructor

const advancedEllipsis = new AdvancedEllipsis($selector);
or
const advancedEllipsis = new AdvancedEllipsis($options);
or
const advancedEllipsis = new AdvancedEllipsis($options, $selector);
// $selector is a string
// $options is an object

If $selector is not entered, '[data-ellipsis]' is set as the default.

Methods

MethodsDescriptionParameterreturn
startSet ellipsis according to the set $options and $attributes.
$status becomes true
-this
destroyRestore the ellipsis set through the start().
$status becomes false
-this
restartRestart when $status is start(true).-this

MethodsDescriptionParameterParameter typereturn
setElementsSet the element according to the $selector.
Existing elements are automatically destroy()
$selectorstringthis
getElementsReturns the set elements in an array.
Changing the returned array does not change the elements
(it is possible to change the element itself).
--Array<HTMLElement>
setOptionsSet the options according to the $options.
Calls restart() when options have changed
$optionsobjectthis
getOptionsCalls the set option.
Converting the returned object does not change the options.
--object
getOptionReturns the option value corresponding to $optionKey$optionKeystringboolean | number | string | object
getStatusReturns $status. If it is true, start() is in operation. If false, it is before start() or after destroy().--$status (boolean)



Options and Attributes

common options

OptionDescriptionTypeDefault
mutationObserverWhen this value is true and $status is start(true),
change the set element is detected.
Elements whose changes are detected are reset.
booleantrue
defaultStylesIf the value is true, apply ellipsis by default.
If false, you have to modify the style yourself to ellipsis.
defaultStyles = {
 overflow: hidden;
 white-space: nowrap;
 text-overflow: ellipsis;
}
booleantrue
useCloneNodeIf the value is true, use cloneNode to determine ellipsis.
If false, use scrollWidth.
booleanfalse
showOptionIt gives special effects to ellipsis processed nodes.
'static': I only apply ellipsis.
'flow': Text flows sideways when a mouse hover or touch is touched.
'flow-auto': Text automatically flows sideways.
'tooltip': Text flows sideways when a mouse hover or touch is touched.
string'static'
correctionValueAdd the calibration value in 'px' to the internal size. (The larger the value, the more generous the ellipsis decision is.)number0

flow options

When showOption or data-ellipsis-show-option is 'flow' or 'flow-auto'

OptionDescriptionTypeUnitDefault
flowDelayThe delay time before the text flows.numberms1000
flowAfterDelayThe delay time after text flow is over.numberms1000
flowSpeedThe speed at which the text flows.numberpx / s50
flowPaddingAdd the space at the end as the text flows.numberpx20
flowCountThe number of flows running after the event occurs.
when the showOption is 'flow'.
number-1
flowCountPreThe number of flows that are executed as soon as the setting is made.
when the showOption is 'flow'.
number-0
flowAutoCountThe number of flows when showOption is 'flow-auto'.number-Infinity

tooltip options

When showOption or data-ellipsis-show-option is 'tooltip'

OptionDescriptionTypeDefault
tooltipShowAlwaysSet to true if you want tooltips to appear even in non-ellipsis text.booleanfalse
tooltipClassThe class applied to the tooltip that is created.
(Strings separated by spacebars)
string'ellipsis_tooltip_box'
tooltipDurationThe time when the tool tip is maintained. (unit: ms)numberDefault
customTooltipStylesApply custom style to tool tip.object{ }

attributes

If the element has the following prop, overwrite the options.

example:

<div data-ellipsis data-ellipsis-show-option="flow-auto">ellipsis text...</div>
AttributesDescription
data-show-optionoverwrite showOption
data-flow-countoverwrite both flowCount and flowAutoCount
data-flow-count-preoverwrite flowCountPre
data-tooltip-show-alwaysoverwrite tooltipShowAlways
data-tooltip-idThe class applied to the tooltip that is created.
data-tooltip-classThe id applied to the tooltip that is created.
(Strings separated by spacebars)



Description

  • Elements only apply if they have only one text note as a child.
  • when showOption is 'flow', 'flow-auto' or 'tooltip',
    it detects mouseover or touchstart and operates.
  • The default value of elements is '[data-ellipsis]'.
  • Always follow the priority below

Options

Attributes > custom Options > default Options


Tooltip Element Class

Attributes > tooltipElementClass


Tooltip Element Styles

!important styles > customTooltipStyles > defaultTooltipStyles > User-entered inline styles > css styles

customTooltipStyles and defaultTooltipStyles will be override User-entered inline styles

License

NPM

Contact

cotnmin@gmail.com

Keywords

FAQs

Last updated on 08 Apr 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc