288 lines
8.9 KiB
JavaScript
288 lines
8.9 KiB
JavaScript
|
import {
|
||
|
isObject,
|
||
|
keyCodes
|
||
|
} from "./chunk-I4KGD5X4.js";
|
||
|
|
||
|
// node_modules/vuetify/lib/directives/ripple/index.mjs
|
||
|
import "C:/Users/Jeremy/Documents/Dev/Projects.cloudsucks.net/Vulture/VApp/node_modules/vuetify/lib/directives/ripple/VRipple.css";
|
||
|
var stopSymbol = Symbol("rippleStop");
|
||
|
var DELAY_RIPPLE = 80;
|
||
|
function transform(el, value) {
|
||
|
el.style.transform = value;
|
||
|
el.style.webkitTransform = value;
|
||
|
}
|
||
|
function isTouchEvent(e) {
|
||
|
return e.constructor.name === "TouchEvent";
|
||
|
}
|
||
|
function isKeyboardEvent(e) {
|
||
|
return e.constructor.name === "KeyboardEvent";
|
||
|
}
|
||
|
var calculate = function(e, el) {
|
||
|
var _a;
|
||
|
let value = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
||
|
let localX = 0;
|
||
|
let localY = 0;
|
||
|
if (!isKeyboardEvent(e)) {
|
||
|
const offset = el.getBoundingClientRect();
|
||
|
const target = isTouchEvent(e) ? e.touches[e.touches.length - 1] : e;
|
||
|
localX = target.clientX - offset.left;
|
||
|
localY = target.clientY - offset.top;
|
||
|
}
|
||
|
let radius = 0;
|
||
|
let scale = 0.3;
|
||
|
if ((_a = el._ripple) == null ? void 0 : _a.circle) {
|
||
|
scale = 0.15;
|
||
|
radius = el.clientWidth / 2;
|
||
|
radius = value.center ? radius : radius + Math.sqrt((localX - radius) ** 2 + (localY - radius) ** 2) / 4;
|
||
|
} else {
|
||
|
radius = Math.sqrt(el.clientWidth ** 2 + el.clientHeight ** 2) / 2;
|
||
|
}
|
||
|
const centerX = `${(el.clientWidth - radius * 2) / 2}px`;
|
||
|
const centerY = `${(el.clientHeight - radius * 2) / 2}px`;
|
||
|
const x = value.center ? centerX : `${localX - radius}px`;
|
||
|
const y = value.center ? centerY : `${localY - radius}px`;
|
||
|
return {
|
||
|
radius,
|
||
|
scale,
|
||
|
x,
|
||
|
y,
|
||
|
centerX,
|
||
|
centerY
|
||
|
};
|
||
|
};
|
||
|
var ripples = {
|
||
|
/* eslint-disable max-statements */
|
||
|
show(e, el) {
|
||
|
var _a;
|
||
|
let value = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
||
|
if (!((_a = el == null ? void 0 : el._ripple) == null ? void 0 : _a.enabled)) {
|
||
|
return;
|
||
|
}
|
||
|
const container = document.createElement("span");
|
||
|
const animation = document.createElement("span");
|
||
|
container.appendChild(animation);
|
||
|
container.className = "v-ripple__container";
|
||
|
if (value.class) {
|
||
|
container.className += ` ${value.class}`;
|
||
|
}
|
||
|
const {
|
||
|
radius,
|
||
|
scale,
|
||
|
x,
|
||
|
y,
|
||
|
centerX,
|
||
|
centerY
|
||
|
} = calculate(e, el, value);
|
||
|
const size = `${radius * 2}px`;
|
||
|
animation.className = "v-ripple__animation";
|
||
|
animation.style.width = size;
|
||
|
animation.style.height = size;
|
||
|
el.appendChild(container);
|
||
|
const computed = window.getComputedStyle(el);
|
||
|
if (computed && computed.position === "static") {
|
||
|
el.style.position = "relative";
|
||
|
el.dataset.previousPosition = "static";
|
||
|
}
|
||
|
animation.classList.add("v-ripple__animation--enter");
|
||
|
animation.classList.add("v-ripple__animation--visible");
|
||
|
transform(animation, `translate(${x}, ${y}) scale3d(${scale},${scale},${scale})`);
|
||
|
animation.dataset.activated = String(performance.now());
|
||
|
setTimeout(() => {
|
||
|
animation.classList.remove("v-ripple__animation--enter");
|
||
|
animation.classList.add("v-ripple__animation--in");
|
||
|
transform(animation, `translate(${centerX}, ${centerY}) scale3d(1,1,1)`);
|
||
|
}, 0);
|
||
|
},
|
||
|
hide(el) {
|
||
|
var _a;
|
||
|
if (!((_a = el == null ? void 0 : el._ripple) == null ? void 0 : _a.enabled)) return;
|
||
|
const ripples2 = el.getElementsByClassName("v-ripple__animation");
|
||
|
if (ripples2.length === 0) return;
|
||
|
const animation = ripples2[ripples2.length - 1];
|
||
|
if (animation.dataset.isHiding) return;
|
||
|
else animation.dataset.isHiding = "true";
|
||
|
const diff = performance.now() - Number(animation.dataset.activated);
|
||
|
const delay = Math.max(250 - diff, 0);
|
||
|
setTimeout(() => {
|
||
|
animation.classList.remove("v-ripple__animation--in");
|
||
|
animation.classList.add("v-ripple__animation--out");
|
||
|
setTimeout(() => {
|
||
|
var _a2;
|
||
|
const ripples3 = el.getElementsByClassName("v-ripple__animation");
|
||
|
if (ripples3.length === 1 && el.dataset.previousPosition) {
|
||
|
el.style.position = el.dataset.previousPosition;
|
||
|
delete el.dataset.previousPosition;
|
||
|
}
|
||
|
if (((_a2 = animation.parentNode) == null ? void 0 : _a2.parentNode) === el) el.removeChild(animation.parentNode);
|
||
|
}, 300);
|
||
|
}, delay);
|
||
|
}
|
||
|
};
|
||
|
function isRippleEnabled(value) {
|
||
|
return typeof value === "undefined" || !!value;
|
||
|
}
|
||
|
function rippleShow(e) {
|
||
|
const value = {};
|
||
|
const element = e.currentTarget;
|
||
|
if (!(element == null ? void 0 : element._ripple) || element._ripple.touched || e[stopSymbol]) return;
|
||
|
e[stopSymbol] = true;
|
||
|
if (isTouchEvent(e)) {
|
||
|
element._ripple.touched = true;
|
||
|
element._ripple.isTouch = true;
|
||
|
} else {
|
||
|
if (element._ripple.isTouch) return;
|
||
|
}
|
||
|
value.center = element._ripple.centered || isKeyboardEvent(e);
|
||
|
if (element._ripple.class) {
|
||
|
value.class = element._ripple.class;
|
||
|
}
|
||
|
if (isTouchEvent(e)) {
|
||
|
if (element._ripple.showTimerCommit) return;
|
||
|
element._ripple.showTimerCommit = () => {
|
||
|
ripples.show(e, element, value);
|
||
|
};
|
||
|
element._ripple.showTimer = window.setTimeout(() => {
|
||
|
var _a;
|
||
|
if ((_a = element == null ? void 0 : element._ripple) == null ? void 0 : _a.showTimerCommit) {
|
||
|
element._ripple.showTimerCommit();
|
||
|
element._ripple.showTimerCommit = null;
|
||
|
}
|
||
|
}, DELAY_RIPPLE);
|
||
|
} else {
|
||
|
ripples.show(e, element, value);
|
||
|
}
|
||
|
}
|
||
|
function rippleStop(e) {
|
||
|
e[stopSymbol] = true;
|
||
|
}
|
||
|
function rippleHide(e) {
|
||
|
const element = e.currentTarget;
|
||
|
if (!(element == null ? void 0 : element._ripple)) return;
|
||
|
window.clearTimeout(element._ripple.showTimer);
|
||
|
if (e.type === "touchend" && element._ripple.showTimerCommit) {
|
||
|
element._ripple.showTimerCommit();
|
||
|
element._ripple.showTimerCommit = null;
|
||
|
element._ripple.showTimer = window.setTimeout(() => {
|
||
|
rippleHide(e);
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
window.setTimeout(() => {
|
||
|
if (element._ripple) {
|
||
|
element._ripple.touched = false;
|
||
|
}
|
||
|
});
|
||
|
ripples.hide(element);
|
||
|
}
|
||
|
function rippleCancelShow(e) {
|
||
|
const element = e.currentTarget;
|
||
|
if (!(element == null ? void 0 : element._ripple)) return;
|
||
|
if (element._ripple.showTimerCommit) {
|
||
|
element._ripple.showTimerCommit = null;
|
||
|
}
|
||
|
window.clearTimeout(element._ripple.showTimer);
|
||
|
}
|
||
|
var keyboardRipple = false;
|
||
|
function keyboardRippleShow(e) {
|
||
|
if (!keyboardRipple && (e.keyCode === keyCodes.enter || e.keyCode === keyCodes.space)) {
|
||
|
keyboardRipple = true;
|
||
|
rippleShow(e);
|
||
|
}
|
||
|
}
|
||
|
function keyboardRippleHide(e) {
|
||
|
keyboardRipple = false;
|
||
|
rippleHide(e);
|
||
|
}
|
||
|
function focusRippleHide(e) {
|
||
|
if (keyboardRipple) {
|
||
|
keyboardRipple = false;
|
||
|
rippleHide(e);
|
||
|
}
|
||
|
}
|
||
|
function updateRipple(el, binding, wasEnabled) {
|
||
|
const {
|
||
|
value,
|
||
|
modifiers
|
||
|
} = binding;
|
||
|
const enabled = isRippleEnabled(value);
|
||
|
if (!enabled) {
|
||
|
ripples.hide(el);
|
||
|
}
|
||
|
el._ripple = el._ripple ?? {};
|
||
|
el._ripple.enabled = enabled;
|
||
|
el._ripple.centered = modifiers.center;
|
||
|
el._ripple.circle = modifiers.circle;
|
||
|
if (isObject(value) && value.class) {
|
||
|
el._ripple.class = value.class;
|
||
|
}
|
||
|
if (enabled && !wasEnabled) {
|
||
|
if (modifiers.stop) {
|
||
|
el.addEventListener("touchstart", rippleStop, {
|
||
|
passive: true
|
||
|
});
|
||
|
el.addEventListener("mousedown", rippleStop);
|
||
|
return;
|
||
|
}
|
||
|
el.addEventListener("touchstart", rippleShow, {
|
||
|
passive: true
|
||
|
});
|
||
|
el.addEventListener("touchend", rippleHide, {
|
||
|
passive: true
|
||
|
});
|
||
|
el.addEventListener("touchmove", rippleCancelShow, {
|
||
|
passive: true
|
||
|
});
|
||
|
el.addEventListener("touchcancel", rippleHide);
|
||
|
el.addEventListener("mousedown", rippleShow);
|
||
|
el.addEventListener("mouseup", rippleHide);
|
||
|
el.addEventListener("mouseleave", rippleHide);
|
||
|
el.addEventListener("keydown", keyboardRippleShow);
|
||
|
el.addEventListener("keyup", keyboardRippleHide);
|
||
|
el.addEventListener("blur", focusRippleHide);
|
||
|
el.addEventListener("dragstart", rippleHide, {
|
||
|
passive: true
|
||
|
});
|
||
|
} else if (!enabled && wasEnabled) {
|
||
|
removeListeners(el);
|
||
|
}
|
||
|
}
|
||
|
function removeListeners(el) {
|
||
|
el.removeEventListener("mousedown", rippleShow);
|
||
|
el.removeEventListener("touchstart", rippleShow);
|
||
|
el.removeEventListener("touchend", rippleHide);
|
||
|
el.removeEventListener("touchmove", rippleCancelShow);
|
||
|
el.removeEventListener("touchcancel", rippleHide);
|
||
|
el.removeEventListener("mouseup", rippleHide);
|
||
|
el.removeEventListener("mouseleave", rippleHide);
|
||
|
el.removeEventListener("keydown", keyboardRippleShow);
|
||
|
el.removeEventListener("keyup", keyboardRippleHide);
|
||
|
el.removeEventListener("dragstart", rippleHide);
|
||
|
el.removeEventListener("blur", focusRippleHide);
|
||
|
}
|
||
|
function mounted(el, binding) {
|
||
|
updateRipple(el, binding, false);
|
||
|
}
|
||
|
function unmounted(el) {
|
||
|
delete el._ripple;
|
||
|
removeListeners(el);
|
||
|
}
|
||
|
function updated(el, binding) {
|
||
|
if (binding.value === binding.oldValue) {
|
||
|
return;
|
||
|
}
|
||
|
const wasEnabled = isRippleEnabled(binding.oldValue);
|
||
|
updateRipple(el, binding, wasEnabled);
|
||
|
}
|
||
|
var Ripple = {
|
||
|
mounted,
|
||
|
unmounted,
|
||
|
updated
|
||
|
};
|
||
|
var ripple_default = Ripple;
|
||
|
|
||
|
export {
|
||
|
Ripple,
|
||
|
ripple_default
|
||
|
};
|
||
|
//# sourceMappingURL=chunk-NMCVREUK.js.map
|