Comparing version 0.1.3 to 0.1.4
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Driver=e():t.Driver=e()}(window,function(){return function(t){var e={};function i(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/dist/",i(i.s=8)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.OVERLAY_OPACITY=.75,e.OVERLAY_PADDING=10,e.OVERLAY_ANIMATE=!0,e.OVERLAY_ZINDEX="999999999",e.ESC_KEY_CODE=27,e.LEFT_KEY_CODE=37,e.RIGHT_KEY_CODE=39,e.ID_OVERLAY="driver-canvas-overlay";var o=e.ID_POPOVER="driver-popover-item",n=e.CLASS_POPOVER_TIP="driver-popover-tip",s=e.CLASS_POPOVER_TITLE="driver-popover-title",h=e.CLASS_POPOVER_DESCRIPTION="driver-popover-description",r=e.CLASS_POPOVER_FOOTER="driver-popover-footer",l=e.CLASS_CLOSE_BTN="driver-close-btn",a=e.CLASS_NEXT_STEP_BTN="driver-next-btn",d=e.CLASS_PREV_STEP_BTN="driver-prev-btn";e.CLASS_BTN_DISABLED="driver-disabled",e.POPOVER_HTML='\n <div id="'+o+'">\n <div class="'+n+'"></div>\n <div class="'+s+'">Popover Title</div>\n <div class="'+h+'">Popover Description</div>\n <div class="'+r+'">\n <a href="javascript:void(0)" class="'+l+'">Close</a>\n <span class="driver-btn-group">\n <a class="'+d+'" href="javascript:void(0)">← Previous</a>\n <a class="'+a+'" href="javascript:void(0)">Next →</a>\n </span>\n </div>\n </div>'},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,n=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),s=i(2),h=(o=s)&&o.__esModule?o:{default:o};var r=function(){function t(e,i,o,n,s,h){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.node=e,this.document=h,this.window=s,this.options=i,this.overlay=n,this.popover=o,this.highlightFinished=!1}return n(t,[{key:"getScreenCoordinates",value:function(){var t=this.node,e=this.document.documentElement.offsetLeft,i=this.document.documentElement.offsetTop;if(t.offsetParent)do{e+=t.offsetLeft,i+=t.offsetTop}while(t=t.offsetParent);return{x:e,y:i}}},{key:"isInView",value:function(){for(var t=this.node.offsetTop,e=this.node.offsetLeft,i=this.node.offsetWidth,o=this.node.offsetHeight,n=this.node;n.offsetParent;)t+=(n=n.offsetParent).offsetTop,e+=n.offsetLeft;return t>=this.window.pageYOffset&&e>=this.window.pageXOffset&&t+o<=this.window.pageYOffset+this.window.innerHeight&&e+i<=this.window.pageXOffset+this.window.innerWidth}},{key:"bringInView",value:function(){if(!this.isInView())if(this.node.scrollIntoView){var t=this.options.scrollIntoViewOptions||{behavior:"smooth",block:"center"};this.node.scrollIntoView(t)}else{var e=this.node.getBoundingClientRect().top+this.window.pageYOffset-this.window.innerHeight/2;this.window.scrollTo(0,e)}}},{key:"getCalculatedPosition",value:function(){var t=this.getScreenCoordinates(),e=new h.default({left:Number.MAX_VALUE,top:Number.MAX_VALUE,right:0,bottom:0});return"number"==typeof t.x&&"number"==typeof t.y&&(this.node.offsetWidth>0||this.node.offsetHeight>0)&&(e.left=Math.min(e.left,t.x),e.top=Math.min(e.top,t.y),e.right=Math.max(e.right,t.x+this.node.offsetWidth),e.bottom=Math.max(e.bottom,t.y+this.node.offsetHeight)),e}},{key:"onDeselected",value:function(){this.hidePopover(),this.highlightFinished=!1,this.options.onDeselected&&this.options.onDeselected(this)}},{key:"onHighlightStarted",value:function(){this.showPopover(),this.highlightFinished=!1,this.options.onHighlightStarted&&this.options.onHighlightStarted(this)}},{key:"onHighlighted",value:function(){this.showPopover(),this.highlightFinished=!0;var t=this.overlay.getLastHighlightedElement(),e=this.popover;this.node!==(t&&t.node)&&(e&&!e.isInView()&&e.bringInView(),this.isInView()||this.bringInView()),this.options.onHighlighted&&this.options.onHighlighted(this)}},{key:"getNode",value:function(){return this.node}},{key:"hidePopover",value:function(){this.popover&&this.popover.hide()}},{key:"showPopover",value:function(){if(this.popover){var t=this.getCalculatedPosition();this.popover.show(t)}}},{key:"getFullPageSize",value:function(){var t=this.document.body,e=this.document.documentElement;return{height:Math.max(t.scrollHeight,t.offsetHeight,e.scrollHeight,e.offsetHeight),width:Math.max(t.scrollWidth,t.offsetWidth,e.scrollWidth,e.offsetWidth)}}}]),t}();e.default=r,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}();var n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e.left,o=void 0===i?0:i,n=e.top,s=void 0===n?0:n,h=e.right,r=void 0===h?0:h,l=e.bottom,a=void 0===l?0:l;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.left=o,this.right=r,this.top=s,this.bottom=a}return o(t,[{key:"canHighlight",value:function(){return this.left<this.right&&this.top<this.bottom}},{key:"equals",value:function(t){return Math.round(this.left)===Math.round(t.left)&&Math.round(this.right)===Math.round(t.right)&&Math.round(this.top)===Math.round(t.top)&&Math.round(this.bottom)===Math.round(t.bottom)}}]),t}();e.default=n,t.exports=e.default},function(t,e,i){"use strict";!function(){for(var t=0,e=["ms","moz","webkit","o"],i=0;i<e.length&&!window.requestAnimationFrame;++i)window.requestAnimationFrame=window[e[i]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[e[i]+"CancelAnimationFrame"]||window[e[i]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(e){var i=(new Date).getTime(),o=Math.max(0,16-(i-t)),n=window.setTimeout(function(){e(i+o)},o);return t=i+o,n}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)})}()},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,n=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),s=i(1),h=(o=s)&&o.__esModule?o:{default:o},r=i(0);var l=function(t){function e(t,i,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var n=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.options=Object.assign({isFirst:!0,isLast:!0,totalCount:1,currentIndex:0,showButtons:!0,closeBtnText:"Close",doneBtnText:"Done",startBtnText:"Next →",nextBtnText:"Next →",prevBtnText:"← Previous"},t),n.window=i,n.document=o,n.makeNode(),n.hide(),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,h.default),n(e,[{key:"makeNode",value:function(){var t=this.document.getElementById(r.ID_POPOVER);t||(t=e.createFromString(r.POPOVER_HTML),document.body.appendChild(t)),this.node=t,this.tipNode=t.querySelector("."+r.CLASS_POPOVER_TIP),this.titleNode=t.querySelector("."+r.CLASS_POPOVER_TITLE),this.descriptionNode=t.querySelector("."+r.CLASS_POPOVER_DESCRIPTION),this.footerNode=t.querySelector("."+r.CLASS_POPOVER_FOOTER),this.nextBtnNode=t.querySelector("."+r.CLASS_NEXT_STEP_BTN),this.prevBtnNode=t.querySelector("."+r.CLASS_PREV_STEP_BTN),this.closeBtnNode=t.querySelector("."+r.CLASS_CLOSE_BTN)}},{key:"getSize",value:function(){return{height:Math.max(this.node.scrollHeight,this.node.offsetHeight),width:Math.max(this.node.scrollWidth,this.node.offsetWidth)}}},{key:"hide",value:function(){this.node.style.display="none"}},{key:"reset",value:function(){this.node.style.display="block",this.node.style.left="0",this.node.style.top="0",this.node.style.bottom="",this.node.style.right="",this.node.querySelector("."+r.CLASS_POPOVER_TIP).className=r.CLASS_POPOVER_TIP}},{key:"show",value:function(t){switch(this.reset(),this.titleNode.innerHTML=this.options.title,this.descriptionNode.innerHTML=this.options.description,this.renderButtons(),this.options.position){case"left":this.positionOnLeft(t);break;case"right":this.positionOnRight(t);break;case"top":this.positionOnTop(t);break;case"bottom":this.positionOnBottom(t);break;case"auto":default:this.autoPosition(t)}}},{key:"renderButtons",value:function(){this.nextBtnNode.innerHTML=this.options.nextBtnText,this.prevBtnNode.innerHTML=this.options.prevBtnText,this.closeBtnNode.innerHTML=this.options.closeBtnText,this.options.showButtons&&this.options.totalCount&&1!==this.options.totalCount?(this.footerNode.style.display="block",this.options.isFirst?(this.prevBtnNode.classList.add(r.CLASS_BTN_DISABLED),this.nextBtnNode.innerHTML=this.options.startBtnText):this.prevBtnNode.classList.remove(r.CLASS_BTN_DISABLED),this.options.isLast?this.nextBtnNode.innerHTML=this.options.doneBtnText:this.nextBtnNode.innerHTML=this.options.nextBtnText):this.footerNode.style.display="none"}},{key:"positionOnLeft",value:function(t){var e=this.getSize().width,i=this.options.padding+10;this.node.style.left=t.left-e-i+"px",this.node.style.top=t.top-this.options.padding+"px",this.node.style.right="",this.node.style.bottom="",this.tipNode.classList.add("right")}},{key:"positionOnRight",value:function(t){var e=this.options.padding+10;this.node.style.left=t.right+e+"px",this.node.style.top=t.top-this.options.padding+"px",this.node.style.right="",this.node.style.bottom="",this.tipNode.classList.add("left")}},{key:"positionOnTop",value:function(t){var e=this.getSize().height,i=this.options.padding+10;this.node.style.top=t.top-e-i+"px",this.node.style.left=t.left-this.options.padding+"px",this.node.style.right="",this.node.style.bottom="",this.tipNode.classList.add("bottom")}},{key:"positionOnBottom",value:function(t){var e=this.options.padding+10;this.node.style.top=t.bottom+e+"px",this.node.style.left=t.left-this.options.padding+"px",this.node.style.right="",this.node.style.bottom="",this.tipNode.classList.add("top")}},{key:"autoPosition",value:function(t){var e=this.getFullPageSize(),i=this.getSize(),o=e.height,n=i.height,s=this.options.padding+10;t.bottom+n+s>=o?this.positionOnTop(t):this.positionOnBottom(t)}}],[{key:"createFromString",value:function(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstChild}}]),e}();e.default=l,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,n=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),s=i(2),h=(o=s)&&o.__esModule?o:{default:o},r=i(0);var l=function(){function t(e,i,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.options=e,this.overlayAlpha=0,this.positionToHighlight=new h.default({}),this.highlightedPosition=new h.default({}),this.redrawAnimation=null,this.highlightedElement=null,this.lastHighlightedElement=null,this.draw=this.draw.bind(this),this.window=i,this.document=o,this.resetOverlay(),this.setSize()}return n(t,[{key:"resetOverlay",value:function(){var t=this.document.getElementById(r.ID_OVERLAY);t&&t.parentNode&&t.parentNode.removeChild(t);var e=this.document.createElement("canvas");this.overlay=e,this.context=e.getContext("2d"),this.overlay.id=r.ID_OVERLAY,this.overlay.style.pointerEvents="none",this.overlay.style.background="transparent",this.overlay.style.position="fixed",this.overlay.style.top="0",this.overlay.style.left="0",this.overlay.style.zIndex=r.OVERLAY_ZINDEX}},{key:"highlight",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t&&t.node){t.onHighlightStarted(),this.highlightedElement&&this.highlightedElement.onDeselected();var i=t.getCalculatedPosition();i.canHighlight()&&(this.lastHighlightedElement=this.highlightedElement,this.highlightedElement=t,this.positionToHighlight=i,this.options.animate&&e||(this.highlightedPosition=this.positionToHighlight),this.draw())}else console.warn("Invalid element to highlight. Must be an instance of `Element`")}},{key:"getHighlightedElement",value:function(){return this.highlightedElement}},{key:"getLastHighlightedElement",value:function(){return this.lastHighlightedElement}},{key:"clear",value:function(){this.positionToHighlight=new h.default,this.highlightedElement&&this.highlightedElement.onDeselected(),this.highlightedElement=null,this.lastHighlightedElement=null,this.draw()}},{key:"draw",value:function(){var t=this.positionToHighlight.canHighlight();this.removeCloak(),this.addCloak();var e=this.overlayAlpha<.1;t&&(e?this.highlightedPosition=this.positionToHighlight:(this.highlightedPosition.left+=.18*(this.positionToHighlight.left-this.highlightedPosition.left),this.highlightedPosition.top+=.18*(this.positionToHighlight.top-this.highlightedPosition.top),this.highlightedPosition.right+=.18*(this.positionToHighlight.right-this.highlightedPosition.right),this.highlightedPosition.bottom+=.18*(this.positionToHighlight.bottom-this.highlightedPosition.bottom))),this.removeCloak({posX:this.highlightedPosition.left-this.window.scrollX-this.options.padding,posY:this.highlightedPosition.top-this.window.scrollY-this.options.padding,width:this.highlightedPosition.right-this.highlightedPosition.left+2*this.options.padding,height:this.highlightedPosition.bottom-this.highlightedPosition.top+2*this.options.padding}),t?this.options.animate?this.overlayAlpha+=.08*(this.options.opacity-this.overlayAlpha):this.overlayAlpha=this.options.opacity:this.overlayAlpha=Math.max(.85*this.overlayAlpha-.02,0),this.window.cancelAnimationFrame(this.redrawAnimation),t||this.overlayAlpha>0?(this.overlay.parentNode||this.document.body.appendChild(this.overlay),this.hasPositionHighlighted()?!this.options.animate&&e?this.redrawAnimation=this.window.requestAnimationFrame(this.draw):this.highlightedElement.onHighlighted():this.redrawAnimation=this.window.requestAnimationFrame(this.draw)):this.overlay.parentNode&&this.document.body.removeChild(this.overlay)}},{key:"hasPositionHighlighted",value:function(){return this.positionToHighlight.equals(this.highlightedPosition)&&this.overlayAlpha>this.options.opacity-.05}},{key:"removeCloak",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.posX,i=void 0===e?0:e,o=t.posY,n=void 0===o?0:o,s=t.width,h=void 0===s?this.overlay.width:s,r=t.height,l=void 0===r?this.overlay.height:r;this.context.clearRect(i,n,h,l)}},{key:"addCloak",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.posX,i=void 0===e?0:e,o=t.posY,n=void 0===o?0:o,s=t.width,h=void 0===s?this.overlay.width:s,r=t.height,l=void 0===r?this.overlay.height:r;this.context.fillStyle="rgba( 0, 0, 0, "+this.overlayAlpha+" )",this.context.fillRect(i,n,h,l)}},{key:"setSize",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.overlay.width=t||this.window.innerWidth,this.overlay.height=e||this.window.innerHeight}},{key:"refresh",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.setSize(),this.highlightedElement&&(this.window.cancelAnimationFrame(this.redrawAnimation),this.highlight(this.highlightedElement,t),this.highlightedElement.onHighlighted())}}]),t}();e.default=l,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),n=l(i(5)),s=l(i(1)),h=l(i(4));i(3);var r=i(0);function l(t){return t&&t.__esModule?t:{default:t}}var a=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.options=Object.assign({animate:r.OVERLAY_ANIMATE,opacity:r.OVERLAY_OPACITY,padding:r.OVERLAY_PADDING,scrollIntoViewOptions:null,onHighlightStarted:function(){},onHighlighted:function(){},onDeselected:function(){}},e),this.document=document,this.window=window,this.isActivated=!1,this.overlay=new n.default(this.options,this.window,this.document),this.steps=[],this.currentStep=0,this.onScroll=this.onScroll.bind(this),this.onResize=this.onResize.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onClick=this.onClick.bind(this),this.bind()}return o(t,[{key:"bind",value:function(){this.document.addEventListener("scroll",this.onScroll,!1),this.document.addEventListener("DOMMouseScroll",this.onScroll,!1),this.window.addEventListener("resize",this.onResize,!1),this.window.addEventListener("keyup",this.onKeyUp,!1),this.window.addEventListener("click",this.onClick,!1)}},{key:"onClick",value:function(t){if(this.hasHighlightedElement()&&this.isActivated){var e=this.overlay.getHighlightedElement(),i=this.document.getElementById(r.ID_POPOVER),o=e.node.contains(t.target),n=i&&i.contains(t.target);if(o||n){var s=t.target.classList.contains(r.CLASS_NEXT_STEP_BTN),h=t.target.classList.contains(r.CLASS_PREV_STEP_BTN);t.target.classList.contains(r.CLASS_CLOSE_BTN)?this.reset():s?this.moveNext():h&&this.movePrevious()}else this.reset()}}},{key:"movePrevious",value:function(){this.currentStep-=1,this.steps[this.currentStep]?this.overlay.highlight(this.steps[this.currentStep]):this.reset()}},{key:"moveNext",value:function(){this.currentStep+=1,this.steps[this.currentStep]?this.overlay.highlight(this.steps[this.currentStep]):this.reset()}},{key:"hasNextStep",value:function(){return!!this.steps[this.currentStep+1]}},{key:"hasPreviousStep",value:function(){return!!this.steps[this.currentStep-1]}},{key:"reset",value:function(){this.currentStep=0,this.isActivated=!1,this.overlay.clear()}},{key:"hasHighlightedElement",value:function(){var t=this.overlay.getHighlightedElement();return t&&t.node&&t.highlightFinished}},{key:"getHighlightedElement",value:function(){return this.overlay.getHighlightedElement()}},{key:"getLastHighlightedElement",value:function(){return this.overlay.getLastHighlightedElement()}},{key:"onScroll",value:function(){this.isActivated&&this.overlay.refresh(!1)}},{key:"onResize",value:function(){this.isActivated&&this.overlay.refresh(!0)}},{key:"onKeyUp",value:function(t){this.isActivated&&(t.keyCode===r.ESC_KEY_CODE?this.reset():t.keyCode===r.RIGHT_KEY_CODE?this.moveNext():t.keyCode===r.LEFT_KEY_CODE&&this.movePrevious())}},{key:"defineSteps",value:function(t){var e=this;this.steps=[],t.forEach(function(i,o){if(!i.element||"string"!=typeof i.element)throw new Error("Element (query selector string) missing in step "+o);var n=e.prepareElementFromStep(i,t,o);n&&e.steps.push(n)})}},{key:"prepareElementFromStep",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o="",n={};"string"==typeof t?o=t:(o=t.element,n=Object.assign({},this.options,t));var r=this.document.querySelector(o);if(!r)return console.warn("Element to highlight "+o+" not found"),null;var l=null;if(n.popover&&n.popover.description){var a=Object.assign({},this.options,n.popover,{totalCount:e.length,currentIndex:i,isFirst:0===i,isLast:i===e.length-1});l=new h.default(a,this.window,this.document)}return new s.default(r,n,l,this.overlay,this.window,this.document)}},{key:"start",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(!this.steps||0===this.steps.length)throw new Error("There are no steps defined to iterate");this.isActivated=!0,this.currentStep=t,this.overlay.highlight(this.steps[t])}},{key:"highlight",value:function(t){this.isActivated=!0;var e=this.prepareElementFromStep(t);e&&this.overlay.highlight(e)}}]),t}();e.default=a,t.exports=e.default},function(t,e){},function(t,e,i){i(7),t.exports=i(6)}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Driver=e():t.Driver=e()}(window,function(){return function(t){var e={};function i(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/dist/",i(i.s=8)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.OVERLAY_OPACITY=.75,e.OVERLAY_PADDING=10,e.OVERLAY_ANIMATE=!0,e.OVERLAY_ZINDEX="999999999",e.ESC_KEY_CODE=27,e.LEFT_KEY_CODE=37,e.RIGHT_KEY_CODE=39,e.ID_OVERLAY="driver-canvas-overlay";var o=e.ID_POPOVER="driver-popover-item",n=e.CLASS_POPOVER_TIP="driver-popover-tip",s=e.CLASS_POPOVER_TITLE="driver-popover-title",h=e.CLASS_POPOVER_DESCRIPTION="driver-popover-description",r=e.CLASS_POPOVER_FOOTER="driver-popover-footer",l=e.CLASS_CLOSE_BTN="driver-close-btn",a=e.CLASS_NEXT_STEP_BTN="driver-next-btn",d=e.CLASS_PREV_STEP_BTN="driver-prev-btn";e.CLASS_BTN_DISABLED="driver-disabled",e.POPOVER_HTML='\n <div id="'+o+'">\n <div class="'+n+'"></div>\n <div class="'+s+'">Popover Title</div>\n <div class="'+h+'">Popover Description</div>\n <div class="'+r+'">\n <a href="javascript:void(0)" class="'+l+'">Close</a>\n <span class="driver-btn-group">\n <a class="'+d+'" href="javascript:void(0)">← Previous</a>\n <a class="'+a+'" href="javascript:void(0)">Next →</a>\n </span>\n </div>\n </div>'},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,n=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),s=i(2),h=(o=s)&&o.__esModule?o:{default:o};var r=function(){function t(e,i,o,n,s,h){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.node=e,this.document=h,this.window=s,this.options=i,this.overlay=n,this.popover=o,this.highlightFinished=!1}return n(t,[{key:"getScreenCoordinates",value:function(){var t=this.node,e=this.document.documentElement.offsetLeft,i=this.document.documentElement.offsetTop;if(t.offsetParent)do{e+=t.offsetLeft,i+=t.offsetTop}while(t=t.offsetParent);return{x:e,y:i}}},{key:"isInView",value:function(){for(var t=this.node.offsetTop,e=this.node.offsetLeft,i=this.node.offsetWidth,o=this.node.offsetHeight,n=this.node;n.offsetParent;)t+=(n=n.offsetParent).offsetTop,e+=n.offsetLeft;return t>=this.window.pageYOffset&&e>=this.window.pageXOffset&&t+o<=this.window.pageYOffset+this.window.innerHeight&&e+i<=this.window.pageXOffset+this.window.innerWidth}},{key:"scrollManually",value:function(){var t=this.node.getBoundingClientRect().top+this.window.pageYOffset-this.window.innerHeight/2;this.window.scrollTo(0,t)}},{key:"bringInView",value:function(){if(!this.isInView())if(this.node.scrollIntoView)try{this.node.scrollIntoView(this.options.scrollIntoViewOptions||{behavior:"smooth",block:"center"})}catch(t){this.scrollManually()}else this.scrollManually()}},{key:"getCalculatedPosition",value:function(){var t=this.getScreenCoordinates(),e=new h.default({left:Number.MAX_VALUE,top:Number.MAX_VALUE,right:0,bottom:0});return"number"==typeof t.x&&"number"==typeof t.y&&(this.node.offsetWidth>0||this.node.offsetHeight>0)&&(e.left=Math.min(e.left,t.x),e.top=Math.min(e.top,t.y),e.right=Math.max(e.right,t.x+this.node.offsetWidth),e.bottom=Math.max(e.bottom,t.y+this.node.offsetHeight)),e}},{key:"onDeselected",value:function(){this.hidePopover(),this.highlightFinished=!1,this.options.onDeselected&&this.options.onDeselected(this)}},{key:"onHighlightStarted",value:function(){this.showPopover(),this.highlightFinished=!1,this.options.onHighlightStarted&&this.options.onHighlightStarted(this)}},{key:"onHighlighted",value:function(){this.showPopover(),this.highlightFinished=!0;var t=this.overlay.getLastHighlightedElement(),e=this.popover;this.node!==(t&&t.node)&&(e&&!e.isInView()&&e.bringInView(),this.isInView()||this.bringInView()),this.options.onHighlighted&&this.options.onHighlighted(this)}},{key:"getNode",value:function(){return this.node}},{key:"hidePopover",value:function(){this.popover&&this.popover.hide()}},{key:"showPopover",value:function(){if(this.popover){var t=this.getCalculatedPosition();this.popover.show(t)}}},{key:"getFullPageSize",value:function(){var t=this.document.body,e=this.document.documentElement;return{height:Math.max(t.scrollHeight,t.offsetHeight,e.scrollHeight,e.offsetHeight),width:Math.max(t.scrollWidth,t.offsetWidth,e.scrollWidth,e.offsetWidth)}}}]),t}();e.default=r,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}();var n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e.left,o=void 0===i?0:i,n=e.top,s=void 0===n?0:n,h=e.right,r=void 0===h?0:h,l=e.bottom,a=void 0===l?0:l;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.left=o,this.right=r,this.top=s,this.bottom=a}return o(t,[{key:"canHighlight",value:function(){return this.left<this.right&&this.top<this.bottom}},{key:"equals",value:function(t){return Math.round(this.left)===Math.round(t.left)&&Math.round(this.right)===Math.round(t.right)&&Math.round(this.top)===Math.round(t.top)&&Math.round(this.bottom)===Math.round(t.bottom)}}]),t}();e.default=n,t.exports=e.default},function(t,e,i){"use strict";!function(){for(var t=0,e=["ms","moz","webkit","o"],i=0;i<e.length&&!window.requestAnimationFrame;++i)window.requestAnimationFrame=window[e[i]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[e[i]+"CancelAnimationFrame"]||window[e[i]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(e){var i=(new Date).getTime(),o=Math.max(0,16-(i-t)),n=window.setTimeout(function(){e(i+o)},o);return t=i+o,n}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)})}()},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,n=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),s=i(1),h=(o=s)&&o.__esModule?o:{default:o},r=i(0);var l=function(t){function e(t,i,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var n=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.options=Object.assign({isFirst:!0,isLast:!0,totalCount:1,currentIndex:0,showButtons:!0,closeBtnText:"Close",doneBtnText:"Done",startBtnText:"Next →",nextBtnText:"Next →",prevBtnText:"← Previous"},t),n.window=i,n.document=o,n.makeNode(),n.hide(),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,h.default),n(e,[{key:"makeNode",value:function(){var t=this.document.getElementById(r.ID_POPOVER);t||(t=e.createFromString(r.POPOVER_HTML),document.body.appendChild(t)),this.node=t,this.tipNode=t.querySelector("."+r.CLASS_POPOVER_TIP),this.titleNode=t.querySelector("."+r.CLASS_POPOVER_TITLE),this.descriptionNode=t.querySelector("."+r.CLASS_POPOVER_DESCRIPTION),this.footerNode=t.querySelector("."+r.CLASS_POPOVER_FOOTER),this.nextBtnNode=t.querySelector("."+r.CLASS_NEXT_STEP_BTN),this.prevBtnNode=t.querySelector("."+r.CLASS_PREV_STEP_BTN),this.closeBtnNode=t.querySelector("."+r.CLASS_CLOSE_BTN)}},{key:"getSize",value:function(){return{height:Math.max(this.node.scrollHeight,this.node.offsetHeight),width:Math.max(this.node.scrollWidth,this.node.offsetWidth)}}},{key:"hide",value:function(){this.node.style.display="none"}},{key:"reset",value:function(){this.node.style.display="block",this.node.style.left="0",this.node.style.top="0",this.node.style.bottom="",this.node.style.right="",this.node.querySelector("."+r.CLASS_POPOVER_TIP).className=r.CLASS_POPOVER_TIP}},{key:"show",value:function(t){switch(this.reset(),this.titleNode.innerHTML=this.options.title,this.descriptionNode.innerHTML=this.options.description,this.renderButtons(),this.options.position){case"left":this.positionOnLeft(t);break;case"right":this.positionOnRight(t);break;case"top":this.positionOnTop(t);break;case"bottom":this.positionOnBottom(t);break;case"auto":default:this.autoPosition(t)}}},{key:"renderButtons",value:function(){this.nextBtnNode.innerHTML=this.options.nextBtnText,this.prevBtnNode.innerHTML=this.options.prevBtnText,this.closeBtnNode.innerHTML=this.options.closeBtnText,this.options.showButtons&&this.options.totalCount&&1!==this.options.totalCount?(this.footerNode.style.display="block",this.options.isFirst?(this.prevBtnNode.classList.add(r.CLASS_BTN_DISABLED),this.nextBtnNode.innerHTML=this.options.startBtnText):this.prevBtnNode.classList.remove(r.CLASS_BTN_DISABLED),this.options.isLast?this.nextBtnNode.innerHTML=this.options.doneBtnText:this.nextBtnNode.innerHTML=this.options.nextBtnText):this.footerNode.style.display="none"}},{key:"positionOnLeft",value:function(t){var e=this.getSize().width,i=this.options.padding+10;this.node.style.left=t.left-e-i+"px",this.node.style.top=t.top-this.options.padding+"px",this.node.style.right="",this.node.style.bottom="",this.tipNode.classList.add("right")}},{key:"positionOnRight",value:function(t){var e=this.options.padding+10;this.node.style.left=t.right+e+"px",this.node.style.top=t.top-this.options.padding+"px",this.node.style.right="",this.node.style.bottom="",this.tipNode.classList.add("left")}},{key:"positionOnTop",value:function(t){var e=this.getSize().height,i=this.options.padding+10;this.node.style.top=t.top-e-i+"px",this.node.style.left=t.left-this.options.padding+"px",this.node.style.right="",this.node.style.bottom="",this.tipNode.classList.add("bottom")}},{key:"positionOnBottom",value:function(t){var e=this.options.padding+10;this.node.style.top=t.bottom+e+"px",this.node.style.left=t.left-this.options.padding+"px",this.node.style.right="",this.node.style.bottom="",this.tipNode.classList.add("top")}},{key:"autoPosition",value:function(t){var e=this.getFullPageSize(),i=this.getSize(),o=e.height,n=i.height,s=this.options.padding+10;t.bottom+n+s>=o?this.positionOnTop(t):this.positionOnBottom(t)}}],[{key:"createFromString",value:function(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstChild}}]),e}();e.default=l,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,n=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),s=i(2),h=(o=s)&&o.__esModule?o:{default:o},r=i(0);var l=function(){function t(e,i,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.options=e,this.overlayAlpha=0,this.positionToHighlight=new h.default({}),this.highlightedPosition=new h.default({}),this.redrawAnimation=null,this.highlightedElement=null,this.lastHighlightedElement=null,this.draw=this.draw.bind(this),this.window=i,this.document=o,this.resetOverlay(),this.setSize()}return n(t,[{key:"resetOverlay",value:function(){var t=this.document.getElementById(r.ID_OVERLAY);t&&t.parentNode&&t.parentNode.removeChild(t);var e=this.document.createElement("canvas");this.overlay=e,this.context=e.getContext("2d"),this.overlay.id=r.ID_OVERLAY,this.overlay.style.pointerEvents="none",this.overlay.style.background="transparent",this.overlay.style.position="fixed",this.overlay.style.top="0",this.overlay.style.left="0",this.overlay.style.zIndex=r.OVERLAY_ZINDEX}},{key:"highlight",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t&&t.node){t.onHighlightStarted(),this.highlightedElement&&this.highlightedElement.onDeselected();var i=t.getCalculatedPosition();i.canHighlight()&&(this.lastHighlightedElement=this.highlightedElement,this.highlightedElement=t,this.positionToHighlight=i,this.options.animate&&e||(this.highlightedPosition=this.positionToHighlight),this.draw())}else console.warn("Invalid element to highlight. Must be an instance of `Element`")}},{key:"getHighlightedElement",value:function(){return this.highlightedElement}},{key:"getLastHighlightedElement",value:function(){return this.lastHighlightedElement}},{key:"clear",value:function(){this.positionToHighlight=new h.default,this.highlightedElement&&this.highlightedElement.onDeselected(),this.highlightedElement=null,this.lastHighlightedElement=null,this.draw()}},{key:"draw",value:function(){var t=this.positionToHighlight.canHighlight();this.removeCloak(),this.addCloak();var e=this.overlayAlpha<.1;t&&(e?this.highlightedPosition=this.positionToHighlight:(this.highlightedPosition.left+=.18*(this.positionToHighlight.left-this.highlightedPosition.left),this.highlightedPosition.top+=.18*(this.positionToHighlight.top-this.highlightedPosition.top),this.highlightedPosition.right+=.18*(this.positionToHighlight.right-this.highlightedPosition.right),this.highlightedPosition.bottom+=.18*(this.positionToHighlight.bottom-this.highlightedPosition.bottom))),this.removeCloak({posX:this.highlightedPosition.left-this.window.scrollX-this.options.padding,posY:this.highlightedPosition.top-this.window.scrollY-this.options.padding,width:this.highlightedPosition.right-this.highlightedPosition.left+2*this.options.padding,height:this.highlightedPosition.bottom-this.highlightedPosition.top+2*this.options.padding}),t?this.options.animate?this.overlayAlpha+=.08*(this.options.opacity-this.overlayAlpha):this.overlayAlpha=this.options.opacity:this.overlayAlpha=Math.max(.85*this.overlayAlpha-.02,0),this.window.cancelAnimationFrame(this.redrawAnimation),t||this.overlayAlpha>0?(this.overlay.parentNode||this.document.body.appendChild(this.overlay),this.hasPositionHighlighted()?!this.options.animate&&e?this.redrawAnimation=this.window.requestAnimationFrame(this.draw):this.highlightedElement.onHighlighted():this.redrawAnimation=this.window.requestAnimationFrame(this.draw)):this.overlay.parentNode&&this.document.body.removeChild(this.overlay)}},{key:"hasPositionHighlighted",value:function(){return this.positionToHighlight.equals(this.highlightedPosition)&&this.overlayAlpha>this.options.opacity-.05}},{key:"removeCloak",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.posX,i=void 0===e?0:e,o=t.posY,n=void 0===o?0:o,s=t.width,h=void 0===s?this.overlay.width:s,r=t.height,l=void 0===r?this.overlay.height:r;this.context.clearRect(i,n,h,l)}},{key:"addCloak",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.posX,i=void 0===e?0:e,o=t.posY,n=void 0===o?0:o,s=t.width,h=void 0===s?this.overlay.width:s,r=t.height,l=void 0===r?this.overlay.height:r;this.context.fillStyle="rgba( 0, 0, 0, "+this.overlayAlpha+" )",this.context.fillRect(i,n,h,l)}},{key:"setSize",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.overlay.width=t||this.window.innerWidth,this.overlay.height=e||this.window.innerHeight}},{key:"refresh",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.setSize(),this.highlightedElement&&(this.window.cancelAnimationFrame(this.redrawAnimation),this.highlight(this.highlightedElement,t),this.highlightedElement.onHighlighted())}}]),t}();e.default=l,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),n=l(i(5)),s=l(i(1)),h=l(i(4));i(3);var r=i(0);function l(t){return t&&t.__esModule?t:{default:t}}var a=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.options=Object.assign({animate:r.OVERLAY_ANIMATE,opacity:r.OVERLAY_OPACITY,padding:r.OVERLAY_PADDING,scrollIntoViewOptions:null,onHighlightStarted:function(){},onHighlighted:function(){},onDeselected:function(){}},e),this.document=document,this.window=window,this.isActivated=!1,this.overlay=new n.default(this.options,this.window,this.document),this.steps=[],this.currentStep=0,this.onScroll=this.onScroll.bind(this),this.onResize=this.onResize.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onClick=this.onClick.bind(this),this.bind()}return o(t,[{key:"bind",value:function(){this.document.addEventListener("scroll",this.onScroll,!1),this.document.addEventListener("DOMMouseScroll",this.onScroll,!1),this.window.addEventListener("resize",this.onResize,!1),this.window.addEventListener("keyup",this.onKeyUp,!1),this.window.addEventListener("click",this.onClick,!1)}},{key:"onClick",value:function(t){if(this.hasHighlightedElement()&&this.isActivated){var e=this.overlay.getHighlightedElement(),i=this.document.getElementById(r.ID_POPOVER),o=e.node.contains(t.target),n=i&&i.contains(t.target);if(o||n){var s=t.target.classList.contains(r.CLASS_NEXT_STEP_BTN),h=t.target.classList.contains(r.CLASS_PREV_STEP_BTN);t.target.classList.contains(r.CLASS_CLOSE_BTN)?this.reset():s?this.moveNext():h&&this.movePrevious()}else this.reset()}}},{key:"movePrevious",value:function(){this.currentStep-=1,this.steps[this.currentStep]?this.overlay.highlight(this.steps[this.currentStep]):this.reset()}},{key:"moveNext",value:function(){this.currentStep+=1,this.steps[this.currentStep]?this.overlay.highlight(this.steps[this.currentStep]):this.reset()}},{key:"hasNextStep",value:function(){return!!this.steps[this.currentStep+1]}},{key:"hasPreviousStep",value:function(){return!!this.steps[this.currentStep-1]}},{key:"reset",value:function(){this.currentStep=0,this.isActivated=!1,this.overlay.clear()}},{key:"hasHighlightedElement",value:function(){var t=this.overlay.getHighlightedElement();return t&&t.node&&t.highlightFinished}},{key:"getHighlightedElement",value:function(){return this.overlay.getHighlightedElement()}},{key:"getLastHighlightedElement",value:function(){return this.overlay.getLastHighlightedElement()}},{key:"onScroll",value:function(){this.isActivated&&this.overlay.refresh(!1)}},{key:"onResize",value:function(){this.isActivated&&this.overlay.refresh(!0)}},{key:"onKeyUp",value:function(t){this.isActivated&&(t.keyCode===r.ESC_KEY_CODE?this.reset():t.keyCode===r.RIGHT_KEY_CODE?this.moveNext():t.keyCode===r.LEFT_KEY_CODE&&this.movePrevious())}},{key:"defineSteps",value:function(t){var e=this;this.steps=[],t.forEach(function(i,o){if(!i.element||"string"!=typeof i.element)throw new Error("Element (query selector string) missing in step "+o);var n=e.prepareElementFromStep(i,t,o);n&&e.steps.push(n)})}},{key:"prepareElementFromStep",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o="",n={};"string"==typeof t?o=t:(o=t.element,n=Object.assign({},this.options,t));var r=this.document.querySelector(o);if(!r)return console.warn("Element to highlight "+o+" not found"),null;var l=null;if(n.popover&&n.popover.description){var a=Object.assign({},this.options,n.popover,{totalCount:e.length,currentIndex:i,isFirst:0===i,isLast:i===e.length-1});l=new h.default(a,this.window,this.document)}return new s.default(r,n,l,this.overlay,this.window,this.document)}},{key:"start",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(!this.steps||0===this.steps.length)throw new Error("There are no steps defined to iterate");this.isActivated=!0,this.currentStep=t,this.overlay.highlight(this.steps[t])}},{key:"highlight",value:function(t){this.isActivated=!0;var e=this.prepareElementFromStep(t);e&&this.overlay.highlight(e)}}]),t}();e.default=a,t.exports=e.default},function(t,e){},function(t,e,i){i(7),t.exports=i(6)}])}); | ||
//# sourceMappingURL=driver.min.js.map |
{ | ||
"name": "driver.js", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the page", | ||
@@ -5,0 +5,0 @@ "main": "./assets/scripts/dist/driver.min.js", |
@@ -75,2 +75,13 @@ import Position from './position'; | ||
/** | ||
* Manually scrolls to the position of element if `scrollIntoView` fails | ||
*/ | ||
scrollManually() { | ||
const elementRect = this.node.getBoundingClientRect(); | ||
const absoluteElementTop = elementRect.top + this.window.pageYOffset; | ||
const middle = absoluteElementTop - (this.window.innerHeight / 2); | ||
this.window.scrollTo(0, middle); | ||
} | ||
/** | ||
* Brings the element to middle of the view port if not in view | ||
@@ -83,16 +94,16 @@ */ | ||
// If browser supports scrollIntoView, use that otherwise center it manually | ||
if (this.node.scrollIntoView) { | ||
const scrollIntoViewOptions = this.options.scrollIntoViewOptions || { | ||
// If browser does not support scrollIntoView | ||
if (!this.node.scrollIntoView) { | ||
this.scrollManually(); | ||
return; | ||
} | ||
try { | ||
this.node.scrollIntoView(this.options.scrollIntoViewOptions || { | ||
behavior: 'smooth', | ||
block: 'center', | ||
}; | ||
this.node.scrollIntoView(scrollIntoViewOptions); | ||
} else { | ||
const elementRect = this.node.getBoundingClientRect(); | ||
const absoluteElementTop = elementRect.top + this.window.pageYOffset; | ||
const middle = absoluteElementTop - (this.window.innerHeight / 2); | ||
this.window.scrollTo(0, middle); | ||
}); | ||
} catch (e) { | ||
// `block` option is not allowed in older versions of firefox, scroll manually | ||
this.scrollManually(); | ||
} | ||
@@ -99,0 +110,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
389331
1618