wix-style-react
Version:
wix-style-react
46 lines (37 loc) • 2.02 kB
JavaScript
var _this = this;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
import { proportionDriverFactory as publicDriverFactory } from './Proportion.driver';
export var proportionPrivateDriverFactory = function proportionPrivateDriverFactory(base) {
return _extends({}, publicDriverFactory(base), {
// Add here driver methods that considered "private"
/** Get the component's aspect ratio */
getAspectRatio: function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var width, height;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return base.attr('offsetWidth');
case 2:
width = _context.sent;
_context.next = 5;
return base.attr('offsetHeight');
case 5:
height = _context.sent;
return _context.abrupt('return', width / height);
case 7:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
}));
return function getAspectRatio() {
return _ref.apply(this, arguments);
};
}()
});
};