diff --git a/dest/tilt.jquery.js b/dest/tilt.jquery.js index e9a1b02..65fbe44 100644 --- a/dest/tilt.jquery.js +++ b/dest/tilt.jquery.js @@ -140,17 +140,20 @@ * Prepare elements */ var prepareGlare = function prepareGlare() { + var glarePrerender = this.settings.glarePrerender; // If option pre-render is enabled we assume all html/css is present for an optimal glare effect. - if (this.settings.glarePrerender) return; - - // Create glare element - $(this).append('
'); + if (!glarePrerender) + // Create glare element + $(this).append('
'); // Store glare selector if glare is enabled this.glareElementWrapper = $(this).find(".js-tilt-glare"); this.glareElement = $(this).find(".js-tilt-glare-inner"); + // Remember? We assume all css is already set, so just return + if (glarePrerender) return; + // Abstracted re-usable glare styles var stretch = { 'position': 'absolute', diff --git a/dest/tilt.jquery.js.map b/dest/tilt.jquery.js.map index 3f23bc9..91eaf4c 100644 --- a/dest/tilt.jquery.js.map +++ b/dest/tilt.jquery.js.map @@ -1 +1 @@ -{"version":3,"sources":["tilt.jquery.js"],"names":["$","fn","tilt","options","requestTick","ticking","requestAnimationFrame","updateTransforms","bind","bindEvents","on","mouseMove","mouseEnter","settings","reset","mouseLeave","setTransition","timeout","undefined","clearTimeout","css","speed","easing","glare","glareElement","setTimeout","event","call","trigger","getMousePositions","pageX","offset","left","outerWidth","pageY","top","outerHeight","x","y","mousePositions","getValues","width","height","percentageX","percentageY","tiltX","maxTilt","toFixed","tiltY","angle","Math","atan2","PI","transforms","perspective","maxGlare","axis","scale","prepareGlare","glarePrerender","append","glareElementWrapper","find","stretch","destroy","each","remove","off","results","push","data","transition","extend","is","init","jQuery"],"mappings":";;AAAC,WAAUA,CAAV,EAAa;AACVA,MAAEC,EAAF,CAAKC,IAAL,GAAY,UAAUC,OAAV,EAAmB;;AAE3B;;;AAGA,YAAMC,cAAc,SAAdA,WAAc,GAAW;AAC3B,gBAAI,KAAKC,OAAT,EAAkB;AAClBC,kCAAsBC,iBAAiBC,IAAjB,CAAsB,IAAtB,CAAtB;AACA,iBAAKH,OAAL,GAAe,IAAf;AAC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IAP9C;AAQrBxD,uBAAOd,EAAE,IAAF,EAAQyE,EAAR,CAAW,mBAAX,IAAkCzE,EAAE,IAAF,EAAQsE,IAAR,CAAa,YAAb,CAAlC,GAA+D,IARjD;AASrB/C,uBAAOvB,EAAE,IAAF,EAAQyE,EAAR,CAAW,mBAAX,IAAkCzE,EAAE,IAAF,EAAQsE,IAAR,CAAa,YAAb,CAAlC,GAA+D,KATjD;AAUrBf,0BAAUvD,EAAE,IAAF,EAAQyE,EAAR,CAAW,sBAAX,IAAqCzE,EAAE,IAAF,EAAQsE,IAAR,CAAa,eAAb,CAArC,GAAqE;AAV1D,aAAT,EAWbnE,OAXa,CAAhB;;AAcA,iBAAKuE,IAAL,GAAY,YAAM;AACd;AACA1E,0BAAQsE,IAAR,CAAa,UAAb,EAAyB,OAAKzD,QAA9B;;AAEA;AACA,oBAAG,OAAKA,QAAL,CAAcU,KAAjB,EAAwBmC,aAAa/B,IAAb;;AAExB;AACAlB,2BAAWkB,IAAX;AACH,aATD;;AAWA;AACA,iBAAK+C,IAAL;AAEH,SAnCM,CAAP;AAoCH,KAjPD;;AAmPA;;;AAGA1E,MAAE,aAAF,EAAiBE,IAAjB;AAEH,CAzPA,EAyPCyE,MAzPD,CAAD","file":"tilt.jquery.js","sourcesContent":["(function ($) {\r\n $.fn.tilt = function (options) {\r\n\r\n /**\r\n * RequestAnimationFrame\r\n */\r\n const requestTick = function() {\r\n if (this.ticking) return;\r\n requestAnimationFrame(updateTransforms.bind(this));\r\n this.ticking = true;\r\n };\r\n\r\n /**\r\n * Bind mouse movement evens on instance\r\n */\r\n const bindEvents = function() {\r\n $(this).on('mousemove', mouseMove);\r\n $(this).on('mouseenter', mouseEnter);\r\n if (this.settings.reset) $(this).on('mouseleave', mouseLeave);\r\n };\r\n\r\n /**\r\n * Set transition only on mouse leave and mouse enter so it doesn't influence mouse move transforms\r\n */\r\n const setTransition = function() {\r\n if (this.timeout !== undefined) clearTimeout(this.timeout);\r\n $(this).css({'transition': `${this.settings.speed}ms ${this.settings.easing}`});\r\n if(this.settings.glare) this.glareElement.css({'transition': `opacity ${this.settings.speed}ms ${this.settings.easing}`});\r\n this.timeout = setTimeout(() => {\r\n $(this).css({'transition': ''});\r\n if(this.settings.glare) this.glareElement.css({'transition': ''});\r\n }, this.settings.speed);\r\n };\r\n\r\n /**\r\n * When user mouse enters tilt element\r\n */\r\n const mouseEnter = function(event) {\r\n this.ticking = false;\r\n $(this).css({'will-change': 'transform'});\r\n setTransition.call(this);\r\n\r\n // Trigger change event\r\n $(this).trigger(\"tilt.mouseEnter\");\r\n };\r\n\r\n /**\r\n * Return the x,y position of the muose on the tilt element\r\n * @returns {{x: *, y: *}}\r\n */\r\n const getMousePositions = function(event) {\r\n if (typeof(event) === \"undefined\") {\r\n event = {\r\n pageX: $(this).offset().left + $(this).outerWidth() / 2,\r\n pageY: $(this).offset().top + $(this).outerHeight() / 2\r\n };\r\n }\r\n return {x: event.pageX, y: event.pageY};\r\n };\r\n\r\n /**\r\n * When user mouse moves over the tilt element\r\n */\r\n const mouseMove = function(event) {\r\n this.mousePositions = getMousePositions(event);\r\n requestTick.call(this);\r\n };\r\n\r\n /**\r\n * When user mouse leaves tilt element\r\n */\r\n const mouseLeave = function() {\r\n setTransition.call(this);\r\n this.reset = true;\r\n requestTick.call(this);\r\n\r\n // Trigger change event\r\n $(this).trigger(\"tilt.mouseLeave\");\r\n };\r\n\r\n /**\r\n * Get tilt values\r\n *\r\n * @returns {{x: tilt value, y: tilt value}}\r\n */\r\n const getValues = function() {\r\n const width = $(this).width();\r\n const height = $(this).height();\r\n const left = $(this).offset().left;\r\n const top = $(this).offset().top;\r\n const percentageX = (this.mousePositions.x - left) / width;\r\n const percentageY = (this.mousePositions.y - top) / height;\r\n // x or y position inside instance / width of instance = percentage of position inside instance * the max tilt value\r\n const tiltX = ((this.settings.maxTilt / 2) - ((percentageX) * this.settings.maxTilt)).toFixed(2);\r\n const tiltY = (((percentageY) * this.settings.maxTilt) - (this.settings.maxTilt / 2)).toFixed(2);\r\n // angle\r\n const angle = Math.atan2(this.mousePositions.x - (left+width/2),- (this.mousePositions.y - (top+height/2)) )*(180/Math.PI);\r\n // Return x & y tilt values\r\n return {tiltX, tiltY, 'percentageX': percentageX * 100, 'percentageY': percentageY * 100, angle};\r\n };\r\n\r\n /**\r\n * Update tilt transforms on mousemove\r\n */\r\n const updateTransforms = function() {\r\n this.transforms = getValues.call(this);\r\n\r\n if (this.reset) {\r\n this.reset = false;\r\n $(this).css('transform', `perspective(${this.settings.perspective}px) rotateX(0deg) rotateY(0deg)`);\r\n\r\n // Rotate glare if enabled\r\n if (this.settings.glare){\r\n this.glareElement.css('transform', `rotate(180deg) scale(1.75)`);\r\n this.glareElement.css('opacity', `${this.settings.maxGlare/4}`);\r\n }\r\n\r\n return;\r\n } else {\r\n $(this).css('transform', `perspective(${this.settings.perspective}px) rotateX(${this.settings.axis === 'x' ? 0 : this.transforms.tiltY}deg) rotateY(${this.settings.axis === 'y' ? 0 : this.transforms.tiltX}deg) scale3d(${this.settings.scale},${this.settings.scale},${this.settings.scale})`);\r\n\r\n // Rotate glare if enabled\r\n if (this.settings.glare){\r\n this.glareElement.css('transform', `rotate(${this.transforms.angle}deg) scale(1.75)`);\r\n this.glareElement.css('opacity', `${this.transforms.percentageY * this.settings.maxGlare / 100}`);\r\n }\r\n }\r\n\r\n // Trigger change event\r\n $(this).trigger(\"change\", [this.transforms]);\r\n\r\n this.ticking = false;\r\n };\r\n\r\n /**\r\n * Prepare elements\r\n */\r\n const prepareGlare = function () {\r\n\r\n // If option pre-render is enabled we assume all html/css is present for an optimal glare effect.\r\n if(this.settings.glarePrerender) return;\r\n\r\n // Create glare element\r\n $(this).append(`
`);\r\n\r\n // Store glare selector if glare is enabled\r\n this.glareElementWrapper = $(this).find(\".js-tilt-glare\");\r\n this.glareElement = $(this).find(\".js-tilt-glare-inner\");\r\n\r\n // Abstracted re-usable glare styles\r\n const stretch = {\r\n 'position': 'absolute',\r\n 'top': '0',\r\n 'left': '0',\r\n 'width': '100%',\r\n 'height': '100%',\r\n };\r\n\r\n // Style glare wrapper\r\n this.glareElementWrapper.css(stretch).css({\r\n 'overflow': 'hidden',\r\n });\r\n\r\n // Style glare element\r\n this.glareElement.css(stretch).css({\r\n 'background-image': `linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%)`,\r\n 'opacity': `${this.settings.maxGlare / 2}`,\r\n 'transform': `rotate(180deg) scale(1.75)`\r\n });\r\n\r\n };\r\n\r\n /**\r\n * Public methods\r\n */\r\n $.fn.tilt.destroy = function() {\r\n $(this).each(function () {\r\n $(this).find('.js-tilt-glare').remove();\r\n $(this).css({'will-change': '', 'transform': ''});\r\n $(this).off('mousemove mouseenter mouseleave');\r\n });\r\n };\r\n\r\n $.fn.tilt.getValues = function() {\r\n const results = [];\r\n $(this).each(function () {\r\n this.mousePositions = getMousePositions.call(this);\r\n results.push(getValues.call(this));\r\n });\r\n return results;\r\n };\r\n\r\n $.fn.tilt.reset = function() {\r\n $(this).each(function () {\r\n this.mousePositions = getMousePositions.call(this);\r\n this.settings = $(this).data('settings');\r\n mouseLeave.call(this);\r\n setTimeout(() => {\r\n this.reset = false;\r\n }, this.settings.transition);\r\n });\r\n };\r\n\r\n /**\r\n * Loop every instance\r\n */\r\n return this.each(function () {\r\n\r\n /**\r\n * Default settings merged with user settings\r\n * Can be set trough data attributes or as parameter.\r\n * @type {*}\r\n */\r\n this.settings = $.extend({\r\n maxTilt: $(this).is('[data-tilt-max]') ? $(this).data('tilt-max') : 20,\r\n perspective: $(this).is('[data-tilt-perspective]') ? $(this).data('tilt-perspective') : 300,\r\n easing: $(this).is('[data-tilt-easing]') ? $(this).data('tilt-easing') : 'cubic-bezier(.03,.98,.52,.99)',\r\n scale: $(this).is('[data-tilt-scale]') ? $(this).data('tilt-scale') : '1',\r\n speed: $(this).is('[data-tilt-speed]') ? $(this).data('tilt-speed') : '400',\r\n transition: $(this).is('[data-tilt-transition]') ? $(this).data('tilt-transition') : true,\r\n axis: $(this).is('[data-tilt-axis]') ? $(this).data('tilt-axis') : null,\r\n reset: $(this).is('[data-tilt-reset]') ? $(this).data('tilt-reset') : true,\r\n glare: $(this).is('[data-tilt-glare]') ? $(this).data('tilt-glare') : false,\r\n maxGlare: $(this).is('[data-tilt-maxglare]') ? $(this).data('tilt-maxglare') : 1,\r\n }, options);\r\n\r\n\r\n this.init = () => {\r\n // Store settings\r\n $(this).data('settings', this.settings);\r\n\r\n // Prepare element\r\n if(this.settings.glare) prepareGlare.call(this);\r\n\r\n // Bind events\r\n bindEvents.call(this);\r\n };\r\n\r\n // Init\r\n this.init();\r\n\r\n });\r\n };\r\n\r\n /**\r\n * Auto load\r\n */\r\n $('[data-tilt]').tilt();\r\n\r\n}(jQuery));"]} \ No newline at end of file +{"version":3,"sources":["tilt.jquery.js"],"names":["$","fn","tilt","options","requestTick","ticking","requestAnimationFrame","updateTransforms","bind","bindEvents","on","mouseMove","mouseEnter","settings","reset","mouseLeave","setTransition","timeout","undefined","clearTimeout","css","speed","easing","glare","glareElement","setTimeout","event","call","trigger","getMousePositions","pageX","offset","left","outerWidth","pageY","top","outerHeight","x","y","mousePositions","getValues","width","height","percentageX","percentageY","tiltX","maxTilt","toFixed","tiltY","angle","Math","atan2","PI","transforms","perspective","maxGlare","axis","scale","prepareGlare","glarePrerender","append","glareElementWrapper","find","stretch","destroy","each","remove","off","results","push","data","transition","extend","is","init","jQuery"],"mappings":";;AAAC,WAAUA,CAAV,EAAa;AACVA,MAAEC,EAAF,CAAKC,IAAL,GAAY,UAAUC,OAAV,EAAmB;;AAE3B;;;AAGA,YAAMC,cAAc,SAAdA,WAAc,GAAW;AAC3B,gBAAI,KAAKC,OAAT,EAAkB;AAClBC,kCAAsBC,iBAAiBC,IAAjB,CAAsB,IAAtB,CAAtB;AACA,iBAAKH,OAAL,GAAe,IAAf;AACH,SAJD;;AAMA;;;AAGA,YAAMI,aAAa,SAAbA,UAAa,GAAW;AAC1BT,cAAE,IAA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AP9C;AAQrBxD,uBAAOd,EAAE,IAAF,EAAQyE,EAAR,CAAW,mBAAX,IAAkCzE,EAAE,IAAF,EAAQsE,IAAR,CAAa,YAAb,CAAlC,GAA+D,IARjD;AASrB/C,uBAAOvB,EAAE,IAAF,EAAQyE,EAAR,CAAW,mBAAX,IAAkCzE,EAAE,IAAF,EAAQsE,IAAR,CAAa,YAAb,CAAlC,GAA+D,KATjD;AAUrBf,0BAAUvD,EAAE,IAAF,EAAQyE,EAAR,CAAW,sBAAX,IAAqCzE,EAAE,IAAF,EAAQsE,IAAR,CAAa,eAAb,CAArC,GAAqE;AAV1D,aAAT,EAWbnE,OAXa,CAAhB;;AAcA,iBAAKuE,IAAL,GAAY,YAAM;AACd;AACA1E,0BAAQsE,IAAR,CAAa,UAAb,EAAyB,OAAKzD,QAA9B;;AAEA;AACA,oBAAG,OAAKA,QAAL,CAAcU,KAAjB,EAAwBmC,aAAa/B,IAAb;;AAExB;AACAlB,2BAAWkB,IAAX;AACH,aATD;;AAWA;AACA,iBAAK+C,IAAL;AAEH,SAnCM,CAAP;AAoCH,KApPD;;AAsPA;;;AAGA1E,MAAE,aAAF,EAAiBE,IAAjB;AAEH,CA5PA,EA4PCyE,MA5PD,CAAD","file":"tilt.jquery.js","sourcesContent":["(function ($) {\r\n $.fn.tilt = function (options) {\r\n\r\n /**\r\n * RequestAnimationFrame\r\n */\r\n const requestTick = function() {\r\n if (this.ticking) return;\r\n requestAnimationFrame(updateTransforms.bind(this));\r\n this.ticking = true;\r\n };\r\n\r\n /**\r\n * Bind mouse movement evens on instance\r\n */\r\n const bindEvents = function() {\r\n $(this).on('mousemove', mouseMove);\r\n $(this).on('mouseenter', mouseEnter);\r\n if (this.settings.reset) $(this).on('mouseleave', mouseLeave);\r\n };\r\n\r\n /**\r\n * Set transition only on mouse leave and mouse enter so it doesn't influence mouse move transforms\r\n */\r\n const setTransition = function() {\r\n if (this.timeout !== undefined) clearTimeout(this.timeout);\r\n $(this).css({'transition': `${this.settings.speed}ms ${this.settings.easing}`});\r\n if(this.settings.glare) this.glareElement.css({'transition': `opacity ${this.settings.speed}ms ${this.settings.easing}`});\r\n this.timeout = setTimeout(() => {\r\n $(this).css({'transition': ''});\r\n if(this.settings.glare) this.glareElement.css({'transition': ''});\r\n }, this.settings.speed);\r\n };\r\n\r\n /**\r\n * When user mouse enters tilt element\r\n */\r\n const mouseEnter = function(event) {\r\n this.ticking = false;\r\n $(this).css({'will-change': 'transform'});\r\n setTransition.call(this);\r\n\r\n // Trigger change event\r\n $(this).trigger(\"tilt.mouseEnter\");\r\n };\r\n\r\n /**\r\n * Return the x,y position of the muose on the tilt element\r\n * @returns {{x: *, y: *}}\r\n */\r\n const getMousePositions = function(event) {\r\n if (typeof(event) === \"undefined\") {\r\n event = {\r\n pageX: $(this).offset().left + $(this).outerWidth() / 2,\r\n pageY: $(this).offset().top + $(this).outerHeight() / 2\r\n };\r\n }\r\n return {x: event.pageX, y: event.pageY};\r\n };\r\n\r\n /**\r\n * When user mouse moves over the tilt element\r\n */\r\n const mouseMove = function(event) {\r\n this.mousePositions = getMousePositions(event);\r\n requestTick.call(this);\r\n };\r\n\r\n /**\r\n * When user mouse leaves tilt element\r\n */\r\n const mouseLeave = function() {\r\n setTransition.call(this);\r\n this.reset = true;\r\n requestTick.call(this);\r\n\r\n // Trigger change event\r\n $(this).trigger(\"tilt.mouseLeave\");\r\n };\r\n\r\n /**\r\n * Get tilt values\r\n *\r\n * @returns {{x: tilt value, y: tilt value}}\r\n */\r\n const getValues = function() {\r\n const width = $(this).width();\r\n const height = $(this).height();\r\n const left = $(this).offset().left;\r\n const top = $(this).offset().top;\r\n const percentageX = (this.mousePositions.x - left) / width;\r\n const percentageY = (this.mousePositions.y - top) / height;\r\n // x or y position inside instance / width of instance = percentage of position inside instance * the max tilt value\r\n const tiltX = ((this.settings.maxTilt / 2) - ((percentageX) * this.settings.maxTilt)).toFixed(2);\r\n const tiltY = (((percentageY) * this.settings.maxTilt) - (this.settings.maxTilt / 2)).toFixed(2);\r\n // angle\r\n const angle = Math.atan2(this.mousePositions.x - (left+width/2),- (this.mousePositions.y - (top+height/2)) )*(180/Math.PI);\r\n // Return x & y tilt values\r\n return {tiltX, tiltY, 'percentageX': percentageX * 100, 'percentageY': percentageY * 100, angle};\r\n };\r\n\r\n /**\r\n * Update tilt transforms on mousemove\r\n */\r\n const updateTransforms = function() {\r\n this.transforms = getValues.call(this);\r\n\r\n if (this.reset) {\r\n this.reset = false;\r\n $(this).css('transform', `perspective(${this.settings.perspective}px) rotateX(0deg) rotateY(0deg)`);\r\n\r\n // Rotate glare if enabled\r\n if (this.settings.glare){\r\n this.glareElement.css('transform', `rotate(180deg) scale(1.75)`);\r\n this.glareElement.css('opacity', `${this.settings.maxGlare/4}`);\r\n }\r\n\r\n return;\r\n } else {\r\n $(this).css('transform', `perspective(${this.settings.perspective}px) rotateX(${this.settings.axis === 'x' ? 0 : this.transforms.tiltY}deg) rotateY(${this.settings.axis === 'y' ? 0 : this.transforms.tiltX}deg) scale3d(${this.settings.scale},${this.settings.scale},${this.settings.scale})`);\r\n\r\n // Rotate glare if enabled\r\n if (this.settings.glare){\r\n this.glareElement.css('transform', `rotate(${this.transforms.angle}deg) scale(1.75)`);\r\n this.glareElement.css('opacity', `${this.transforms.percentageY * this.settings.maxGlare / 100}`);\r\n }\r\n }\r\n\r\n // Trigger change event\r\n $(this).trigger(\"change\", [this.transforms]);\r\n\r\n this.ticking = false;\r\n };\r\n\r\n /**\r\n * Prepare elements\r\n */\r\n const prepareGlare = function () {\r\n const glarePrerender = this.settings.glarePrerender;\r\n\r\n // If option pre-render is enabled we assume all html/css is present for an optimal glare effect.\r\n if (!glarePrerender)\r\n // Create glare element\r\n $(this).append('
');\r\n\r\n // Store glare selector if glare is enabled\r\n this.glareElementWrapper = $(this).find(\".js-tilt-glare\");\r\n this.glareElement = $(this).find(\".js-tilt-glare-inner\");\r\n \r\n // Remember? We assume all css is already set, so just return\r\n if (glarePrerender) return;\r\n\r\n // Abstracted re-usable glare styles\r\n const stretch = {\r\n 'position': 'absolute',\r\n 'top': '0',\r\n 'left': '0',\r\n 'width': '100%',\r\n 'height': '100%',\r\n };\r\n\r\n // Style glare wrapper\r\n this.glareElementWrapper.css(stretch).css({\r\n 'overflow': 'hidden',\r\n });\r\n\r\n // Style glare element\r\n this.glareElement.css(stretch).css({\r\n 'background-image': `linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%)`,\r\n 'opacity': `${this.settings.maxGlare / 2}`,\r\n 'transform': `rotate(180deg) scale(1.75)`\r\n });\r\n\r\n };\r\n\r\n /**\r\n * Public methods\r\n */\r\n $.fn.tilt.destroy = function() {\r\n $(this).each(function () {\r\n $(this).find('.js-tilt-glare').remove();\r\n $(this).css({'will-change': '', 'transform': ''});\r\n $(this).off('mousemove mouseenter mouseleave');\r\n });\r\n };\r\n\r\n $.fn.tilt.getValues = function() {\r\n const results = [];\r\n $(this).each(function () {\r\n this.mousePositions = getMousePositions.call(this);\r\n results.push(getValues.call(this));\r\n });\r\n return results;\r\n };\r\n\r\n $.fn.tilt.reset = function() {\r\n $(this).each(function () {\r\n this.mousePositions = getMousePositions.call(this);\r\n this.settings = $(this).data('settings');\r\n mouseLeave.call(this);\r\n setTimeout(() => {\r\n this.reset = false;\r\n }, this.settings.transition);\r\n });\r\n };\r\n\r\n /**\r\n * Loop every instance\r\n */\r\n return this.each(function () {\r\n\r\n /**\r\n * Default settings merged with user settings\r\n * Can be set trough data attributes or as parameter.\r\n * @type {*}\r\n */\r\n this.settings = $.extend({\r\n maxTilt: $(this).is('[data-tilt-max]') ? $(this).data('tilt-max') : 20,\r\n perspective: $(this).is('[data-tilt-perspective]') ? $(this).data('tilt-perspective') : 300,\r\n easing: $(this).is('[data-tilt-easing]') ? $(this).data('tilt-easing') : 'cubic-bezier(.03,.98,.52,.99)',\r\n scale: $(this).is('[data-tilt-scale]') ? $(this).data('tilt-scale') : '1',\r\n speed: $(this).is('[data-tilt-speed]') ? $(this).data('tilt-speed') : '400',\r\n transition: $(this).is('[data-tilt-transition]') ? $(this).data('tilt-transition') : true,\r\n axis: $(this).is('[data-tilt-axis]') ? $(this).data('tilt-axis') : null,\r\n reset: $(this).is('[data-tilt-reset]') ? $(this).data('tilt-reset') : true,\r\n glare: $(this).is('[data-tilt-glare]') ? $(this).data('tilt-glare') : false,\r\n maxGlare: $(this).is('[data-tilt-maxglare]') ? $(this).data('tilt-maxglare') : 1,\r\n }, options);\r\n\r\n\r\n this.init = () => {\r\n // Store settings\r\n $(this).data('settings', this.settings);\r\n\r\n // Prepare element\r\n if(this.settings.glare) prepareGlare.call(this);\r\n\r\n // Bind events\r\n bindEvents.call(this);\r\n };\r\n\r\n // Init\r\n this.init();\r\n\r\n });\r\n };\r\n\r\n /**\r\n * Auto load\r\n */\r\n $('[data-tilt]').tilt();\r\n\r\n}(jQuery));\r\n"]} \ No newline at end of file diff --git a/package.json b/package.json index daf34f4..d1128a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tilt.js", - "version": "1.1.12", + "version": "1.1.13", "description": "A tiny requestAnimationFrame powered 60+fps lightweight parallax tilt effect for jQuery.", "main": "./src/tilt.jquery.js", "scripts": {