TweenMax.js
4 years ago
iscroll.js
4 years ago
isotope.js
4 years ago
jquery-countdown.js
4 years ago
jquery-slimscroll.js
4 years ago
lottie.js
4 years ago
modal.js
4 years ago
premium-addons.js
4 years ago
premium-eq-height.js
4 years ago
premium-maps.js
4 years ago
premium-vscroll.js
4 years ago
prettyPhoto.js
4 years ago
slick.js
4 years ago
typed.js
4 years ago
universal-tilt.js
4 years ago
vticker.js
4 years ago
universal-tilt.js
273 lines
| 1 | ! function (e, t) { |
| 2 | "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define("UniversalTilt", [], t) : "object" == typeof exports ? exports.UniversalTilt = t() : e.UniversalTilt = t() |
| 3 | }("object" != typeof window ? global.window = global : window, function () { |
| 4 | return function (e) { |
| 5 | var t = {}; |
| 6 | |
| 7 | function n(i) { |
| 8 | if (t[i]) return t[i].exports; |
| 9 | var s = t[i] = { |
| 10 | i: i, |
| 11 | l: !1, |
| 12 | exports: {} |
| 13 | }; |
| 14 | return e[i].call(s.exports, s, s.exports, n), s.l = !0, s.exports |
| 15 | } |
| 16 | return n.m = e, n.c = t, n.d = function (e, t, i) { |
| 17 | n.o(e, t) || Object.defineProperty(e, t, { |
| 18 | enumerable: !0, |
| 19 | get: i |
| 20 | }) |
| 21 | }, n.r = function (e) { |
| 22 | "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { |
| 23 | value: "Module" |
| 24 | }), Object.defineProperty(e, "__esModule", { |
| 25 | value: !0 |
| 26 | }) |
| 27 | }, n.t = function (e, t) { |
| 28 | if (1 & t && (e = n(e)), 8 & t) return e; |
| 29 | if (4 & t && "object" == typeof e && e && e.__esModule) return e; |
| 30 | var i = Object.create(null); |
| 31 | if (n.r(i), Object.defineProperty(i, "default", { |
| 32 | enumerable: !0, |
| 33 | value: e |
| 34 | }), 2 & t && "string" != typeof e) |
| 35 | for (var s in e) n.d(i, s, function (t) { |
| 36 | return e[t] |
| 37 | }.bind(null, s)); |
| 38 | return i |
| 39 | }, n.n = function (e) { |
| 40 | var t = e && e.__esModule ? function () { |
| 41 | return e.default |
| 42 | } : function () { |
| 43 | return e |
| 44 | }; |
| 45 | return n.d(t, "a", t), t |
| 46 | }, n.o = function (e, t) { |
| 47 | return Object.prototype.hasOwnProperty.call(e, t) |
| 48 | }, n.p = "", n(n.s = 0) |
| 49 | }([function (e, t, n) { |
| 50 | "use strict"; |
| 51 | Object.defineProperty(t, "__esModule", { |
| 52 | value: !0 |
| 53 | }), t.default = void 0; |
| 54 | var i, s = (i = n(1)) && i.__esModule ? i : { |
| 55 | default: i |
| 56 | }; |
| 57 | var o = s.default; |
| 58 | t.default = o, t.default = s.default, e.exports = t.default |
| 59 | }, function (e, t, n) { |
| 60 | "use strict"; |
| 61 | |
| 62 | function i(e, t) { |
| 63 | for (var n = 0; n < t.length; n++) { |
| 64 | var i = t[n]; |
| 65 | i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | function s(e, t, n) { |
| 70 | return t in e ? Object.defineProperty(e, t, { |
| 71 | value: n, |
| 72 | enumerable: !0, |
| 73 | configurable: !0, |
| 74 | writable: !0 |
| 75 | }) : e[t] = n, e |
| 76 | } |
| 77 | Object.defineProperty(t, "__esModule", { |
| 78 | value: !0 |
| 79 | }), t.default = void 0; |
| 80 | var o = function () { |
| 81 | function e(t) { |
| 82 | var n = this, |
| 83 | i = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, |
| 84 | o = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}; |
| 85 | ! function (e, t) { |
| 86 | if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") |
| 87 | }(this, e), s(this, "onMouseEnter", function () { |
| 88 | n.updateElementPosition(), n.transitions(), "function" == typeof n.callbacks.onMouseEnter && n.callbacks.onMouseEnter(n.element) |
| 89 | }), s(this, "onMouseMove", function (e) { |
| 90 | null !== n.updateCall && cancelAnimationFrame(n.updateCall), n.event = e, n.updateElementPosition(), n.updateCall = requestAnimationFrame(function () { |
| 91 | return n.update() |
| 92 | }), "function" == typeof n.callbacks.onMouseMove && n.callbacks.onMouseMove(n.element) |
| 93 | }), s(this, "onMouseLeave", function () { |
| 94 | n.transitions(), requestAnimationFrame(function () { |
| 95 | return n.reset() |
| 96 | }), "function" == typeof n.callbacks.onMouseLeave && n.callbacks.onMouseLeave(n.element) |
| 97 | }), s(this, "onDeviceMove", function (e) { |
| 98 | n.event = e, n.update(), n.updateElementPosition(), n.transitions(), "function" == typeof n.callbacks.onDeviceMove && n.callbacks.onDeviceMove(n.element) |
| 99 | }), this.element = t, this.callbacks = o, this.settings = this.extendSettings(i), "function" == typeof this.callbacks.onInit && this.callbacks.onInit(this.element), this.reverse = this.settings.reverse ? -1 : 1, this.settings.shine && this.shine(), this.element.style.transform = "perspective(".concat(this.settings.perspective, "px)"), this.addEventListeners() |
| 100 | } |
| 101 | var t, n, o; |
| 102 | return t = e, o = [{ |
| 103 | key: "init", |
| 104 | value: function () { |
| 105 | var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, |
| 106 | n = t.elements, |
| 107 | i = t.settings, |
| 108 | s = t.callbacks; |
| 109 | n instanceof Node && (n = [n]), n instanceof NodeList && (n = [].slice.call(n)); |
| 110 | var o = !0, |
| 111 | a = !1, |
| 112 | l = void 0; |
| 113 | try { |
| 114 | for (var r, c = n[Symbol.iterator](); !(o = (r = c.next()).done); o = !0) { |
| 115 | var u = r.value; |
| 116 | "universalTilt" in u || (u.universalTilt = new e(u, i, s)) |
| 117 | } |
| 118 | } catch (e) { |
| 119 | a = !0, l = e |
| 120 | } finally { |
| 121 | try { |
| 122 | o || null == c.return || c.return() |
| 123 | } finally { |
| 124 | if (a) throw l |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | }], (n = [{ |
| 129 | key: "isMobile", |
| 130 | value: function () { |
| 131 | return window.DeviceMotionEvent && "ontouchstart" in document.documentElement |
| 132 | } |
| 133 | }, { |
| 134 | key: "addEventListeners", |
| 135 | value: function () { |
| 136 | navigator.userAgent.match(this.settings.exclude) || (this.isMobile() ? window.addEventListener("devicemotion", this.onDeviceMove) : ("element" === this.settings.base ? this.base = this.element : "window" === this.settings.base && (this.base = window), this.base.addEventListener("mouseenter", this.onMouseEnter), this.base.addEventListener("mousemove", this.onMouseMove), this.base.addEventListener("mouseleave", this.onMouseLeave))) |
| 137 | } |
| 138 | }, { |
| 139 | key: "removeEventListeners", |
| 140 | value: function () { |
| 141 | window.removeEventListener("devicemotion", this.onDeviceMove), this.base.removeEventListener("mouseenter", this.onMouseEnter), this.base.removeEventListener("mousemove", this.onMouseMove), this.base.removeEventListener("mouseleave", this.onMouseLeave) |
| 142 | } |
| 143 | }, { |
| 144 | key: "destroy", |
| 145 | value: function () { |
| 146 | clearTimeout(this.timeout), null !== this.updateCall && cancelAnimationFrame(this.updateCall), "function" == typeof this.callbacks.onDestroy && this.callbacks.onDestroy(this.element), this.reset(), this.removeEventListeners(), this.element.universalTilt = null, delete this.element.universalTilt, this.element = null |
| 147 | } |
| 148 | }, { |
| 149 | key: "reset", |
| 150 | value: function () { |
| 151 | this.event = { |
| 152 | pageX: this.left + this.width / 2, |
| 153 | pageY: this.top + this.height / 2 |
| 154 | }, this.settings.reset && (this.element.style.transform = "perspective(".concat(this.settings.perspective, "px) rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)")), this.settings.shine && !this.settings["shine-save"] && Object.assign(this.shineElement.style, { |
| 155 | transform: "rotate(180deg) translate3d(-50%, -50%, 0)", |
| 156 | opacity: "0" |
| 157 | }) |
| 158 | } |
| 159 | }, { |
| 160 | key: "getValues", |
| 161 | value: function () { |
| 162 | var e, t, n; |
| 163 | this.isMobile() ? (e = this.event.accelerationIncludingGravity.x / 4, t = this.event.accelerationIncludingGravity.y / 4, 90 === window.orientation ? (n = (1 - t) / 2, t = (1 + e) / 2, e = n) : -90 === window.orientation ? (n = (1 + t) / 2, t = (1 - e) / 2, e = n) : 0 === window.orientation ? (t = n = (1 + t) / 2, e = (1 + e) / 2) : 180 === window.orientation && (t = n = (1 - t) / 2, e = (1 - e) / 2)) : "element" === this.settings.base ? (e = (this.event.clientX - this.left) / this.width, t = (this.event.clientY - this.top) / this.height) : "window" === this.settings.base && (e = this.event.clientX / window.innerWidth, t = this.event.clientY / window.innerHeight); |
| 164 | e = Math.min(Math.max(e, 0), 1), t = Math.min(Math.max(t, 0), 1); |
| 165 | var i = (this.settings.max / 2 - e * this.settings.max).toFixed(2), |
| 166 | s = (t * this.settings.max - this.settings.max / 2).toFixed(2), |
| 167 | o = Math.atan2(e - .5, .5 - t) * (180 / Math.PI); |
| 168 | return { |
| 169 | tiltX: this.reverse * i, |
| 170 | tiltY: this.reverse * s, |
| 171 | angle: o |
| 172 | } |
| 173 | } |
| 174 | }, { |
| 175 | key: "updateElementPosition", |
| 176 | value: function () { |
| 177 | var e = this.element.getBoundingClientRect(); |
| 178 | this.width = this.element.offsetWidth, this.height = this.element.offsetHeight, this.left = e.left, this.top = e.top |
| 179 | } |
| 180 | }, { |
| 181 | key: "update", |
| 182 | value: function () { |
| 183 | var e = this.getValues(); |
| 184 | this.element.style.transform = "perspective(".concat(this.settings.perspective, "px)\n rotateX(").concat(this.settings.disabled && "X" === this.settings.disabled.toUpperCase() ? 0 : e.tiltY, "deg)\n rotateY(").concat(this.settings.disabled && "Y" === this.settings.disabled.toUpperCase() ? 0 : e.tiltX, "deg)\n scale3d(").concat(this.settings.scale, ", ").concat(this.settings.scale, ", ").concat(this.settings.scale, ")"), this.settings.shine && Object.assign(this.shineElement.style, { |
| 185 | transform: "rotate(".concat(e.angle, "deg) translate3d(-50%, -50%, 0)"), |
| 186 | opacity: "".concat(this.settings["shine-opacity"]) |
| 187 | }), this.element.dispatchEvent(new CustomEvent("tiltChange", { |
| 188 | detail: e |
| 189 | })), this.updateCall = null |
| 190 | } |
| 191 | }, { |
| 192 | key: "shine", |
| 193 | value: function () { |
| 194 | var e = document.createElement("div"), |
| 195 | t = document.createElement("div"); |
| 196 | e.classList.add("shine"), t.classList.add("shine-inner"), e.appendChild(t), this.element.appendChild(e), this.shineWrapper = this.element.querySelector(".shine"), this.shineElement = this.element.querySelector(".shine-inner"), Object.assign(this.shineWrapper.style, { |
| 197 | position: "absolute", |
| 198 | top: "0", |
| 199 | left: "0", |
| 200 | height: "100%", |
| 201 | width: "100%", |
| 202 | overflow: "hidden" |
| 203 | }), Object.assign(this.shineElement.style, { |
| 204 | position: "absolute", |
| 205 | top: "50%", |
| 206 | left: "50%", |
| 207 | "pointer-events": "none", |
| 208 | "background-image": "linear-gradient(0deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%)", |
| 209 | width: "".concat(2 * this.element.offsetWidth, "px"), |
| 210 | height: "".concat(2 * this.element.offsetWidth, "px"), |
| 211 | transform: "rotate(180deg) translate3d(-50%, -50%, 0)", |
| 212 | "transform-origin": "0% 0%", |
| 213 | opacity: "0" |
| 214 | }) |
| 215 | } |
| 216 | }, { |
| 217 | key: "transitions", |
| 218 | value: function () { |
| 219 | var e = this; |
| 220 | clearTimeout(this.timeout), this.element.style.transition = "all ".concat(this.settings.speed, "ms ").concat(this.settings.easing), this.settings.shine && (this.shineElement.style.transition = "opacity ".concat(this.settings.speed, "ms ").concat(this.settings.easing)), this.timeout = setTimeout(function () { |
| 221 | e.element.style.transition = "", e.settings.shine && (e.shineElement.style.transition = "") |
| 222 | }, this.settings.speed) |
| 223 | } |
| 224 | }, { |
| 225 | key: "extendSettings", |
| 226 | value: function (e) { |
| 227 | var t = { |
| 228 | base: "element", |
| 229 | disabled: null, |
| 230 | easing: "cubic-bezier(.03, .98, .52, .99)", |
| 231 | exclude: null, |
| 232 | max: 35, |
| 233 | perspective: 1e3, |
| 234 | reset: !0, |
| 235 | reverse: !1, |
| 236 | scale: 1, |
| 237 | shine: !1, |
| 238 | "shine-opacity": 0, |
| 239 | "shine-save": !1, |
| 240 | speed: 300 |
| 241 | }, |
| 242 | n = {}; |
| 243 | for (var i in t) |
| 244 | if (i in e) n[i] = e[i]; |
| 245 | else if (this.element.getAttribute("data-".concat(i))) { |
| 246 | var s = this.element.getAttribute("data-".concat(i)); |
| 247 | try { |
| 248 | n[i] = JSON.parse(s) |
| 249 | } catch (e) { |
| 250 | n[i] = s |
| 251 | } |
| 252 | } else n[i] = t[i]; |
| 253 | return n |
| 254 | } |
| 255 | }]) && i(t.prototype, n), o && i(t, o), e |
| 256 | }(); |
| 257 | if (t.default = o, "undefined" != typeof document) { |
| 258 | window.UniversalTilt = o; |
| 259 | var a = document.querySelectorAll("[data-tilt]"); |
| 260 | a.length && o.init({ |
| 261 | elements: a |
| 262 | }) |
| 263 | } |
| 264 | window.jQuery && (window.jQuery.fn.universalTilt = function () { |
| 265 | var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; |
| 266 | o.init({ |
| 267 | elements: this, |
| 268 | settings: e.settings || {}, |
| 269 | callbacks: e.callbacks || {} |
| 270 | }) |
| 271 | }) |
| 272 | }]) |
| 273 | }); |