{"version":3,"file":"mouse-follower.min.js","sources":["../src/index.js"],"sourcesContent":["/*!\n * Cuberto Mouse Follower\n * https://cuberto.com/\n *\n * @version 1.1.2\n * @author Cuberto, Artem Dordzhiev (Draft)\n */\n\nexport default class MouseFollower {\n /**\n * @typedef {Object} MouseFollowerOptions\n * @property {string|HTMLElement|null} [el] Existed cursor element.\n * @property {string|HTMLElement|null} [container] Cursor container.\n * @property {string} [className] Cursor root element class name.\n * @property {string} [innerClassName] Inner element class name.\n * @property {string} [textClassName] Text element class name.\n * @property {string} [mediaClassName] Media element class name.\n * @property {string} [mediaBoxClassName] Media inner element class name.\n * @property {string} [iconSvgClassName] SVG sprite class name.\n * @property {string} [iconSvgNamePrefix] SVG sprite icon class name prefix.\n * @property {string} [iconSvgSrc] SVG sprite source.\n * @property {string|null} [dataAttr] Name of data attribute for changing cursor state directly in HTML.\n * @property {string} [hiddenState] Hidden state name.\n * @property {string} [textState] Text state name.\n * @property {string} [iconState] Icon state name.\n * @property {string|null} [activeState] Active (mousedown) state name. Set false to disable.\n * @property {string} [mediaState] Media (image/video) state name.\n * @property {Object} [stateDetection] State detection rules.\n * @property {boolean} [visible] Is cursor visible by default.\n * @property {boolean} [visibleOnState] Automatically show/hide cursor when state added.\n * @property {number} [speed] Cursor movement speed.\n * @property {string} [ease] Timing function of cursor movement.\n * @property {boolean} [overwrite] Overwrite or remain cursor position when `mousemove` event happens.\n * @property {number} [skewing] Default skewing factor.\n * @property {number} [skewingText] Skewing effect factor in a text state.\n * @property {number} [skewingIcon] Skewing effect factor in a icon state.\n * @property {number} [skewingMedia] Skewing effect factor in a media (image/video) state.\n * @property {number} [skewingDelta] Skewing effect base delta.\n * @property {number} [skewingDeltaMax] Skew effect max delta.\n * @property {number} [stickDelta] Stick effect delta.\n * @property {number} [showTimeout] Delay before show.\n * @property {boolean} [hideOnLeave] Hide the cursor when mouse leave container.\n * @property {number} [hideTimeout] Delay before hiding. It should be equal to the CSS hide animation time.\n * @property {number[]} [initialPos] Array (x, y) of initial cursor position.\n */\n\n /**\n * Register GSAP animation library.\n *\n * @param {gsap} gsap GSAP library.\n */\n static registerGSAP(gsap) {\n MouseFollower.gsap = gsap;\n }\n\n /**\n * Create cursor instance.\n *\n * @param {MouseFollowerOptions} [options] Cursor options.\n */\n constructor(options = {}) {\n /** @type {MouseFollowerOptions} **/\n this.options = Object.assign({}, {\n el: null,\n container: document.body,\n className: 'mf-cursor',\n innerClassName: 'mf-cursor-inner',\n textClassName: 'mf-cursor-text',\n mediaClassName: 'mf-cursor-media',\n mediaBoxClassName: 'mf-cursor-media-box',\n iconSvgClassName: 'mf-svgsprite',\n iconSvgNamePrefix: '-',\n iconSvgSrc: '',\n dataAttr: 'cursor',\n hiddenState: '-hidden',\n textState: '-text',\n iconState: '-icon',\n activeState: '-active',\n mediaState: '-media',\n stateDetection: {\n '-pointer': 'a,button',\n },\n visible: true,\n visibleOnState: false,\n speed: 0.55,\n ease: 'expo.out',\n overwrite: true,\n skewing: 0,\n skewingText: 2,\n skewingIcon: 2,\n skewingMedia: 2,\n skewingDelta: 0.001,\n skewingDeltaMax: 0.15,\n stickDelta: 0.15,\n showTimeout: 0,\n hideOnLeave: true,\n hideTimeout: 300,\n hideMediaTimeout: 300,\n initialPos: [-window.innerWidth, -window.innerHeight],\n }, options);\n\n if (this.options.visible && options.stateDetection == null) this.options.stateDetection['-hidden'] = 'iframe';\n\n this.gsap = MouseFollower.gsap || window.gsap;\n this.el = typeof (this.options.el) === 'string' ?\n document.querySelector(this.options.el) : this.options.el;\n this.container = typeof (this.options.container) === 'string' ?\n document.querySelector(this.options.container) : this.options.container;\n this.skewing = this.options.skewing;\n this.pos = {x: this.options.initialPos[0], y: this.options.initialPos[1]};\n this.vel = {x: 0, y: 0};\n this.event = {};\n this.events = [];\n\n this.init();\n }\n\n /**\n * Init cursor.\n */\n init() {\n if (!this.el) this.create();\n this.createSetter();\n this.bind();\n this.render(true);\n this.ticker = this.render.bind(this, false);\n this.gsap.ticker.add(this.ticker);\n }\n\n /**\n * Create cursor DOM element and append to container.\n */\n create() {\n this.el = document.createElement('div');\n this.el.className = this.options.className;\n this.el.classList.add(this.options.hiddenState);\n\n this.inner = document.createElement('div');\n this.inner.className = this.options.innerClassName;\n\n this.text = document.createElement('div');\n this.text.className = this.options.textClassName;\n\n this.media = document.createElement('div');\n this.media.className = this.options.mediaClassName;\n\n this.mediaBox = document.createElement('div');\n this.mediaBox.className = this.options.mediaBoxClassName;\n\n this.media.appendChild(this.mediaBox);\n this.inner.appendChild(this.media);\n this.inner.appendChild(this.text);\n this.el.appendChild(this.inner);\n this.container.appendChild(this.el);\n }\n\n /**\n * Create GSAP setters.\n */\n createSetter() {\n this.setter = {\n x: this.gsap.quickSetter(this.el, 'x', 'px'),\n y: this.gsap.quickSetter(this.el, 'y', 'px'),\n rotation: this.gsap.quickSetter(this.el, 'rotation', 'deg'),\n scaleX: this.gsap.quickSetter(this.el, 'scaleX'),\n scaleY: this.gsap.quickSetter(this.el, 'scaleY'),\n wc: this.gsap.quickSetter(this.el, 'willChange'),\n inner: {\n rotation: this.gsap.quickSetter(this.inner, 'rotation', 'deg'),\n },\n };\n }\n\n /**\n * Create and attach events.\n */\n bind() {\n this.event.mouseleave = () => this.hide();\n this.event.mouseenter = () => this.show();\n this.event.mousedown = () => this.addState(this.options.activeState);\n this.event.mouseup = () => this.removeState(this.options.activeState);\n this.event.mousemoveOnce = () => this.show();\n this.event.mousemove = (e) => {\n this.gsap.to(this.pos, {\n x: this.stick ? this.stick.x - ((this.stick.x - e.clientX) * this.options.stickDelta) : e.clientX,\n y: this.stick ? this.stick.y - ((this.stick.y - e.clientY) * this.options.stickDelta) : e.clientY,\n overwrite: this.options.overwrite,\n ease: this.options.ease,\n duration: this.visible ? this.options.speed : 0,\n onUpdate: () => this.vel = {x: e.clientX - this.pos.x, y: e.clientY - this.pos.y},\n });\n };\n this.event.mouseover = (e) => {\n for (let target = e.target; target && target !== this.container; target = target.parentNode) {\n if (e.relatedTarget && target.contains(e.relatedTarget)) break;\n\n for (let state in this.options.stateDetection) {\n if (target.matches(this.options.stateDetection[state])) this.addState(state);\n }\n\n if (this.options.dataAttr) {\n const params = this.getFromDataset(target);\n if (params.state) this.addState(params.state);\n if (params.text) this.setText(params.text);\n if (params.icon) this.setIcon(params.icon);\n if (params.img) this.setImg(params.img);\n if (params.video) this.setVideo(params.video);\n if (typeof (params.show) !== 'undefined') this.show();\n if (typeof (params.stick) !== 'undefined') this.setStick(params.stick || target);\n }\n }\n };\n this.event.mouseout = (e) => {\n for (let target = e.target; target && target !== this.container; target = target.parentNode) {\n if (e.relatedTarget && target.contains(e.relatedTarget)) break;\n\n for (let state in this.options.stateDetection) {\n if (target.matches(this.options.stateDetection[state])) this.removeState(state);\n }\n\n if (this.options.dataAttr) {\n const params = this.getFromDataset(target);\n if (params.state) this.removeState(params.state);\n if (params.text) this.removeText();\n if (params.icon) this.removeIcon();\n if (params.img) this.removeImg();\n if (params.video) this.removeVideo();\n if (typeof (params.show) !== 'undefined') this.hide();\n if (typeof (params.stick) !== 'undefined') this.removeStick();\n }\n }\n };\n\n if (this.options.hideOnLeave) {\n this.container.addEventListener('mouseleave', this.event.mouseleave, {passive: true});\n }\n if (this.options.visible) {\n this.container.addEventListener('mouseenter', this.event.mouseenter, {passive: true});\n }\n if (this.options.activeState) {\n this.container.addEventListener('mousedown', this.event.mousedown, {passive: true});\n this.container.addEventListener('mouseup', this.event.mouseup, {passive: true});\n }\n this.container.addEventListener('mousemove', this.event.mousemove, {passive: true});\n if (this.options.visible) {\n this.container.addEventListener('mousemove', this.event.mousemoveOnce, {\n passive: true,\n once: true,\n });\n }\n if (this.options.stateDetection || this.options.dataAttr) {\n this.container.addEventListener('mouseover', this.event.mouseover, {passive: true});\n this.container.addEventListener('mouseout', this.event.mouseout, {passive: true});\n }\n }\n\n /**\n * Render the cursor in a new position.\n *\n * @param {boolean} [force=false] Force render.\n */\n render(force) {\n if (force !== true && (this.vel.y === 0 || this.vel.x === 0)) {\n this.setter.wc('auto');\n return;\n }\n\n this.trigger('render');\n this.setter.wc('transform');\n this.setter.x(this.pos.x);\n this.setter.y(this.pos.y);\n\n if (this.skewing) {\n const distance = Math.sqrt(Math.pow(this.vel.x, 2) + Math.pow(this.vel.y, 2));\n const scale = Math.min(distance * this.options.skewingDelta,\n this.options.skewingDeltaMax) * this.skewing;\n const angle = Math.atan2(this.vel.y, this.vel.x) * 180 / Math.PI;\n\n this.setter.rotation(angle);\n this.setter.scaleX(1 + scale);\n this.setter.scaleY(1 - scale);\n this.setter.inner.rotation(-angle);\n }\n }\n\n /**\n * Show cursor.\n */\n show() {\n this.trigger('show');\n clearInterval(this.visibleInt);\n this.visibleInt = setTimeout(() => {\n this.el.classList.remove(this.options.hiddenState);\n this.visible = true;\n this.render(true);\n }, this.options.showTimeout);\n }\n\n /**\n * Hide cursor.\n */\n hide() {\n this.trigger('hide');\n clearInterval(this.visibleInt);\n this.el.classList.add(this.options.hiddenState);\n this.visibleInt = setTimeout(() => this.visible = false, this.options.hideTimeout);\n }\n\n /**\n * Toggle cursor.\n *\n * @param {boolean} [force] Force state.\n */\n toggle(force) {\n if (force === true || force !== false && !this.visible) {\n this.show();\n } else {\n this.hide();\n }\n }\n\n /**\n * Add state/states to the cursor.\n *\n * @param {string} state State name.\n */\n addState(state) {\n this.trigger('addState', state);\n if (state === this.options.hiddenState) return this.hide();\n this.el.classList.add(...state.split(' '));\n if (this.options.visibleOnState) this.show();\n }\n\n /**\n * Remove state/states from cursor.\n *\n * @param {string} state State name.\n */\n removeState(state) {\n this.trigger('removeState', state);\n if (state === this.options.hiddenState) return this.show();\n this.el.classList.remove(...state.split(' '));\n if (this.options.visibleOnState && this.el.className === this.options.className) this.hide();\n }\n\n /**\n * Toggle cursor state.\n *\n * @param {string} state State name.\n * @param {boolean} [force] Force state.\n */\n toggleState(state, force) {\n if (force === true || force !== false && !this.el.classList.contains(state)) {\n this.addState(state);\n } else {\n this.removeState(state);\n }\n }\n\n /**\n * Set factor of skewing effect.\n *\n * @param {number} value Skewing factor.\n */\n setSkewing(value) {\n this.gsap.to(this, {skewing: value});\n }\n\n /**\n * Reverts skewing factor to default.\n */\n removeSkewing() {\n this.gsap.to(this, {skewing: this.options.skewing});\n }\n\n /**\n * Stick cursor to the element.\n *\n * @param {string|HTMLElement} element Element or selector.\n */\n setStick(element) {\n const el = typeof (element) === 'string' ? document.querySelector(element) : element;\n const rect = el.getBoundingClientRect();\n this.stick = {\n y: rect.top + (rect.height / 2),\n x: rect.left + (rect.width / 2),\n };\n }\n\n /**\n * Unstick cursor from the element.\n */\n removeStick() {\n this.stick = false;\n }\n\n /**\n * Transform cursor to text mode with a given string.\n *\n * @param {string} text Text.\n */\n setText(text) {\n this.text.innerHTML = text;\n this.addState(this.options.textState);\n this.setSkewing(this.options.skewingText);\n }\n\n /**\n * Reverts cursor from text mode.\n */\n removeText() {\n this.removeState(this.options.textState);\n this.removeSkewing();\n }\n\n /**\n * Transform cursor to svg icon mode.\n *\n * @param {string} name Icon identifier.\n * @param {string} [style=\"\"] Additional SVG styles.\n */\n setIcon(name, style = '') {\n this.text.innerHTML = ``;\n this.addState(this.options.iconState);\n this.setSkewing(this.options.skewingIcon);\n }\n\n /**\n * Reverts cursor from icon mode.\n */\n removeIcon() {\n this.removeState(this.options.iconState);\n this.removeSkewing();\n }\n\n /**\n * Transform cursor to media mode with a given element.\n *\n * @param {HTMLElement} element Element.\n */\n setMedia(element) {\n clearTimeout(this.mediaInt);\n if (element) {\n this.mediaBox.innerHTML = '';\n this.mediaBox.appendChild(element);\n }\n this.mediaInt = setTimeout(() => this.addState(this.options.mediaState), 20);\n this.setSkewing(this.options.skewingMedia);\n }\n\n /**\n * Revert cursor from media mode.\n */\n removeMedia() {\n clearTimeout(this.mediaInt);\n this.removeState(this.options.mediaState);\n this.mediaInt = setTimeout(() => this.mediaBox.innerHTML = '', this.options.hideMediaTimeout);\n this.removeSkewing();\n }\n\n /**\n * Transform cursor to image mode.\n *\n * @param {string} url Image url.\n */\n setImg(url) {\n if (!this.mediaImg) this.mediaImg = new Image();\n if (this.mediaImg.src !== url) this.mediaImg.src = url;\n this.setMedia(this.mediaImg);\n }\n\n /**\n * Reverts cursor from image mode.\n */\n removeImg() {\n this.removeMedia();\n }\n\n /**\n * Transform cursor to video mode.\n *\n * @param {string} url Video url.\n */\n setVideo(url) {\n if (!this.mediaVideo) {\n this.mediaVideo = document.createElement('video');\n this.mediaVideo.muted = true;\n this.mediaVideo.loop = true;\n this.mediaVideo.autoplay = true;\n }\n if (this.mediaVideo.src !== url) {\n this.mediaVideo.src = url;\n this.mediaVideo.load();\n }\n this.mediaVideo.play();\n this.setMedia(this.mediaVideo);\n }\n\n /**\n * Reverts cursor from video mode.\n */\n removeVideo() {\n if (this.mediaVideo && this.mediaVideo.readyState > 2) this.mediaVideo.pause();\n this.removeMedia();\n }\n\n /**\n * Attach an event handler function.\n *\n * @param {string} event Event name.\n * @param {function} callback Callback.\n */\n on(event, callback) {\n if (!(this.events[event] instanceof Array)) this.off(event);\n this.events[event].push(callback);\n }\n\n /**\n * Remove an event handler.\n *\n * @param {string} event Event name.\n * @param {function} [callback] Callback.\n */\n off(event, callback) {\n if (callback) {\n this.events[event] = this.events[event].filter((f) => f !== callback);\n } else {\n this.events[event] = [];\n }\n }\n\n /**\n * Execute all handlers for the given event type.\n *\n * @param {string} event Event name.\n * @param params Extra parameters.\n */\n trigger(event, ...params) {\n if (!this.events[event]) return;\n this.events[event].forEach((f) => f.call(this, this, ...params));\n }\n\n /**\n * Get cursor options from data attribute of a given element.\n *\n * @param {HTMLElement} element Element.\n * @return {Object} Options.\n */\n getFromDataset(element) {\n const dataset = element.dataset;\n return {\n state: dataset[this.options.dataAttr],\n show: dataset[this.options.dataAttr + 'Show'],\n text: dataset[this.options.dataAttr + 'Text'],\n icon: dataset[this.options.dataAttr + 'Icon'],\n img: dataset[this.options.dataAttr + 'Img'],\n video: dataset[this.options.dataAttr + 'Video'],\n stick: dataset[this.options.dataAttr + 'Stick'],\n };\n }\n\n /**\n * Destroy cursor instance.\n */\n destroy() {\n this.trigger('destroy');\n this.gsap.ticker.remove(this.ticker);\n this.container.removeEventListener('mouseleave', this.event.mouseleave);\n this.container.removeEventListener('mouseenter', this.event.mouseenter);\n this.container.removeEventListener('mousedown', this.event.mousedown);\n this.container.removeEventListener('mouseup', this.event.mouseup);\n this.container.removeEventListener('mousemove', this.event.mousemove);\n this.container.removeEventListener('mousemove', this.event.mousemoveOnce);\n this.container.removeEventListener('mouseover', this.event.mouseover);\n this.container.removeEventListener('mouseout', this.event.mouseout);\n if (this.el) {\n this.container.removeChild(this.el);\n this.el = null;\n this.mediaImg = null;\n this.mediaVideo = null;\n }\n }\n}\n"],"names":["MouseFollower","options","this","Object","assign","el","container","document","body","className","innerClassName","textClassName","mediaClassName","mediaBoxClassName","iconSvgClassName","iconSvgNamePrefix","iconSvgSrc","dataAttr","hiddenState","textState","iconState","activeState","mediaState","stateDetection","visible","visibleOnState","speed","ease","overwrite","skewing","skewingText","skewingIcon","skewingMedia","skewingDelta","skewingDeltaMax","stickDelta","showTimeout","hideOnLeave","hideTimeout","hideMediaTimeout","initialPos","window","innerWidth","innerHeight","gsap","querySelector","pos","x","y","vel","event","events","init","registerGSAP","create","createSetter","bind","render","ticker","add","createElement","classList","inner","text","media","mediaBox","appendChild","setter","quickSetter","rotation","scaleX","scaleY","wc","mouseleave","_this","hide","mouseenter","show","mousedown","addState","mouseup","removeState","mousemoveOnce","mousemove","e","to","stick","clientX","clientY","duration","onUpdate","mouseover","target","relatedTarget","contains","parentNode","matches","state","getFromDataset","params","setText","icon","setIcon","img","setImg","video","setVideo","setStick","mouseout","removeText","removeIcon","removeImg","removeVideo","removeStick","addEventListener","passive","once","force","trigger","distance","Math","sqrt","pow","scale","min","angle","atan2","PI","_this2","clearInterval","visibleInt","setTimeout","remove","_this3","toggle","_this$el$classList","split","_this$el$classList2","toggleState","setSkewing","value","removeSkewing","element","rect","getBoundingClientRect","top","height","left","width","innerHTML","name","style","setMedia","clearTimeout","mediaInt","_this4","removeMedia","_this5","url","mediaImg","Image","src","mediaVideo","muted","loop","autoplay","load","play","readyState","pause","on","callback","Array","off","push","filter","f","_arguments","arguments","_this6","forEach","call","concat","slice","dataset","destroy","removeEventListener","removeChild"],"mappings":"gOAQqBA,IAAAA,0BAoDjB,SAAYC,EAAAA,QAAAA,IAAAA,IAAAA,EAAU,IAElBC,KAAKD,QAAUE,OAAOC,OAAO,GAAI,CAC7BC,GAAI,KACJC,UAAWC,SAASC,KACpBC,UAAW,YACXC,eAAgB,kBAChBC,cAAe,iBACfC,eAAgB,kBAChBC,kBAAmB,sBACnBC,iBAAkB,eAClBC,kBAAmB,IACnBC,WAAY,GACZC,SAAU,SACVC,YAAa,UACbC,UAAW,QACXC,UAAW,QACXC,YAAa,UACbC,WAAY,SACZC,eAAgB,CACZ,WAAY,YAEhBC,SAAS,EACTC,gBAAgB,EAChBC,MAAO,IACPC,KAAM,WACNC,WAAW,EACXC,QAAS,EACTC,YAAa,EACbC,YAAa,EACbC,aAAc,EACdC,aAAc,KACdC,gBAAiB,IACjBC,WAAY,IACZC,YAAa,EACbC,aAAa,EACbC,YAAa,IACbC,iBAAkB,IAClBC,WAAY,EAAEC,OAAOC,YAAaD,OAAOE,cAC1C1C,GAECC,KAAKD,QAAQuB,SAAqC,MAA1BvB,EAAQsB,iBAAwBrB,KAAKD,QAAQsB,eAAe,WAAa,UAErGrB,KAAK0C,KAAO5C,EAAc4C,MAAQH,OAAOG,KACzC1C,KAAKG,GAAkC,iBAArBH,KAAKD,QAAQI,GAC3BE,SAASsC,cAAc3C,KAAKD,QAAQI,IAAMH,KAAKD,QAAQI,GAC3DH,KAAKI,UAAgD,iBAAvBL,KAAAA,QAAQK,UAClCC,SAASsC,cAAc3C,KAAKD,QAAQK,WAAaJ,KAAKD,QAAQK,UAClEJ,KAAK2B,QAAU3B,KAAKD,QAAQ4B,QAC5B3B,KAAK4C,IAAM,CAACC,EAAG7C,KAAKD,QAAQuC,WAAW,G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