@blockquote-web-components/blockquote-base-embedded-webview 1.6.6 → 1.7.0

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/README.md CHANGED
@@ -171,14 +171,13 @@ It will create a `select` tag with the provided demo HTML files and add the `[da
171
171
 
172
172
  ##### Methods
173
173
 
174
- | Name | Privacy | Description | Parameters | Return | Inherited From |
175
- | ------------------------------- | ------- | ----------- | ------------ | ------ | -------------- |
176
- | `_doubleclickForCssInitialSize` | | | | | |
177
- | `_createResizer` | | | `DOMRect` | | |
178
- | `_removeResizer` | | | | | |
179
- | `_resizer` | | | `{ detail }` | | |
180
- | `_dispatchResizeEvent` | | | | | |
181
- | `_getBoundingClientRect` | | | `DOMRect` | | |
174
+ | Name | Privacy | Description | Parameters | Return | Inherited From |
175
+ | ------------------------------- | ------- | ----------- | ------------------------------------ | ------ | -------------- |
176
+ | `_doubleclickForCssInitialSize` | | | | | |
177
+ | `_createResizer` | | | `DOMRect: !string, ev: PointerEvent` | | |
178
+ | `_resizer` | | | `{ detail }` | | |
179
+ | `_dispatchResizeEvent` | | | | | |
180
+ | `_getBoundingClientRect` | | | `DOMRect: !string` | | |
182
181
 
183
182
  ##### Events
184
183
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockquote-web-components/blockquote-base-embedded-webview",
3
- "version": "1.6.6",
3
+ "version": "1.7.0",
4
4
  "description": "Webcomponent blockquote-base-embedded-webview following open-wc recommendations",
5
5
  "keywords": [
6
6
  "lit",
@@ -174,17 +174,15 @@
174
174
  }
175
175
  },
176
176
  "dependencies": {
177
- "@blockquote/polymer": "^3.4.4",
178
177
  "lit": "^3.1.1"
179
178
  },
180
179
  "devDependencies": {
181
180
  "@blockquote-web-components/blockquote-base-common-dev-dependencies": "^1.7.3",
182
- "@blockquote-web-components/blockquote-foundations-sass": "^1.1.2",
183
- "@polymer/iron-test-helpers": "^3.0.1"
181
+ "@blockquote-web-components/blockquote-foundations-sass": "^1.1.2"
184
182
  },
185
183
  "publishConfig": {
186
184
  "access": "public"
187
185
  },
188
186
  "customElements": "custom-elements.json",
189
- "gitHead": "7cab55d07987e71874de7ca265dac10c5ce070d6"
187
+ "gitHead": "d9bc07c424437dd78ecace41ec5465ebda063ab8"
190
188
  }
@@ -1,5 +1,4 @@
1
1
  import { html, LitElement } from 'lit';
2
- import * as Gestures from '@blockquote/polymer/lib/utils/gestures.js';
3
2
  import { styles } from './styles/blockquote-base-embedded-webview-resize-styles.css.js';
4
3
 
5
4
  // https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#value - window.scrollY to get a bounding rectangle which is independent from the current scrolling position.
@@ -23,7 +22,6 @@ export class BlockquoteBaseEmbeddedWebviewResize extends LitElement {
23
22
  super();
24
23
  this._cursor = '';
25
24
  this._resizer = this._resizer.bind(this);
26
- this._removeResizer = this._removeResizer.bind(this);
27
25
  this._createResizerLeft = this._createResizer.bind(this, 'right');
28
26
  this._createResizerRight = this._createResizer.bind(this, 'left');
29
27
  this._createResizerBottom = this._createResizer.bind(this, 'top');
@@ -45,11 +43,11 @@ export class BlockquoteBaseEmbeddedWebviewResize extends LitElement {
45
43
  this.leftResizerElement = this.shadowRoot?.querySelector('.resizer-w');
46
44
  this.bottomResizerElement = this.shadowRoot?.querySelector('.resizer-s');
47
45
 
48
- this.leftResizerElement?.addEventListener('mousedown', this._createResizerLeft);
49
- this.rightResizerElement?.addEventListener('mousedown', this._createResizerRight);
50
- this.bottomResizerElement?.addEventListener('mousedown', this._createResizerBottom);
51
- this.bottomLeftResizerElement?.addEventListener('mousedown', this._createResizerBottomLeft);
52
- this.bottomRightResizerElement?.addEventListener('mousedown', this._createResizerBottomRight);
46
+ this.leftResizerElement?.addEventListener('pointerdown', this._createResizerLeft);
47
+ this.rightResizerElement?.addEventListener('pointerdown', this._createResizerRight);
48
+ this.bottomResizerElement?.addEventListener('pointerdown', this._createResizerBottom);
49
+ this.bottomLeftResizerElement?.addEventListener('pointerdown', this._createResizerBottomLeft);
50
+ this.bottomRightResizerElement?.addEventListener('pointerdown', this._createResizerBottomRight);
53
51
 
54
52
  this.bottomResizerElement?.addEventListener('dblclick', this._doubleclickForCssInitialSize);
55
53
  }
@@ -78,29 +76,52 @@ export class BlockquoteBaseEmbeddedWebviewResize extends LitElement {
78
76
  this.removeAttribute('style');
79
77
  }
80
78
 
81
- _createResizer(DOMRect) {
79
+ /**
80
+ * @param {!string} DOMRect
81
+ * @param {PointerEvent} ev
82
+ */
83
+ _createResizer(DOMRect, ev) {
84
+ this.setAttribute('resizing', '');
85
+
82
86
  this._getBoundingClientRecDOMRect = DOMRect;
83
87
  this._getBoundingClientRectWidth = this._getBoundingClientRect('width');
84
88
  this._getBoundingClientRectHeight = this._getBoundingClientRect('height');
85
-
86
- this.setAttribute('resizing', '');
87
- Gestures.addListener(document, 'track', /** @type {*} */ (this._resizer));
88
- document.addEventListener('mouseup', this._removeResizer);
89
- }
90
-
91
- _removeResizer() {
92
- this.removeAttribute('resizing');
93
-
94
- Gestures.removeListener(document, 'track', /** @type {*} */ (this._resizer));
95
- document.removeEventListener('mouseup', this._removeResizer);
96
- this._dispatchResizeEvent();
89
+ const { target, pointerId, clientX: trackDistanceX, clientY: trackDistanceY } = ev;
90
+
91
+ /** @type {Element} */ (target)?.setPointerCapture(pointerId);
92
+
93
+ /**
94
+ * @param {!PointerEvent} moveEvent
95
+ */
96
+ const addResizer = ({ clientX, clientY }) => {
97
+ const dx = Math.round(clientX - trackDistanceX);
98
+ const dy = Math.round(clientY - trackDistanceY);
99
+ this._resizer({ detail: { dx, dy } });
100
+ };
101
+ target?.addEventListener(
102
+ 'pointermove',
103
+ /** @type {EventListenerOrEventListenerObject} */ (addResizer),
104
+ );
105
+
106
+ const removeResizer = () => {
107
+ this.removeAttribute('resizing');
108
+ /** @type {Element} */ (target)?.releasePointerCapture(pointerId);
109
+ target?.removeEventListener(
110
+ 'pointermove',
111
+ /** @type {EventListenerOrEventListenerObject} */ (addResizer),
112
+ );
113
+ target?.removeEventListener('pointerup', removeResizer);
114
+
115
+ this._dispatchResizeEvent();
116
+ };
117
+ target?.addEventListener('pointerup', removeResizer);
97
118
  }
98
119
 
99
120
  _resizer({ detail }) {
100
121
  let cssOffsetX;
101
122
  let cssOffsetY;
102
- const dx = Math.floor(detail.dx * 2.02);
103
- const dy = Math.floor(detail.dy * 1.02);
123
+ const dx = Math.floor(detail.dx * 2.04);
124
+ const dy = Math.floor(detail.dy * 1.04);
104
125
  // http://jsfiddle.net/MissoulaLorenzo/gfn6ob3j/
105
126
  switch (this._getBoundingClientRecDOMRect) {
106
127
  case 'right':
@@ -132,8 +153,7 @@ export class BlockquoteBaseEmbeddedWebviewResize extends LitElement {
132
153
  this.style.setProperty('--blockquote-base-embedded-webview-resize-rect-width', cssOffsetX);
133
154
  this.style.setProperty('--blockquote-base-embedded-webview-resize-rect-height', cssOffsetY);
134
155
  break;
135
- /* c8 ignore next */
136
- default:
156
+ /* c8 ignore next */ default:
137
157
  }
138
158
 
139
159
  this._dispatchResizeEvent();
@@ -156,6 +176,9 @@ export class BlockquoteBaseEmbeddedWebviewResize extends LitElement {
156
176
  this.dispatchEvent(event);
157
177
  }
158
178
 
179
+ /**
180
+ * @param {!string} DOMRect
181
+ */
159
182
  _getBoundingClientRect(DOMRect) {
160
183
  return Math.abs(parseInt(this.rect?.getBoundingClientRect()[DOMRect], 10));
161
184
  }