Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initCropBosPosition (newOpts) {
// 更新this.options
if (newOpts) {
this.options = Object.assign({}, this.options, newOpts)
}
let opts = this.options
let winWidth = window.innerWidth
let winHeight = window.innerHeight
// 宽度取设置宽度和屏幕宽度的最小值
let width = Math.min(opts.width, winWidth * 0.8)
let height = opts.height / opts.width * width
// 边界判断,如果高度超高(确定按钮不能显示),则重新计算裁剪框尺寸
if (height > winHeight * 0.8) {
height = winHeight * 0.8
width = opts.width / opts.height * height
}
let top = (winHeight - height) / 2
let left = (winWidth - width) / 2
let borderWidth = Math.max(top, left)
// 裁剪比例
this.cropRatio = opts.width / width
// 尺寸信息
this.cropBoxPos = {
winWidth,
return false;
}
if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
return undefined;
}
if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) {
return undefined;
}
if (swiper.params.keyboard.onlyInViewport && (kc === 37 || kc === 39 || kc === 38 || kc === 40)) {
let inView = false;
// Check that swiper should be inside of visible area of window
if (swiper.$el.parents(`.${swiper.params.slideClass}`).length > 0 && swiper.$el.parents(`.${swiper.params.slideActiveClass}`).length === 0) {
return undefined;
}
const windowWidth = window.innerWidth;
const windowHeight = window.innerHeight;
const swiperOffset = swiper.$el.offset();
if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft;
const swiperCoord = [
[swiperOffset.left, swiperOffset.top],
[swiperOffset.left + swiper.width, swiperOffset.top],
[swiperOffset.left, swiperOffset.top + swiper.height],
[swiperOffset.left + swiper.width, swiperOffset.top + swiper.height],
];
for (let i = 0; i < swiperCoord.length; i += 1) {
const point = swiperCoord[i];
if (
point[0] >= 0 && point[0] <= windowWidth &&
point[1] >= 0 && point[1] <= windowHeight
) {
inView = true;
}
return false;
}
if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
return undefined;
}
if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) {
return undefined;
}
if (swiper.params.keyboard.onlyInViewport && (kc === 33 || kc === 34 || kc === 37 || kc === 39 || kc === 38 || kc === 40)) {
let inView = false;
// Check that swiper should be inside of visible area of window
if (swiper.$el.parents(`.${swiper.params.slideClass}`).length > 0 && swiper.$el.parents(`.${swiper.params.slideActiveClass}`).length === 0) {
return undefined;
}
const windowWidth = window.innerWidth;
const windowHeight = window.innerHeight;
const swiperOffset = swiper.$el.offset();
if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft;
const swiperCoord = [
[swiperOffset.left, swiperOffset.top],
[swiperOffset.left + swiper.width, swiperOffset.top],
[swiperOffset.left, swiperOffset.top + swiper.height],
[swiperOffset.left + swiper.width, swiperOffset.top + swiper.height],
];
for (let i = 0; i < swiperCoord.length; i += 1) {
const point = swiperCoord[i];
if (
point[0] >= 0 && point[0] <= windowWidth
&& point[1] >= 0 && point[1] <= windowHeight
) {
inView = true;
}
function height() {
if (this[0] === window) {
return window.innerHeight;
}
if (this.length > 0) {
return parseFloat(this.css('height'));
}
return null;
}
function outerHeight(includeMargins) {
function height() {
if (this[0] === window) {
return window.innerHeight;
}
if (this.length > 0) {
return parseFloat(this.css('height'));
}
return null;
}
function outerHeight(includeMargins) {
const points = Object.keys(breakpoints).map((point) => {
if (typeof point === 'string' && point.startsWith('@')) {
const minRatio = parseFloat(point.substr(1));
const value = window.innerHeight * minRatio;
return { value, point };
}
return { value: point, point };
});
height() {
if (this[0] === window) return window.innerHeight
return this.length > 0 ? parseFloat(this.css('height')) : null
},