Typing animation plugin code

 


<div class="text-3">And I'm a <span class="type"></span></div>


<script src="typed.js"></script>
<script>
    var typednew Typed(".type",{
        strings: ["Programmer","Designer","Web developer"],
        typeSpeed:100,
        backSpeed:60,
        loop:true
    });
</script>


typed.js

/*!
 * 
 *   typed.js - A JavaScript Typing Animation Library
 *   Author: Matt Boldt <me@mattboldt.com>
 *   Version: v2.0.11
 *   Url: https://github.com/mattboldt/typed.js
 *   License(s): MIT
 * 
 */
(function webpackUniversalModuleDefinition(rootfactory) {
    if(typeof exports === 'object' && typeof module === 'object')
        module.exports = factory();
    else if(typeof define === 'function' && define.amd)
        define([], factory);
    else if(typeof exports === 'object')
        exports["Typed"] = factory();
    else
        root["Typed"] = factory();
})(thisfunction() {
return /******/ (function(modules) { // webpackBootstrap
/******/    // The module cache
/******/    var installedModules = {};
/******/
/******/    // The require function
/******/    function __webpack_require__(moduleId) {
/******/
/******/        // Check if module is in cache
/******/        if(installedModules[moduleId])
/******/            return installedModules[moduleId].exports;
/******/
/******/        // Create a new module (and put it into the cache)
/******/        var module = installedModules[moduleId] = {
/******/            exports: {},
/******/            idmoduleId,
/******/            loadedfalse
/******/        };
/******/
/******/        // Execute the module function
/******/        modules[moduleId].call(module.exportsmodulemodule.exports__webpack_require__);
/******/
/******/        // Flag the module as loaded
/******/        module.loaded = true;
/******/
/******/        // Return the exports of the module
/******/        return module.exports;
/******/    }
/******/
/******/
/******/    // expose the modules object (__webpack_modules__)
/******/    __webpack_require__.m = modules;
/******/
/******/    // expose the module cache
/******/    __webpack_require__.c = installedModules;
/******/
/******/    // __webpack_public_path__
/******/    __webpack_require__.p = "";
/******/
/******/    // Load entry module and return exports
/******/    return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(moduleexports__webpack_require__) {

    'use strict';
    
    Object.defineProperty(exports'__esModule', {
      valuetrue
    });
    
    var _createClass = (function () { function defineProperties(targetprops) { for (var i = 0i < props.lengthi++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = trueif ('value' in descriptor) descriptor.writable = trueObject.defineProperty(target, descriptor.keydescriptor); } } return function (ConstructorprotoPropsstaticProps) { if (protoPropsdefineProperties(Constructor.prototypeprotoProps); if (staticPropsdefineProperties(ConstructorstaticProps); return Constructor; }; })();
    
    function _classCallCheck(instanceConstructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
    
    var _initializerJs = __webpack_require__(1);
    
    var _htmlParserJs = __webpack_require__(3);
    
    /**
     * Welcome to Typed.js!
     * @param {string} elementId HTML element ID _OR_ HTML element
     * @param {object} options options object
     * @returns {object} a new Typed object
     */
    
    var Typed = (function () {
      function Typed(elementIdoptions) {
        _classCallCheck(thisTyped);
    
        // Initialize it up
        _initializerJs.initializer.load(thisoptionselementId);
        // All systems go!
        this.begin();
      }
    
      /**
       * Toggle start() and stop() of the Typed instance
       * @public
       */
    
      _createClass(Typed, [{
        key'toggle',
        valuefunction toggle() {
          this.pause.status ? this.start() : this.stop();
        }
    
        /**
         * Stop typing / backspacing and enable cursor blinking
         * @public
         */
      }, {
        key'stop',
        valuefunction stop() {
          if (this.typingCompletereturn;
          if (this.pause.statusreturn;
          this.toggleBlinking(true);
          this.pause.status = true;
          this.options.onStop(this.arrayPosthis);
        }
    
        /**
         * Start typing / backspacing after being stopped
         * @public
         */
      }, {
        key'start',
        valuefunction start() {
          if (this.typingCompletereturn;
          if (!this.pause.statusreturn;
          this.pause.status = false;
          if (this.pause.typewrite) {
            this.typewrite(this.pause.curStringthis.pause.curStrPos);
          } else {
            this.backspace(this.pause.curStringthis.pause.curStrPos);
          }
          this.options.onStart(this.arrayPosthis);
        }
    
        /**
         * Destroy this instance of Typed
         * @public
         */
      }, {
        key'destroy',
        valuefunction destroy() {
          this.reset(false);
          this.options.onDestroy(this);
        }
    
        /**
         * Reset Typed and optionally restarts
         * @param {boolean} restart
         * @public
         */
      }, {
        key'reset',
        valuefunction reset() {
          var restart = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
    
          clearInterval(this.timeout);
          this.replaceText('');
          if (this.cursor && this.cursor.parentNode) {
            this.cursor.parentNode.removeChild(this.cursor);
            this.cursor = null;
          }
          this.strPos = 0;
          this.arrayPos = 0;
          this.curLoop = 0;
          if (restart) {
            this.insertCursor();
            this.options.onReset(this);
            this.begin();
          }
        }
    
        /**
         * Begins the typing animation
         * @private
         */
      }, {
        key'begin',
        valuefunction begin() {
          var _this = this;
    
          this.options.onBegin(this);
          this.typingComplete = false;
          this.shuffleStringsIfNeeded(this);
          this.insertCursor();
          if (this.bindInputFocusEventsthis.bindFocusEvents();
          this.timeout = setTimeout(function () {
            // Check if there is some text in the element, if yes start by backspacing the default message
            if (!_this.currentElContent || _this.currentElContent.length === 0) {
              _this.typewrite(_this.strings[_this.sequence[_this.arrayPos]], _this.strPos);
            } else {
              // Start typing
              _this.backspace(_this.currentElContent, _this.currentElContent.length);
            }
          }, this.startDelay);
        }
    
        /**
         * Called for each character typed
         * @param {string} curString the current string in the strings array
         * @param {number} curStrPos the current position in the curString
         * @private
         */
      }, {
        key'typewrite',
        valuefunction typewrite(curStringcurStrPos) {
          var _this2 = this;
    
          if (this.fadeOut && this.el.classList.contains(this.fadeOutClass)) {
            this.el.classList.remove(this.fadeOutClass);
            if (this.cursorthis.cursor.classList.remove(this.fadeOutClass);
          }
    
          var humanize = this.humanizer(this.typeSpeed);
          var numChars = 1;
    
          if (this.pause.status === true) {
            this.setPauseStatus(curStringcurStrPostrue);
            return;
          }
    
          // contain typing function in a timeout humanize'd delay
          this.timeout = setTimeout(function () {
            // skip over any HTML chars
            curStrPos = _htmlParserJs.htmlParser.typeHtmlChars(curStringcurStrPos_this2);
    
            var pauseTime = 0;
            var substr = curString.substr(curStrPos);
            // check for an escape character before a pause value
            // format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^
            // single ^ are removed from string
            if (substr.charAt(0) === '^') {
              if (/^\^\d+/.test(substr)) {
                var skip = 1// skip at least 1
                substr = /\d+/.exec(substr)[0];
                skip += substr.length;
                pauseTime = parseInt(substr);
                _this2.temporaryPause = true;
                _this2.options.onTypingPaused(_this2.arrayPos_this2);
                // strip out the escape character and pause value so they're not printed
                curString = curString.substring(0curStrPos) + curString.substring(curStrPos + skip);
                _this2.toggleBlinking(true);
              }
            }
    
            // check for skip characters formatted as
            // "this is a `string to print NOW` ..."
            if (substr.charAt(0) === '`') {
              while (curString.substr(curStrPos + numChars).charAt(0) !== '`') {
                numChars++;
                if (curStrPos + numChars > curString.lengthbreak;
              }
              // strip out the escape characters and append all the string in between
              var stringBeforeSkip = curString.substring(0curStrPos);
              var stringSkipped = curString.substring(stringBeforeSkip.length + 1curStrPos + numChars);
              var stringAfterSkip = curString.substring(curStrPos + numChars + 1);
              curString = stringBeforeSkip + stringSkipped + stringAfterSkip;
              numChars--;
            }
    
            // timeout for any pause after a character
            _this2.timeout = setTimeout(function () {
              // Accounts for blinking while paused
              _this2.toggleBlinking(false);
    
              // We're done with this sentence!
              if (curStrPos >= curString.length) {
                _this2.doneTyping(curStringcurStrPos);
              } else {
                _this2.keepTyping(curStringcurStrPosnumChars);
              }
              // end of character pause
              if (_this2.temporaryPause) {
                _this2.temporaryPause = false;
                _this2.options.onTypingResumed(_this2.arrayPos_this2);
              }
            }, pauseTime);
    
            // humanized value for typing
          }, humanize);
        }
    
        /**
         * Continue to the next string & begin typing
         * @param {string} curString the current string in the strings array
         * @param {number} curStrPos the current position in the curString
         * @private
         */
      }, {
        key'keepTyping',
        valuefunction keepTyping(curStringcurStrPosnumChars) {
          // call before functions if applicable
          if (curStrPos === 0) {
            this.toggleBlinking(false);
            this.options.preStringTyped(this.arrayPosthis);
          }
          // start typing each new char into existing string
          // curString: arg, this.el.html: original text inside element
          curStrPos += numChars;
          var nextString = curString.substr(0curStrPos);
          this.replaceText(nextString);
          // loop the function
          this.typewrite(curStringcurStrPos);
        }
    
        /**
         * We're done typing the current string
         * @param {string} curString the current string in the strings array
         * @param {number} curStrPos the current position in the curString
         * @private
         */
      }, {
        key'doneTyping',
        valuefunction doneTyping(curStringcurStrPos) {
          var _this3 = this;
    
          // fires callback function
          this.options.onStringTyped(this.arrayPosthis);
          this.toggleBlinking(true);
          // is this the final string
          if (this.arrayPos === this.strings.length - 1) {
            // callback that occurs on the last typed string
            this.complete();
            // quit if we wont loop back
            if (this.loop === false || this.curLoop === this.loopCount) {
              return;
            }
          }
          this.timeout = setTimeout(function () {
            _this3.backspace(curStringcurStrPos);
          }, this.backDelay);
        }
    
        /**
         * Backspaces 1 character at a time
         * @param {string} curString the current string in the strings array
         * @param {number} curStrPos the current position in the curString
         * @private
         */
      }, {
        key'backspace',
        valuefunction backspace(curStringcurStrPos) {
          var _this4 = this;
    
          if (this.pause.status === true) {
            this.setPauseStatus(curStringcurStrPostrue);
            return;
          }
          if (this.fadeOutreturn this.initFadeOut();
    
          this.toggleBlinking(false);
          var humanize = this.humanizer(this.backSpeed);
    
          this.timeout = setTimeout(function () {
            curStrPos = _htmlParserJs.htmlParser.backSpaceHtmlChars(curStringcurStrPos_this4);
            // replace text with base text + typed characters
            var curStringAtPosition = curString.substr(0curStrPos);
            _this4.replaceText(curStringAtPosition);
    
            // if smartBack is enabled
            if (_this4.smartBackspace) {
              // the remaining part of the current string is equal of the same part of the new string
              var nextString = _this4.strings[_this4.arrayPos + 1];
              if (nextString && curStringAtPosition === nextString.substr(0curStrPos)) {
                _this4.stopNum = curStrPos;
              } else {
                _this4.stopNum = 0;
              }
            }
    
            // if the number (id of character in current string) is
            // less than the stop number, keep going
            if (curStrPos > _this4.stopNum) {
              // subtract characters one by one
              curStrPos--;
              // loop the function
              _this4.backspace(curStringcurStrPos);
            } else if (curStrPos <= _this4.stopNum) {
              // if the stop number has been reached, increase
              // array position to next string
              _this4.arrayPos++;
              // When looping, begin at the beginning after backspace complete
              if (_this4.arrayPos === _this4.strings.length) {
                _this4.arrayPos = 0;
                _this4.options.onLastStringBackspaced();
                _this4.shuffleStringsIfNeeded();
                _this4.begin();
              } else {
                _this4.typewrite(_this4.strings[_this4.sequence[_this4.arrayPos]], curStrPos);
              }
            }
            // humanized value for typing
          }, humanize);
        }
    
        /**
         * Full animation is complete
         * @private
         */
      }, {
        key'complete',
        valuefunction complete() {
          this.options.onComplete(this);
          if (this.loop) {
            this.curLoop++;
          } else {
            this.typingComplete = true;
          }
        }
    
        /**
         * Has the typing been stopped
         * @param {string} curString the current string in the strings array
         * @param {number} curStrPos the current position in the curString
         * @param {boolean} isTyping
         * @private
         */
      }, {
        key'setPauseStatus',
        valuefunction setPauseStatus(curStringcurStrPosisTyping) {
          this.pause.typewrite = isTyping;
          this.pause.curString = curString;
          this.pause.curStrPos = curStrPos;
        }
    
        /**
         * Toggle the blinking cursor
         * @param {boolean} isBlinking
         * @private
         */
      }, {
        key'toggleBlinking',
        valuefunction toggleBlinking(isBlinking) {
          if (!this.cursorreturn;
          // if in paused state, don't toggle blinking a 2nd time
          if (this.pause.statusreturn;
          if (this.cursorBlinking === isBlinkingreturn;
          this.cursorBlinking = isBlinking;
          if (isBlinking) {
            this.cursor.classList.add('typed-cursor--blink');
          } else {
            this.cursor.classList.remove('typed-cursor--blink');
          }
        }
    
        /**
         * Speed in MS to type
         * @param {number} speed
         * @private
         */
      }, {
        key'humanizer',
        valuefunction humanizer(speed) {
          return Math.round(Math.random() * speed / 2) + speed;
        }
    
        /**
         * Shuffle the sequence of the strings array
         * @private
         */
      }, {
        key'shuffleStringsIfNeeded',
        valuefunction shuffleStringsIfNeeded() {
          if (!this.shufflereturn;
          this.sequence = this.sequence.sort(function () {
            return Math.random() - 0.5;
          });
        }
    
        /**
         * Adds a CSS class to fade out current string
         * @private
         */
      }, {
        key'initFadeOut',
        valuefunction initFadeOut() {
          var _this5 = this;
    
          this.el.className += ' ' + this.fadeOutClass;
          if (this.cursorthis.cursor.className += ' ' + this.fadeOutClass;
          return setTimeout(function () {
            _this5.arrayPos++;
            _this5.replaceText('');
    
            // Resets current string if end of loop reached
            if (_this5.strings.length > _this5.arrayPos) {
              _this5.typewrite(_this5.strings[_this5.sequence[_this5.arrayPos]], 0);
            } else {
              _this5.typewrite(_this5.strings[0], 0);
              _this5.arrayPos = 0;
            }
          }, this.fadeOutDelay);
        }
    
        /**
         * Replaces current text in the HTML element
         * depending on element type
         * @param {string} str
         * @private
         */
      }, {
        key'replaceText',
        valuefunction replaceText(str) {
          if (this.attr) {
            this.el.setAttribute(this.attrstr);
          } else {
            if (this.isInput) {
              this.el.value = str;
            } else if (this.contentType === 'html') {
              this.el.innerHTML = str;
            } else {
              this.el.textContent = str;
            }
          }
        }
    
        /**
         * If using input elements, bind focus in order to
         * start and stop the animation
         * @private
         */
      }, {
        key'bindFocusEvents',
        valuefunction bindFocusEvents() {
          var _this6 = this;
    
          if (!this.isInputreturn;
          this.el.addEventListener('focus'function (e) {
            _this6.stop();
          });
          this.el.addEventListener('blur'function (e) {
            if (_this6.el.value && _this6.el.value.length !== 0) {
              return;
            }
            _this6.start();
          });
        }
    
        /**
         * On init, insert the cursor element
         * @private
         */
      }, {
        key'insertCursor',
        valuefunction insertCursor() {
          if (!this.showCursorreturn;
          if (this.cursorreturn;
          this.cursor = document.createElement('span');
          this.cursor.className = 'typed-cursor';
          this.cursor.innerHTML = this.cursorChar;
          this.el.parentNode && this.el.parentNode.insertBefore(this.cursorthis.el.nextSibling);
        }
      }]);
    
      return Typed;
    })();
    
    exports['default'] = Typed;
    module.exports = exports['default'];

/***/ }),
/* 1 */
/***/ (function(moduleexports__webpack_require__) {

    'use strict';
    
    Object.defineProperty(exports, '__esModule', {
      valuetrue
    });
    
    var _extends = Object.assign || function (target) { for (var i = 1i < arguments.lengthi++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(sourcekey)) { target[key] = source[key]; } } } return target; };
    
    var _createClass = (function () { function defineProperties(targetprops) { for (var i = 0i < props.lengthi++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = trueif ('value' in descriptor) descriptor.writable = trueObject.defineProperty(target, descriptor.keydescriptor); } } return function (ConstructorprotoPropsstaticProps) { if (protoPropsdefineProperties(Constructor.prototypeprotoProps); if (staticPropsdefineProperties(ConstructorstaticProps); return Constructor; }; })();
    
    function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default'obj }; }
    
    function _classCallCheck(instanceConstructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
    
    var _defaultsJs = __webpack_require__(2);
    
    var _defaultsJs2 = _interopRequireDefault(_defaultsJs);
    
    /**
     * Initialize the Typed object
     */
    
    var Initializer = (function () {
      function Initializer() {
        _classCallCheck(thisInitializer);
      }
    
      _createClass(Initializer, [{
        key'load',
    
        /**
         * Load up defaults & options on the Typed instance
         * @param {Typed} self instance of Typed
         * @param {object} options options object
         * @param {string} elementId HTML element ID _OR_ instance of HTML element
         * @private
         */
    
        valuefunction load(selfoptionselementId) {
          // chosen element to manipulate text
          if (typeof elementId === 'string') {
            self.el = document.querySelector(elementId);
          } else {
            self.el = elementId;
          }
    
          self.options = _extends({}, _defaultsJs2['default'], options);
    
          // attribute to type into
          self.isInput = self.el.tagName.toLowerCase() === 'input';
          self.attr = self.options.attr;
          self.bindInputFocusEvents = self.options.bindInputFocusEvents;
    
          // show cursor
          self.showCursor = self.isInput ? false : self.options.showCursor;
    
          // custom cursor
          self.cursorChar = self.options.cursorChar;
    
          // Is the cursor blinking
          self.cursorBlinking = true;
    
          // text content of element
          self.elContent = self.attr ? self.el.getAttribute(self.attr) : self.el.textContent;
    
          // html or plain text
          self.contentType = self.options.contentType;
    
          // typing speed
          self.typeSpeed = self.options.typeSpeed;
    
          // add a delay before typing starts
          self.startDelay = self.options.startDelay;
    
          // backspacing speed
          self.backSpeed = self.options.backSpeed;
    
          // only backspace what doesn't match the previous string
          self.smartBackspace = self.options.smartBackspace;
    
          // amount of time to wait before backspacing
          self.backDelay = self.options.backDelay;
    
          // Fade out instead of backspace
          self.fadeOut = self.options.fadeOut;
          self.fadeOutClass = self.options.fadeOutClass;
          self.fadeOutDelay = self.options.fadeOutDelay;
    
          // variable to check whether typing is currently paused
          self.isPaused = false;
    
          // input strings of text
          self.strings = self.options.strings.map(function (s) {
            return s.trim();
          });
    
          // div containing strings
          if (typeof self.options.stringsElement === 'string') {
            self.stringsElement = document.querySelector(self.options.stringsElement);
          } else {
            self.stringsElement = self.options.stringsElement;
          }
    
          if (self.stringsElement) {
            self.strings = [];
            self.stringsElement.style.display = 'none';
            var strings = Array.prototype.slice.apply(self.stringsElement.children);
            var stringsLength = strings.length;
    
            if (stringsLength) {
              for (var i = 0i < stringsLengthi += 1) {
                var stringEl = strings[i];
                self.strings.push(stringEl.innerHTML.trim());
              }
            }
          }
    
          // character number position of current string
          self.strPos = 0;
    
          // current array position
          self.arrayPos = 0;
    
          // index of string to stop backspacing on
          self.stopNum = 0;
    
          // Looping logic
          self.loop = self.options.loop;
          self.loopCount = self.options.loopCount;
          self.curLoop = 0;
    
          // shuffle the strings
          self.shuffle = self.options.shuffle;
          // the order of strings
          self.sequence = [];
    
          self.pause = {
            statusfalse,
            typewritetrue,
            curString'',
            curStrPos0
          };
    
          // When the typing is complete (when not looped)
          self.typingComplete = false;
    
          // Set the order in which the strings are typed
          for (var i in self.strings) {
            self.sequence[i] = i;
          }
    
          // If there is some text in the element
          self.currentElContent = this.getCurrentElContent(self);
    
          self.autoInsertCss = self.options.autoInsertCss;
    
          this.appendAnimationCss(self);
        }
      }, {
        key'getCurrentElContent',
        valuefunction getCurrentElContent(self) {
          var elContent = '';
          if (self.attr) {
            elContent = self.el.getAttribute(self.attr);
          } else if (self.isInput) {
            elContent = self.el.value;
          } else if (self.contentType === 'html') {
            elContent = self.el.innerHTML;
          } else {
            elContent = self.el.textContent;
          }
          return elContent;
        }
      }, {
        key'appendAnimationCss',
        valuefunction appendAnimationCss(self) {
          var cssDataName = 'data-typed-js-css';
          if (!self.autoInsertCss) {
            return;
          }
          if (!self.showCursor && !self.fadeOut) {
            return;
          }
          if (document.querySelector('[' + cssDataName + ']')) {
            return;
          }
    
          var css = document.createElement('style');
          css.type = 'text/css';
          css.setAttribute(cssDataNametrue);
    
          var innerCss = '';
          if (self.showCursor) {
            innerCss += '\n        .typed-cursor{\n          opacity: 1;\n        }\n        .typed-cursor.typed-cursor--blink{\n          animation: typedjsBlink 0.7s infinite;\n          -webkit-animation: typedjsBlink 0.7s infinite;\n                  animation: typedjsBlink 0.7s infinite;\n        }\n        @keyframes typedjsBlink{\n          50% { opacity: 0.0; }\n        }\n        @-webkit-keyframes typedjsBlink{\n          0% { opacity: 1; }\n          50% { opacity: 0.0; }\n          100% { opacity: 1; }\n        }\n      ';
          }
          if (self.fadeOut) {
            innerCss += '\n        .typed-fade-out{\n          opacity: 0;\n          transition: opacity .25s;\n        }\n        .typed-cursor.typed-cursor--blink.typed-fade-out{\n          -webkit-animation: 0;\n          animation: 0;\n        }\n      ';
          }
          if (css.length === 0) {
            return;
          }
          css.innerHTML = innerCss;
          document.body.appendChild(css);
        }
      }]);
    
      return Initializer;
    })();
    
    exports['default'] = Initializer;
    var initializer = new Initializer();
    exports.initializer = initializer;

/***/ }),
/* 2 */
/***/ (function(moduleexports) {

    /**
     * Defaults & options
     * @returns {object} Typed defaults & options
     * @public
     */
    
    'use strict';
    
    Object.defineProperty(exports, '__esModule', {
      valuetrue
    });
    var defaults = {
      /**
       * @property {array} strings strings to be typed
       * @property {string} stringsElement ID of element containing string children
       */
      strings: ['These are the default values...''You know what you should do?''Use your own!''Have a great day!'],
      stringsElementnull,
    
      /**
       * @property {number} typeSpeed type speed in milliseconds
       */
      typeSpeed0,
    
      /**
       * @property {number} startDelay time before typing starts in milliseconds
       */
      startDelay0,
    
      /**
       * @property {number} backSpeed backspacing speed in milliseconds
       */
      backSpeed0,
    
      /**
       * @property {boolean} smartBackspace only backspace what doesn't match the previous string
       */
      smartBackspacetrue,
    
      /**
       * @property {boolean} shuffle shuffle the strings
       */
      shufflefalse,
    
      /**
       * @property {number} backDelay time before backspacing in milliseconds
       */
      backDelay700,
    
      /**
       * @property {boolean} fadeOut Fade out instead of backspace
       * @property {string} fadeOutClass css class for fade animation
       * @property {boolean} fadeOutDelay Fade out delay in milliseconds
       */
      fadeOutfalse,
      fadeOutClass'typed-fade-out',
      fadeOutDelay500,
    
      /**
       * @property {boolean} loop loop strings
       * @property {number} loopCount amount of loops
       */
      loopfalse,
      loopCountInfinity,
    
      /**
       * @property {boolean} showCursor show cursor
       * @property {string} cursorChar character for cursor
       * @property {boolean} autoInsertCss insert CSS for cursor and fadeOut into HTML <head>
       */
      showCursortrue,
      cursorChar'|',
      autoInsertCsstrue,
    
      /**
       * @property {string} attr attribute for typing
       * Ex: input placeholder, value, or just HTML text
       */
      attrnull,
    
      /**
       * @property {boolean} bindInputFocusEvents bind to focus and blur if el is text input
       */
      bindInputFocusEventsfalse,
    
      /**
       * @property {string} contentType 'html' or 'null' for plaintext
       */
      contentType'html',
    
      /**
       * Before it begins typing
       * @param {Typed} self
       */
      onBeginfunction onBegin(self) {},
    
      /**
       * All typing is complete
       * @param {Typed} self
       */
      onCompletefunction onComplete(self) {},
    
      /**
       * Before each string is typed
       * @param {number} arrayPos
       * @param {Typed} self
       */
      preStringTypedfunction preStringTyped(arrayPosself) {},
    
      /**
       * After each string is typed
       * @param {number} arrayPos
       * @param {Typed} self
       */
      onStringTypedfunction onStringTyped(arrayPosself) {},
    
      /**
       * During looping, after last string is typed
       * @param {Typed} self
       */
      onLastStringBackspacedfunction onLastStringBackspaced(self) {},
    
      /**
       * Typing has been stopped
       * @param {number} arrayPos
       * @param {Typed} self
       */
      onTypingPausedfunction onTypingPaused(arrayPosself) {},
    
      /**
       * Typing has been started after being stopped
       * @param {number} arrayPos
       * @param {Typed} self
       */
      onTypingResumedfunction onTypingResumed(arrayPosself) {},
    
      /**
       * After reset
       * @param {Typed} self
       */
      onResetfunction onReset(self) {},
    
      /**
       * After stop
       * @param {number} arrayPos
       * @param {Typed} self
       */
      onStopfunction onStop(arrayPosself) {},
    
      /**
       * After start
       * @param {number} arrayPos
       * @param {Typed} self
       */
      onStartfunction onStart(arrayPosself) {},
    
      /**
       * After destroy
       * @param {Typed} self
       */
      onDestroyfunction onDestroy(self) {}
    };
    
    exports['default'] = defaults;
    module.exports = exports['default'];

/***/ }),
/* 3 */
/***/ (function(moduleexports) {

    /**
     * TODO: These methods can probably be combined somehow
     * Parse HTML tags & HTML Characters
     */
    
    'use strict';
    
    Object.defineProperty(exports, '__esModule', {
      valuetrue
    });
    
    var _createClass = (function () { function defineProperties(targetprops) { for (var i = 0i < props.lengthi++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = trueif ('value' in descriptor) descriptor.writable = trueObject.defineProperty(target, descriptor.keydescriptor); } } return function (ConstructorprotoPropsstaticProps) { if (protoPropsdefineProperties(Constructor.prototypeprotoProps); if (staticPropsdefineProperties(ConstructorstaticProps); return Constructor; }; })();
    
    function _classCallCheck(instanceConstructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
    
    var HTMLParser = (function () {
      function HTMLParser() {
        _classCallCheck(thisHTMLParser);
      }
    
      _createClass(HTMLParser, [{
        key'typeHtmlChars',
    
        /**
         * Type HTML tags & HTML Characters
         * @param {string} curString Current string
         * @param {number} curStrPos Position in current string
         * @param {Typed} self instance of Typed
         * @returns {number} a new string position
         * @private
         */
    
        valuefunction typeHtmlChars(curStringcurStrPosself) {
          if (self.contentType !== 'html'return curStrPos;
          var curChar = curString.substr(curStrPos).charAt(0);
          if (curChar === '<' || curChar === '&') {
            var endTag = '';
            if (curChar === '<') {
              endTag = '>';
            } else {
              endTag = ';';
            }
            while (curString.substr(curStrPos + 1).charAt(0) !== endTag) {
              curStrPos++;
              if (curStrPos + 1 > curString.length) {
                break;
              }
            }
            curStrPos++;
          }
          return curStrPos;
        }
    
        /**
         * Backspace HTML tags and HTML Characters
         * @param {string} curString Current string
         * @param {number} curStrPos Position in current string
         * @param {Typed} self instance of Typed
         * @returns {number} a new string position
         * @private
         */
      }, {
        key'backSpaceHtmlChars',
        valuefunction backSpaceHtmlChars(curStringcurStrPosself) {
          if (self.contentType !== 'html'return curStrPos;
          var curChar = curString.substr(curStrPos).charAt(0);
          if (curChar === '>' || curChar === ';') {
            var endTag = '';
            if (curChar === '>') {
              endTag = '<';
            } else {
              endTag = '&';
            }
            while (curString.substr(curStrPos - 1).charAt(0) !== endTag) {
              curStrPos--;
              if (curStrPos < 0) {
                break;
              }
            }
            curStrPos--;
          }
          return curStrPos;
        }
      }]);
    
      return HTMLParser;
    })();
    
    exports['default'] = HTMLParser;
    var htmlParser = new HTMLParser();
    exports.htmlParser = htmlParser;

/***/ })
/******/ ])
});
;

Comments

Popular posts from this blog

D WEB LINK