@pacem/pacem-fx 1.0.0-abel
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/NOTICE +4 -0
- package/dist/browser/pacem-fx.js +865 -0
- package/dist/browser/pacem-fx.js.map +1 -0
- package/dist/browser/pacem-fx.min.js +2 -0
- package/dist/browser/pacem-fx.min.js.map +1 -0
- package/dist/bundle/pacem-fx.min.mjs +17 -0
- package/dist/bundle/pacem-fx.mjs +850 -0
- package/dist/bundle/pacem-fx.mjs.map +7 -0
- package/dist/esm/fancy.js +131 -0
- package/dist/esm/gradient.js +259 -0
- package/dist/esm/hero.js +158 -0
- package/dist/esm/index-components-fx.js +7 -0
- package/dist/esm/index-components.js +1 -0
- package/dist/esm/index-iife.js +3 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/list.js +69 -0
- package/dist/esm/pulse.js +115 -0
- package/dist/esm/ripple.js +105 -0
- package/dist/esm/types.js +12 -0
- package/package.json +38 -0
- package/typings/index.d.ts +177 -0
package/dist/esm/hero.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { CustomElement, Watch, PropertyConverters, P, PCSS, Utils } from '@pacem/pacem-core';
|
|
8
|
+
import { PacemFxElement } from './types';
|
|
9
|
+
//namespace Pacem.Components.Fx {
|
|
10
|
+
const HERO_CSS = PCSS + "-hero";
|
|
11
|
+
const TRANSITION = 200;
|
|
12
|
+
const HEROING_IN = "entering";
|
|
13
|
+
const HEROING_OUT = "exiting";
|
|
14
|
+
const HERO_IN = "entered";
|
|
15
|
+
const HERO_OUT = "exited";
|
|
16
|
+
const rectOrElementConverter = {
|
|
17
|
+
convert: attr => {
|
|
18
|
+
if (attr.trim().startsWith('#'))
|
|
19
|
+
return PropertyConverters.Element.convert(attr);
|
|
20
|
+
return PropertyConverters.Json.convert(attr);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
let PacemFxHeroElement = class PacemFxHeroElement extends PacemFxElement {
|
|
24
|
+
propertyChangedCallback(name, old, val, first) {
|
|
25
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
26
|
+
// target switch?
|
|
27
|
+
if (name === 'target' && !Utils.isNull(old)) {
|
|
28
|
+
this._resetTarget(old);
|
|
29
|
+
}
|
|
30
|
+
// recompute back path (originalState)?
|
|
31
|
+
if (name === 'from' && this.hero && !Utils.isNull(val)) {
|
|
32
|
+
this._originalState = this._computeFromState();
|
|
33
|
+
}
|
|
34
|
+
// trigger
|
|
35
|
+
if (name === 'hero' || name === 'target' || name === 'goal') {
|
|
36
|
+
if (!Utils.isNull(this.target)) {
|
|
37
|
+
if (this.hero) {
|
|
38
|
+
this.start();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.reset();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
viewActivatedCallback() {
|
|
47
|
+
super.viewActivatedCallback();
|
|
48
|
+
if (this.hero && !Utils.isNull(this.target))
|
|
49
|
+
this.start();
|
|
50
|
+
}
|
|
51
|
+
disconnectedCallback() {
|
|
52
|
+
if (!Utils.isNull(this.target))
|
|
53
|
+
this.reset();
|
|
54
|
+
super.disconnectedCallback();
|
|
55
|
+
}
|
|
56
|
+
_computeFromState() {
|
|
57
|
+
const tget = this.target, offset = Utils.offset(tget);
|
|
58
|
+
if (this.from instanceof Element) {
|
|
59
|
+
let from = Utils.offset(this.from);
|
|
60
|
+
return { x: from.left, y: from.top, width: from.width, height: from.height };
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return { x: offset.left, y: offset.top, width: offset.width, height: offset.height };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
_resetTarget(tget = this.target) {
|
|
67
|
+
// reset inline style options
|
|
68
|
+
const style = tget.style;
|
|
69
|
+
// reset position/size
|
|
70
|
+
style.top = style.left = style.height = style.width = '';
|
|
71
|
+
for (let j = 0; j < style.length; j++) {
|
|
72
|
+
let prop = style.item(j);
|
|
73
|
+
style[prop] = '';
|
|
74
|
+
}
|
|
75
|
+
for (let prop in this._originalStyle) {
|
|
76
|
+
style[prop] = this._originalStyle[prop];
|
|
77
|
+
}
|
|
78
|
+
Utils.removeClass(tget, HERO_CSS);
|
|
79
|
+
}
|
|
80
|
+
reset() {
|
|
81
|
+
//
|
|
82
|
+
if (Utils.isNull(this._originalState) || Utils.isNull(this._targetState)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.dispatchEvent(new Event(HEROING_OUT));
|
|
86
|
+
return this._animate(this._targetState, this._originalState).then(() => {
|
|
87
|
+
this._resetTarget();
|
|
88
|
+
this.dispatchEvent(new Event(HERO_OUT));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
start() {
|
|
92
|
+
if (!this.disabled && !Utils.isNull(this.target)) {
|
|
93
|
+
let goal;
|
|
94
|
+
if (this.to instanceof Element) {
|
|
95
|
+
let to = Utils.offset(this.to);
|
|
96
|
+
goal = { x: to.left, y: to.top, width: to.width, height: to.height };
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
goal = this.to;
|
|
100
|
+
}
|
|
101
|
+
const tget = this.target, wSize = Utils.windowSize, state = goal || { x: 0, y: 0, width: wSize.width, height: wSize.height }, style = tget.style;
|
|
102
|
+
this._targetState = state;
|
|
103
|
+
let start = this._originalState = this._computeFromState();
|
|
104
|
+
// save inline style options
|
|
105
|
+
this._originalStyle = {};
|
|
106
|
+
for (let j = 0; j < style.length; j++) {
|
|
107
|
+
let prop = style.item(j);
|
|
108
|
+
this._originalStyle[prop] = style[prop];
|
|
109
|
+
}
|
|
110
|
+
//
|
|
111
|
+
Utils.addClass(tget, HERO_CSS);
|
|
112
|
+
this.dispatchEvent(new Event(HEROING_IN));
|
|
113
|
+
return this._animate(start, state).then(() => {
|
|
114
|
+
this.dispatchEvent(new Event(HERO_IN));
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
// nothing to do
|
|
118
|
+
return Promise.resolve();
|
|
119
|
+
}
|
|
120
|
+
_animate(from, to) {
|
|
121
|
+
const tget = this.target, style = tget.style;
|
|
122
|
+
// transformations to make target state look like original state
|
|
123
|
+
// i.e. `target state` gets constrained to fit `original state`.
|
|
124
|
+
const scaleX = from.width / to.width, scaleY = from.height / to.height, translateX = (from.x - to.x) + 'px', translateY = (from.y - to.y) + 'px';
|
|
125
|
+
style.transformOrigin = '0 0';
|
|
126
|
+
style.transition = 'none';
|
|
127
|
+
// set final state
|
|
128
|
+
style.transform = `translate(${translateX}, ${translateY}) scale(${scaleX}, ${scaleY})`;
|
|
129
|
+
style.width = to.width + 'px';
|
|
130
|
+
style.height = to.height + 'px';
|
|
131
|
+
style.top = to.y + 'px';
|
|
132
|
+
style.left = to.x + 'px';
|
|
133
|
+
// hero-animate
|
|
134
|
+
requestAnimationFrame(() => {
|
|
135
|
+
let duration = this.duration || TRANSITION;
|
|
136
|
+
style.transition = `transform cubic-bezier(0.445, 0.05, 0.55, 0.95) ${duration}ms, opacity ${duration}ms`;
|
|
137
|
+
style.transform = `translate(0, 0) scale(1)`;
|
|
138
|
+
});
|
|
139
|
+
return Utils.waitForAnimationEnd(tget, TRANSITION + 10);
|
|
140
|
+
// Utils.addAnimationEndCallback(tget, callback, TRANSITION + 10);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
__decorate([
|
|
144
|
+
Watch({ converter: PropertyConverters.Boolean })
|
|
145
|
+
], PacemFxHeroElement.prototype, "hero", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
Watch({ converter: rectOrElementConverter, emit: false })
|
|
148
|
+
], PacemFxHeroElement.prototype, "to", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
Watch({ converter: rectOrElementConverter, emit: false })
|
|
151
|
+
], PacemFxHeroElement.prototype, "from", void 0);
|
|
152
|
+
__decorate([
|
|
153
|
+
Watch({ converter: PropertyConverters.Number, emit: false })
|
|
154
|
+
], PacemFxHeroElement.prototype, "duration", void 0);
|
|
155
|
+
PacemFxHeroElement = __decorate([
|
|
156
|
+
CustomElement({ tagName: P + '-fx-hero' })
|
|
157
|
+
], PacemFxHeroElement);
|
|
158
|
+
export { PacemFxHeroElement };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Fx from './index-components-fx';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Components from './index-components';
|
package/dist/esm/list.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { CustomElement, P, PCSS, Utils } from '@pacem/pacem-core';
|
|
8
|
+
import { PacemFxElement } from './types';
|
|
9
|
+
//namespace Pacem.Components.Fx {
|
|
10
|
+
const CSS_CLASS = PCSS + '-fx-list';
|
|
11
|
+
let PacemFxListElement = class PacemFxListElement extends PacemFxElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this._observed = (items) => {
|
|
15
|
+
const children = Array.from(this.target.children);
|
|
16
|
+
for (let item of items) {
|
|
17
|
+
item.removedNodes.forEach(n => {
|
|
18
|
+
if (n instanceof Element) {
|
|
19
|
+
this.dispatchEvent(new CustomEvent('itemremoved', { detail: n }));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
item.addedNodes.forEach((n, j) => {
|
|
23
|
+
if (n instanceof Element) {
|
|
24
|
+
this.dispatchEvent(new CustomEvent('itemadded', { detail: { item: n, index: children.indexOf(n) } }));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
viewActivatedCallback() {
|
|
31
|
+
super.viewActivatedCallback();
|
|
32
|
+
if (!Utils.isNull(this.target)) {
|
|
33
|
+
this._setup();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
disconnectedCallback() {
|
|
37
|
+
if (!Utils.isNull(this._observer)) {
|
|
38
|
+
this._observer.disconnect();
|
|
39
|
+
}
|
|
40
|
+
super.disconnectedCallback();
|
|
41
|
+
}
|
|
42
|
+
propertyChangedCallback(name, old, val, first) {
|
|
43
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
44
|
+
if (name === 'target') {
|
|
45
|
+
if (old) {
|
|
46
|
+
this._reset(old);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this._setup();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
_reset(el) {
|
|
54
|
+
Utils.removeClass(el, CSS_CLASS);
|
|
55
|
+
this._observer.disconnect();
|
|
56
|
+
}
|
|
57
|
+
_setup() {
|
|
58
|
+
const target = this.target;
|
|
59
|
+
Utils.addClass(target, CSS_CLASS);
|
|
60
|
+
const obs = this._observer = new MutationObserver(this._observed);
|
|
61
|
+
obs.observe(target, { childList: true });
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
PacemFxListElement = __decorate([
|
|
65
|
+
CustomElement({
|
|
66
|
+
tagName: P + '-fx-list'
|
|
67
|
+
})
|
|
68
|
+
], PacemFxListElement);
|
|
69
|
+
export { PacemFxListElement };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { CustomElement, Defaults, P, PCSS, ViewChild, Utils, Components } from '@pacem/pacem-core';
|
|
8
|
+
import { PacemFxElement } from './types';
|
|
9
|
+
//namespace Pacem.Components.Fx {
|
|
10
|
+
const PULSE_CSS = "pulse";
|
|
11
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
12
|
+
function buildAnimationName(id) {
|
|
13
|
+
return `${PCSS}-fx-pulse-${id}`;
|
|
14
|
+
}
|
|
15
|
+
function ensureCssAnimation(id, args, rx = '0', ry = rx) {
|
|
16
|
+
const selector = 'style#' + id;
|
|
17
|
+
const existing = document.querySelector(selector);
|
|
18
|
+
if (Utils.isNull(existing)) {
|
|
19
|
+
const newStyle = document.createElement('style');
|
|
20
|
+
newStyle.id = id;
|
|
21
|
+
document.head.appendChild(newStyle);
|
|
22
|
+
}
|
|
23
|
+
const css = document.querySelector(selector);
|
|
24
|
+
const w = args.width, h = args.height, dim = Math.max(w, h), x = .5 * (dim - w), y = .5 * (dim - h);
|
|
25
|
+
css.sheet.insertRule(`@keyframes ${buildAnimationName(id)} {
|
|
26
|
+
0%{
|
|
27
|
+
opacity: .25; stroke-thickness: 0; rx: ${rx}; ry: ${ry}; x: ${x}px; y: ${y}px; width: ${args.width}px; height: ${args.height}px;
|
|
28
|
+
}
|
|
29
|
+
50%{
|
|
30
|
+
width: ${args.width}px; height: ${args.height}px; transform: scale(1); stroke-width: 10px; rx: ${rx}; ry: ${ry}; opacity: .333; x: ${x}px; y: ${y}px; width: ${w}px; height: ${h}px;
|
|
31
|
+
}
|
|
32
|
+
80%{
|
|
33
|
+
stroke-width: 10px;
|
|
34
|
+
}
|
|
35
|
+
100%{
|
|
36
|
+
opacity: 0; rx: 50%; ry: 50%; transform: scale(2); stroke-width: 0; width: ${dim}px; height: ${dim}px; x: 0; y: 0
|
|
37
|
+
}
|
|
38
|
+
}`, 0);
|
|
39
|
+
for (let j = css.sheet.rules.length - 1; j > 0; j--) {
|
|
40
|
+
css.sheet.deleteRule(j);
|
|
41
|
+
}
|
|
42
|
+
return css;
|
|
43
|
+
}
|
|
44
|
+
let PacemFxPulseElement = class PacemFxPulseElement extends PacemFxElement {
|
|
45
|
+
constructor() {
|
|
46
|
+
super();
|
|
47
|
+
this._resizeHandler = (e) => {
|
|
48
|
+
this._pulse(e.detail);
|
|
49
|
+
};
|
|
50
|
+
this.#key = Utils.uniqueCode();
|
|
51
|
+
}
|
|
52
|
+
#key;
|
|
53
|
+
viewActivatedCallback() {
|
|
54
|
+
super.viewActivatedCallback();
|
|
55
|
+
this._pulse();
|
|
56
|
+
}
|
|
57
|
+
disconnectedCallback() {
|
|
58
|
+
if (!Utils.isNull(this._sheet)) {
|
|
59
|
+
this._sheet.remove();
|
|
60
|
+
this._sheet = null;
|
|
61
|
+
}
|
|
62
|
+
super.disconnectedCallback();
|
|
63
|
+
}
|
|
64
|
+
propertyChangedCallback(name, old, val, first) {
|
|
65
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
66
|
+
if (name === 'disabled' && !first) {
|
|
67
|
+
this._pulse();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
_pulse(size = this._resize.currentSize) {
|
|
71
|
+
const inert = Utils.isNull(this.target) || Utils.isNull(size) || !(size.height > 0) || !(size.width > 0);
|
|
72
|
+
this._resize.disabled = this.disabled;
|
|
73
|
+
if (this.disabled || inert) {
|
|
74
|
+
Utils.addClass(this, 'pulse-off');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
Utils.removeClass(this, 'pulse-off');
|
|
78
|
+
const rect = size;
|
|
79
|
+
const style = getComputedStyle(this.target);
|
|
80
|
+
const css = this.style;
|
|
81
|
+
const dim = Math.max(rect.width, rect.height);
|
|
82
|
+
css.width = dim + 'px';
|
|
83
|
+
css.height = dim + 'px';
|
|
84
|
+
css.top = (rect.top + .5 * (rect.height - dim)) + 'px';
|
|
85
|
+
css.left = (rect.left + .5 * (rect.width - dim)) + 'px';
|
|
86
|
+
const rect1 = this._rect1, rect2 = this._rect2;
|
|
87
|
+
const css1 = rect1.style, css2 = rect2.style;
|
|
88
|
+
this._sheet = ensureCssAnimation(this.#key, size, style.borderTopLeftRadius);
|
|
89
|
+
const animationName = buildAnimationName(this.#key);
|
|
90
|
+
css1.animation = css2.animation = `${animationName} both cubic-bezier(0.37, 0, 0.63, 1) 1.25s infinite`;
|
|
91
|
+
css2.animationDelay = '.175s';
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
__decorate([
|
|
95
|
+
ViewChild(P + '-resize')
|
|
96
|
+
], PacemFxPulseElement.prototype, "_resize", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
ViewChild('svg')
|
|
99
|
+
], PacemFxPulseElement.prototype, "_svg", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
ViewChild('svg > rect[rect1]')
|
|
102
|
+
], PacemFxPulseElement.prototype, "_rect1", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
ViewChild('svg > rect[rect2]')
|
|
105
|
+
], PacemFxPulseElement.prototype, "_rect2", void 0);
|
|
106
|
+
PacemFxPulseElement = __decorate([
|
|
107
|
+
CustomElement({
|
|
108
|
+
tagName: P + '-fx-pulse', shadow: Defaults.USE_SHADOW_ROOT,
|
|
109
|
+
template: `<${P}-resize target="{{ :host.target }}" watch-position="true" on-${Components.ResizeEventName}=":host._resizeHandler($event)"></${P}-resize>
|
|
110
|
+
<svg class="${PULSE_CSS}" xmlns="${SVG_NS}">
|
|
111
|
+
<rect rect1 /><rect rect2 />
|
|
112
|
+
</svg>`
|
|
113
|
+
})
|
|
114
|
+
], PacemFxPulseElement);
|
|
115
|
+
export { PacemFxPulseElement };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { CustomElement, Defaults, P, ViewChild, Utils, PacemEventTarget } from '@pacem/pacem-core';
|
|
8
|
+
import { Point } from '@pacem/pacem-foundation';
|
|
9
|
+
import { PacemFxElement } from './types';
|
|
10
|
+
//namespace Pacem.Components.Fx {
|
|
11
|
+
const RIPPLE_CSS = "ripple";
|
|
12
|
+
let PacemFxRippleElement = class PacemFxRippleElement extends PacemFxElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this._lock = false;
|
|
16
|
+
this._remove = false;
|
|
17
|
+
this._rippleHandler = (e) => {
|
|
18
|
+
if (this.disabled || (this.target instanceof PacemEventTarget && this.target.disabled)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (e instanceof MouseEvent && e.button !== 0) {
|
|
22
|
+
// only the 'main' (left) button click goes.
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const rect = Utils.offset(this.target);
|
|
26
|
+
const style = getComputedStyle(this.target);
|
|
27
|
+
const css = this.style;
|
|
28
|
+
css.top = rect.top + 'px';
|
|
29
|
+
css.left = rect.left + 'px';
|
|
30
|
+
css.width = rect.width + 'px';
|
|
31
|
+
css.height = rect.height + 'px';
|
|
32
|
+
css.borderRadius = style.borderRadius;
|
|
33
|
+
const pointSrc = e.type === 'touchstart' ? e.touches[0] : e;
|
|
34
|
+
const point = { x: pointSrc.pageX, y: pointSrc.pageY };
|
|
35
|
+
const topLeft = { x: rect.left, y: rect.top }, topRight = { x: rect.left + rect.width, y: rect.top }, bottomLeft = { x: rect.left, y: rect.top + rect.height }, bottomRight = { x: topRight.x, y: bottomLeft.y };
|
|
36
|
+
const radius = Math.max(Point.distance(point, topLeft), Point.distance(point, topRight), Point.distance(point, bottomRight), Point.distance(point, bottomLeft));
|
|
37
|
+
const wave = this._wave;
|
|
38
|
+
wave.style.left = (point.x - rect.left - radius) + 'px';
|
|
39
|
+
wave.style.top = (point.y - rect.top - radius) + 'px';
|
|
40
|
+
wave.style.width = wave.style.height = (2 * radius) + 'px';
|
|
41
|
+
Utils.addAnimationEndCallback(wave, () => {
|
|
42
|
+
this._lock = false;
|
|
43
|
+
this._tryRemove();
|
|
44
|
+
});
|
|
45
|
+
this._lock = true;
|
|
46
|
+
Utils.addClass(wave, 'ripple-go');
|
|
47
|
+
};
|
|
48
|
+
this._unrippleHandler = (e) => {
|
|
49
|
+
this._remove = true;
|
|
50
|
+
this._tryRemove();
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
propertyChangedCallback(name, old, val, first) {
|
|
54
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
55
|
+
// target switch?
|
|
56
|
+
if (name === 'target') {
|
|
57
|
+
if (!Utils.isNull(old)) {
|
|
58
|
+
this._reset(old);
|
|
59
|
+
}
|
|
60
|
+
if (!Utils.isNull(val)) {
|
|
61
|
+
this._set(val);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
viewActivatedCallback() {
|
|
66
|
+
super.viewActivatedCallback();
|
|
67
|
+
if (!Utils.isNull(this.target))
|
|
68
|
+
this._set();
|
|
69
|
+
}
|
|
70
|
+
disconnectedCallback() {
|
|
71
|
+
if (!Utils.isNull(this.target))
|
|
72
|
+
this._reset();
|
|
73
|
+
super.disconnectedCallback();
|
|
74
|
+
}
|
|
75
|
+
_tryRemove() {
|
|
76
|
+
if (!this._lock && this._remove) {
|
|
77
|
+
this._remove = false;
|
|
78
|
+
Utils.removeClass(this._wave, 'ripple-go');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
_set(val = this.target) {
|
|
82
|
+
val.addEventListener('mousedown', this._rippleHandler, false);
|
|
83
|
+
val.addEventListener('touchstart', this._rippleHandler, false);
|
|
84
|
+
val.addEventListener('touchend', this._unrippleHandler, false);
|
|
85
|
+
val.addEventListener('mouseup', this._unrippleHandler, false);
|
|
86
|
+
val.addEventListener('mousemove', this._unrippleHandler, false);
|
|
87
|
+
}
|
|
88
|
+
_reset(old = this.target) {
|
|
89
|
+
old.removeEventListener('mousedown', this._rippleHandler, false);
|
|
90
|
+
old.removeEventListener('touchstart', this._rippleHandler, false);
|
|
91
|
+
old.removeEventListener('touchend', this._unrippleHandler, false);
|
|
92
|
+
old.removeEventListener('mouseup', this._unrippleHandler, false);
|
|
93
|
+
old.removeEventListener('mousemove', this._unrippleHandler, false);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
__decorate([
|
|
97
|
+
ViewChild('.' + RIPPLE_CSS)
|
|
98
|
+
], PacemFxRippleElement.prototype, "_wave", void 0);
|
|
99
|
+
PacemFxRippleElement = __decorate([
|
|
100
|
+
CustomElement({
|
|
101
|
+
tagName: P + '-fx-ripple', shadow: Defaults.USE_SHADOW_ROOT,
|
|
102
|
+
template: `<div class="${RIPPLE_CSS}"></div>`
|
|
103
|
+
})
|
|
104
|
+
], PacemFxRippleElement);
|
|
105
|
+
export { PacemFxRippleElement };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Watch, PropertyConverters, PacemEventTarget } from '@pacem/pacem-core';
|
|
8
|
+
export class PacemFxElement extends PacemEventTarget {
|
|
9
|
+
}
|
|
10
|
+
__decorate([
|
|
11
|
+
Watch({ converter: PropertyConverters.Element })
|
|
12
|
+
], PacemFxElement.prototype, "target", void 0);
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pacem/pacem-fx",
|
|
3
|
+
"files": [
|
|
4
|
+
"dist/browser/*.*",
|
|
5
|
+
"dist/bundle/*.*",
|
|
6
|
+
"dist/esm/*.*",
|
|
7
|
+
"typings/*.*",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE",
|
|
10
|
+
"NOTICE",
|
|
11
|
+
"package.json"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@pacem/pacem-foundation": "*",
|
|
16
|
+
"@pacem/pacem-core": "*"
|
|
17
|
+
},
|
|
18
|
+
"main": "./dist/esm/index.js",
|
|
19
|
+
"module": "./dist/esm/index.js",
|
|
20
|
+
"typings": "./typings/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/esm/index.js",
|
|
24
|
+
"types": "./typings/index.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"version": "1.0.0-abel",
|
|
28
|
+
"author": {
|
|
29
|
+
"name": "Pacem",
|
|
30
|
+
"url": "https://pacem.it"
|
|
31
|
+
},
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"homepage": "https://js.pacem.it",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/pacem-it/pacem.git"
|
|
37
|
+
}
|
|
38
|
+
}
|