(window["webpackJsonp_name_"] = window["webpackJsonp_name_"] || []).push([[45],{ /***/ 172: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _global = __webpack_require__(52); var _global2 = _interopRequireDefault(_global); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var MouseMoveParallax = function () { function MouseMoveParallax(props) { _classCallCheck(this, MouseMoveParallax); this.isActive = false; this.mouseIsMoved = false; this._params = Object.assign({}, MouseMoveParallax.default, props); this._init(); } _createClass(MouseMoveParallax, [{ key: '_init', value: function _init() { var _this = this; if (!this.el) { return false; } if (this.el.classList.contains('vc_column_container')) { this.wrapper = this.el.querySelector('.vc_column-inner'); } else if (this.el.classList.contains('vc_row')) { this.wrapper = document.createElement('div'); this.el.parentNode.insertBefore(this.wrapper, this.el); this.wrapper.appendChild(this.el); } else { this.wrapper = document.createElement('div'); this.wrapper.innerHTML = this.el.innerHTML; this.el.innerHTML = ''; this.el.appendChild(this.wrapper); } if (!this.wrapper) { return false; } this.wrapper.classList.add('wpw-parallax-mouse-move-content'); this.step = 30; if (document.body.classList.contains('wpw-custom-scroll')) { MouseMoveParallax._mainScrollBox = _global2.default.scrollBox; } else { MouseMoveParallax._mainScrollBox = document; } var pos = this.pos = this.el.getBoundingClientRect(); if (pos.top >= 0 && pos.top < _global2.default.wh || pos.bottom < _global2.default.wh && pos.bottom >= 0 || pos.top <= 0 && pos.bottom > _global2.default.wh) { // here code document.addEventListener('mousemove', this.addEventListener.bind(this)); this.isActive = true; } else { this.isActive = false; } this.mouseIsMoved = false; var rAF = false; MouseMoveParallax._mainScrollBox.addEventListener('scroll', function (event) { if (_global2.default.ww < 768) { return; } if (rAF) { return; } rAF = true; requestAnimationFrame(function () { var pos = _this.pos = _this.el.getBoundingClientRect(); if (pos.top >= 0 && pos.top < _global2.default.wh || pos.bottom < _global2.default.wh && pos.bottom >= 0 || pos.top <= 0 && pos.bottom > _global2.default.wh) { // here code if (!_this.isActive) { _this.state = false; document.addEventListener('mousemove', _this.addEventListener.bind(_this)); } _this.isActive = true; if (!_this.mouseIsMoved) { _this._changePosition(_this.lastX, _this.lastY); } } else { if (_this.isActive) { document.removeEventListener('mousemove', _this.addEventListener.bind(_this)); } _this.isActive = false; } rAF = false; }); }); } }, { key: 'addEventListener', value: function addEventListener(event) { this._changePosition(event.clientX, event.clientY); } }, { key: '_changePosition', value: function _changePosition() { var _this2 = this; var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.innerWidth / 2; var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerHeight / 2; if (this.state) { return; } this.state = true; if (this.isActive) { this.mouseIsMoved = true; var clientY = this.lastY = y; var clientX = this.lastX = x; var step = this.step; setTimeout(function () { requestAnimationFrame(function () { _this2.wrapper.style.transform = 'rotateX(' + (_this2.pos.top + _this2.pos.height / 2 - clientY) / step + 'deg) rotateY(' + -(_this2.pos.left + _this2.pos.width / 2 - clientX) / step + 'deg)'; _this2.wrapper.style.webkitTransform = 'rotateX(' + (_this2.pos.top + _this2.pos.height / 2 - clientY) / step + 'deg) rotateY(' + -(_this2.pos.left + _this2.pos.width / 2 - clientX) / step + 'deg)'; _this2.state = false; _this2.mouseIsMoved = false; }); }, 50); } } }, { key: 'el', get: function get() { return this._params.el; } }], [{ key: 'default', get: function get() { return { el: null }; } }]); return MouseMoveParallax; }(); exports.default = MouseMoveParallax; /***/ }) }]);