1class Cursor { 2 constructor(options) { 3 this.options = jQuery.extend(true, { 4 container: "body", 5 speed: 0.7, 6 ease: "expo.out", 7 visibleTimeout: 300 8 }, options); 9 this.body = jQuery(this.options.container); 10 this.el = jQuery('<div class="prt-cursor"></div>'); 11 this.text = jQuery('<div class="prt-cursor-text"></div>'); 12 this.init(); 13 } 14 init() { 15 this.datatag(); 16 this.el.append(this.text); 17 this.body.append(this.el); 18 this.bind(); 19 this.move(-window.innerWidth, -window.innerHeight, 0); 20 dragcursor(); 21 } 22 datatag() { 23 jQuery('.elementor-section').each(function(i, e) { 24 jQuery(e).attr('data-cursor', ''); 25 if (jQuery(e).hasClass('prt-cursor-color-light-color')) { 26 jQuery(e).attr('data-cursor', 'light-color'); 27 } else if (jQuery(e).hasClass('prt-cursor-color-white-color')) { 28 jQuery(e).attr('data-cursor', 'white-color'); 29 } else if (jQuery(e).hasClass('prt-cursor-color-global-color')) { 30 jQuery(e).attr('data-cursor', 'global-color'); 31 } else if (jQuery(e).hasClass('prt-cursor-color-secondary-color')) { 32 jQuery(e).attr('data-cursor', 'secondary-color'); 33 } else { 34 jQuery(e).attr('data-cursor', 'blackish-color'); 35 } 36 }); 37 } 38 bind() { 39 const self = this; 40 this.body.on('mouseleave', () => { 41 self.hide(); 42 }).on('mouseenter', () => { 43 self.show(); 44 }).on('mousemove', (e) => { 45 this.pos = { 46 x: this.stick ? this.stick.x - ((this.stick.x - e.clientX) * 0.15) : e.clientX, 47 y: this.stick ? this.stick.y - ((this.stick.y - e.clientY) * 0.15) : e.clientY 48 }; 49 this.update(); 50 }).on('mousedown', () => { 51 self.setState('-active'); 52 }).on('mouseup', () => { 53 self.removeState('-active'); 54 }).on('mouseenter', 'a,input,textarea,button', () => { 55 self.setState('-pointer'); 56 }).on('mouseleave', 'a,input,textarea,button', () => { 57 self.removeState('-pointer'); 58 }).on('mouseenter', 'iframe', () => { 59 self.hide(); 60 }).on('mouseleave', 'iframe', () => { 61 self.show(); 62 }).on('mouseenter', '[data-cursor]', function() { 63 self.setState(this.dataset.cursor); 64 }).on('mouseleave', '[data-cursor]', function() { 65 self.removeState(this.dataset.cursor); 66 }).on('mouseenter', '[data-cursor-text]', function() { 67 self.setText(this.dataset.cursorText); 68 }).on('mouseleave', '[data-cursor-text]', function() { 69 self.removeText(); 70 }).on('mouseenter', '[data-cursor-stick]', function() { 71 self.setStick(this.dataset.cursorStick); 72 }).on('mouseleave', '[data-cursor-stick]', function() { 73 self.removeStick(); 74 }).on('mouseenter', '[data-cursor-tooltip]', function() { 75 self.setTootip(this.dataset.cursorTooltip); 76 }).on('mouseleave', '[data-cursor-tooltip]', function() { 77 self.removeTooltip(); 78 }); 79 } 80 setState(state) { 81 this.tc.addClass(state); 82 } 83 removeState(state) { 84 this.tc.removeClass(state); 85 } 86 toggleState(state) { 87 this.tc.toggleClass(state); 88 } 89 setState(state) { 90 this.el.addClass(state); 91 } 92 removeState(state) { 93 this.el.removeClass(state); 94 } 95 toggleState(state) { 96 this.el.toggleClass(state); 97 } 98 setText(text) { 99 this.text.html(text); 100 this.el.addClass('-text'); 101 } 102 removeText() { 103 this.el.removeClass('-text'); 104 } 105 setTootip(text) { 106 this.text.html(text); 107 this.el.addClass('-tooltip'); 108 } 109 removeTooltip() { 110 this.text.html(''); 111 this.el.removeClass('-tooltip'); 112 } 113 setStick(el) { 114 const target = jQuery(el); 115 const bound = target.get(0).getBoundingClientRect(); 116 this.stick = { 117 y: bound.top + (target.height() / 2),
118 x: bound.left + (target.width() / 2) 119 }; 120 this.move(this.stick.x, this.stick.y, 5); 121 } 122 removeStick() { 123 this.stick = false; 124 } 125 update() { 126 this.move(); 127 this.show(); 128 } 129 move(x, y, duration) { 130 gsap.to(this.el, { 131 x: x || this.pos.x, 132 y: y || this.pos.y, 133 force3D: true, 134 overwrite: true, 135 ease: this.options.ease, 136 duration: this.visible ? (duration || this.options.speed) : 0 137 }); 138 } 139 show() { 140 if (this.visible) return; 141 clearInterval(this.visibleInt); 142 this.el.addClass('-visible'); 143 this.visibleInt = setTimeout(() => this.visible = true); 144 } 145 hide() { 146 clearInterval(this.visibleInt); 147 this.el.removeClass('-visible'); 148 this.visibleInt = setTimeout(() => this.visible = false, this.options.visibleTimeout); 149 } 150} 151 152function dragcursor() { 153 let cursor2 = document.querySelector(".prt-cursor"); 154 document.addEventListener("pointermove", moveCursor); 155 156 function moveCursor(e) { 157 gsap.to(cursor2, { 158 duration: .5, 159 x: e.clientX, 160 y: e.clientY, 161 autoAlpha: 1, 162 ease: "ease-in-out", 163 }); 164 } 165}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.