8000 GitHub - Tikubonn/omitter.js: Omitter.js is a small javascript plugin, it can omit a text content as faster.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Tikubonn/omitter.js

Repository files navigation

omitter.js

Omitter.js is a small javascript plugin, it can omit a text content faster. this plugin thought about reduce reflow count. so probably this plugin is faster than some plugins that using Element.innerText or TextNode.data.

For Example

window.addEventListener("load", function (event){
  // var doms = $(".omitter-target");
  var doms = document.querySelectorAll(".omitter-target");
  var omitter = new Omitter(doms, 3, "..."); // limit to 3 lines.
  omitter.omit();
});

if you want disable omission, you can use omitter.unomit(); method. it show all sentences.

Methods

Method Description
Omitter.omit enable omission mode and update nodes.
Omitter.unomit disable omission mode and update nodes if necessary.
Omitter.update update nodes if omission mode is enabled.
Omitter.toggle toggle omission mode and update nodes.

TODO

  1. I should think whitespace character. the ellipsis ignore whitespace or not?
  2. append a option about optimization for performance. of an ".emitter-character" contain multiple characters, this plugin is able to reduce some calculations.

License

this plugin released under MIT license.

About

Omitter.js is a small javascript plugin, it can omit a text content as faster.

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0